Decoupling Flutter Views for Reusability

Decoupling Flutter Views for Reusability

Create better-structured views

Create better-structured views

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:

class CustomerListScreen extends StatelessWidget {

  final customers = ["Alex", "John", "Bryan", "Jerry", "Mary"];

  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Customers")
      body: ListView.builder(
        itemCount: customers.length,
        itemBuilder: (context, index) {
          final customer = customers[index]; 
          return ListTile(
            title: Text(customer), 
            onTap: () {
              Navigator.push(context, MaterialPageRoute(
                builder: (context) => CustomerDetailScreen(customer: customer)

programming flutter

What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Google's Flutter 1.20 stable announced with new features - Navoki

Google has announced new flutter 1.20 stable with many improvements, and features, enabling flutter for Desktop and Web

What is Flutter and why you should learn it?

Flutter is an open-source UI toolkit for mobile developers, so they can use it to build native-looking Android and iOS applications from the same code base for both platforms. Flutter is also working to make Flutter apps for Web, PWA (progressive Web-App) and Desktop platform (Windows,macOS,Linux).

Adobe XD plugin for Flutter with CodePen Tutorial

Recently Adobe XD releases a new version of the plugin that you can use to export designs directly into flutter widgets or screens.

Flutter - How to Add AdMob Real Ads in Flutter App | Flutter AdMob Tutorial

Hello Whats is up Everyone So, Today I am going to show u How to Add Admob Real ads in Flutter apps which are very Easy Implement After watching this video u...

Flutter App Development Company India, Flutter App Developers for Hire

IndianAppDevelopers offers Flutter app development services in India for Android and iOS, Hire our flutter developers to create native experience apps for the end-users.