In Android if I have information I want to persist across sessions I know I can use SharedPreferences or create a SQLite database or even write a file to the device and read it in later.
Is there a way to save and restore data like this just using Flutter? Or would I need to write device-specific code for Android and iOS like in the services example?
If you are in a situation where you wanna save a small value that you wanna refer later. then you should store your data as key-value data using shared_preferences
- Storing key-value data on disk
but if you want to store large data you should go with SQLITE
- How to get Started with SQLITE in Flutter
however you can always use firebase database which is available offline
- how to add firebase to your flutter project
- Firebase for Flutter Codelab from google
Since we are talking about local storage you can always read and write files to the disk
- Reading and Writing Files
Other solutions :
- Simple Embedded Application Store database
- A Flutter plugin to store data in secure storage
You can use shared preferences from flutter's official plugins.
https://github.com/flutter/plugins/tree/master/packages/shared_preferences
It uses Shared Preferences for Android, NSUserDefaults for iOS.
I think If you are going to store large amount of data in local storage you can use sqflite library. It is very easy to setup and I have personally used for some test project and it works fine.
https://github.com/tekartik/sqflite
This a tutorial - https://proandroiddev.com/flutter-bookshelf-app-part-2-personal-notes-and-database-integration-a3b47a84c57
If you want to store data in cloud you can use firebase. It is solid service provide by google.
https://firebase.google.com/docs/flutter/setup