Decoupling Flutter Views for Reusability

Create better-structured views

Mohammad Azam
Better Programming
Published in
3 min readFeb 8, 2021

--

Stylish building architecture
Photo by Matt Reames on Unsplash.

Flutter views represent the interface presented to the user. They provide interaction and allow the users to feel the essence of the application. Unfortunately, Flutter views are also often ignored, resulting in tightly coupled and non-reusable components.

In this article, I will discuss techniques that can help you construct more reusable and loosely coupled views.

Displaying List of Customers

Let’s consider a scenario where we have to display a list of customers in our application. When the customer is tapped, we will send the user to the detail screen. In order to create this app, we will start by implementing a CustomerListScreen widget that will represent the entire screen. We can display a list of customers by using the ListView widget. This is implemented below:

The code above works and displays a list of customers on the widget, but it is not reusable. This means if we want to display a list of customers in some other widget, we will…

--

--

Lead instructor at a coding bootcamp. Top iOS mobile instructor on Udemy. Author of multiple books and international speaker. azamsharp.school