Home > Mobile >  loading a page in background in Flutter
loading a page in background in Flutter

Time:01-31

I need to load some data in a global variable in Flutter every minute. To load the data (which is a list) to my global data, I need to open another page. But how can I open that page in the background because I do not need that page, I just want to get some data from it.

CodePudding user response:

create a different class and write a function that instantiates a list from itself enter image description here

CodePudding user response:

Loading a Page is something related to UI or Presentation layer but loading your data is related to Business layer, you need to keep separate them from each other

There is a topic known as State Management, you should centralize your data providers to a separate layer and change your Presentation layer based on the State of your data

First of all take a look at this link, here is an example of using Provider pattern to manage different State of your data

Then you can use some more complicated libraries like BLOC library for State Management

  •  Tags:  
  • Related