flutterdartsavedata-storagesaving-data

Saving 2d Lists to local device - Flutter


i am looking to save data to the device my Pre Delivery Checklist App is runing on (hence all the boolean data(for the checklists)). The data would look something like this:

List<List> listOfCars = [
//CUSTOMER 1
[false, "CUSTOMER NAME", "REG PLATE", false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, ],
//CUSTOMER 2
[false, "CUSTOMER NAME", "REG PLATE", false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, ],
];

I know this probably isnt the best way to store the data anyway but it works for now.

All i am looking for is a way to save it when the app closes and a way to restore the data when the app opens again. i have tried using sharedPreferences but only have luck setting hardcoded data. Is there any way i can do this please?

Thank you all in advance :-)


Solution

  • Look for a local database solution. A popular option would be sembast.

    But you don't have any callback exposed for code execution when the system decides to kill your app. You will have to save your info on the db based on specific user events or on a regular basis.