Flutter Architecture # The State Management in Provider Way ðŸ’™

Managing the state of the application is one of the hardest job in architecting an application, Here in out Flutter application we will be using Provider package to Architect our application.

Flutter comes with its own widget to manage the state of the application the StatefulWidget class

A widget that has mutable state.

Sample State management

 void grow() {
    setState(() { _size += 0.1; });
  }

Lets move on into our Application, Our application is a Covid’19 Tracker application that reads the data from a public api ( India Only ) and displays the data into the UI

Let’s quickly go over the structure. The lib folder is divided into four folders.

  • Ui
  • Models
  • ViewModel
  • Service

UI holds the views and is again further divided based on screen

Models holds all the plain data models, here is good tool to autogenerate your models QuickType.io which instantly parses the JSON into available languages.

ViewModel holds the Provider models for each of the Widget views

Services holds the dedicated files that will handle actual business logic