Package selection guidance compiled from public package information, community data, and project usage.
A lightweight, easy-to-use wrapper around Flutter's SharedPreferences, designed to simplify persistent data storage in Flutter applications. It abstracts common operations like saving, retrieving, and deleting key-value pairs with minimal boilerplate. Ideal for small-scale apps needing basic local storage without the complexity of full databases. The package is cross-platform, supporting Android, iOS, Web, macOS, Windows, and Linux, making it versatile for various deployment scenarios.
Use cases
Storing user preferences
Saving app state between sessions
Caching small amounts of data
Managing simple settings
Persisting login tokens
Tracking user activity
Key features
Minimal API surface
Automatic type serialization
Cross-platform compatibility
Simple setup
Lightweight footprint
Error handling
Suitable for
Beginner Flutter developers
Small to medium apps
Prototypes and MVPs
Apps with basic persistence needs
Projects avoiding complex database setups
Considerations
Not suitable for large datasets
No support for queries or indexing
Limited to key-value storage
Data not encrypted by default
Performance degrades with high-frequency writes
Best used for non-critical, small-scale data
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
Simple Database
A simple lightweight wrapper for the SharedPreferences Flutter package. Simple Database provides an abstraction layer for storing objects instead of key, value pairs. This makes it very easy to get a quick local storage solution up and running.
Please add simple_database as a dependency in your pubspec.yaml file
No Setup Primative Storage
You can easily setup a database of primitive types just by assigning it a name, Simple Database will init the DB if it has not been created yet on the phone for you.
You can use a single database that stores multiple primitive types and then specify what type you want from the database.
voidmain() async {
SimpleDatabase names = SimpleDatabase(name: 'names');
await names.add('Bob');
await names.add(150)
await names.add('Doug');
//Print out all strings in the dbfor (var name inawait names.getAllType<String>()) {
print(name);
}
//Print out at an index, with a typevar number = await names.getAtType<int>(1);
print(number);
}
Non-Primitive object storage
You can store your own objects you have created easily just by implementing 2 functions in the class. toJson and fromJson. You will need to pass the fromJson function to the constructor of SimpleDatabase if you want it to rebuild the json into your object. You do not need this, it will just return a hash map with the values from your object if the function is not provided.