Home > other >  How to migrate local data with server data on Flutter?
How to migrate local data with server data on Flutter?

Time:08-28

I am creating a Flashcard app. I've created and stored the data in SQL database locally. The user creates his own words... Now I want to get data/words/ from the server.

  • What is the best practice for this?/displaying local data with network data/

CodePudding user response:

The best practice for any software development would be its initial phase of development where the focus is more on the architecture of the project instead of logic building and all. In this phase one can judge for the scalability of the application and decide the architecture in the same way. For your case, a better architecture can do better like:

UI

Provider or Controller for business logic

Repository

Storage

|→Local

|→Network

You can have the logic to handle the data into the repository part where you can control: from where to get the data and what to do with the data from multiple sources. You can design an architecture for yourself which might be different from the above one but scalability must be there :)

CodePudding user response:

you can create a model class of Flashcard. and after getting data from DB you can call your api and add its response to your DB response and show them both to user. just remember your api response and DB response should be similar to each other.

  • Related