There are many ways to persistence data in flutter.
Shared Preferences
packages/packages/shared_preferences/shared_preferences at main Β· flutter/packages Β· GitHub
Shared _preferences is the easy way to persistence data.
Wraps platform-specific persistent storage for simple data (NSUserDefaults on iOS and macOS, SharedPreferences on Android, etc.). Data may be persisted to disk asynchronously, and there is no guarantee that writes will be persisted to disk after returning, so this plugin must not be used for storing critical data.
Database
Hive
GitHub - hivedb/hive: Lightweight and blazing fast key-value database written in pure Dart.
Hive is a lightweight and blazing fast key-value database written in pure Dart. Inspired by Bitcask .
Before you start Consider using Isar , a Flutter database by the author of Hive that is superior in every way!
Features
- π Cross platform: mobile, desktop, browser
- β‘ Great performance (see benchmark )
- β€οΈ Simple, powerful, & intuitive API
- π Strong encryption built in
- π NO native dependencies
- π Batteries included
Drift
Note: Moor has been renamed to drift
Drift is a reactive persistence library for Flutter and Dart, built on top of sqlite. Drift is
- Flexible: Drift lets you write queries in both SQL and Dart, providing fluent apis for both languages. You can filter and order results or use joins to run queries on multiple tables. You can even use complex sql features like WITH and WINDOW clauses.
- π₯Feature rich: Drift has builtin support for transactions, schema migrations, complex filters and expressions, batched updates and joins. We even have a builtin IDE for SQL!
- π¦Modular: Thanks to builtin support for daos and imports in sql files, drift helps you keep your database code simple.
- π‘οΈSafe: Drift generates typesafe code based on your tables and queries. If you make a mistake in your queries, drift will find it at compile time and provide helpful and descriptive lints.
- β‘Fast: Even though drift lets you write powerful queries, it can keep up with the performance of key-value stores like shared preferences and Hive. Drift is the only major persistence library with builtin threading support, allowing you to run database code across isolates with zero additional effort.
- Reactive: Turn any sql query into an auto-updating stream! This includes complex queries across many tables
- βοΈCross-Platform support: Drift works on Android, iOS, macOS, Windows, Linux and the web. This template is a Flutter todo app that works on all platforms.
- π‘οΈBattle tested and production ready: Drift is stable and well tested with a wide range of unit and integration tests. It powers production Flutter apps.
Isar
GitHub - isar/isar: Extremely fast, easy to use, and fully async NoSQL database for Flutter
Isar [ee-zahr]:
1 River in Bavaria, Germany.
2 Crazy fast NoSQL database that is a joy to use.
Features
- π Made for Flutter. Easy to use, no config, no boilerplate
- π Highly scalable The sky is the limit (pun intended)
- π Feature rich. Composite & multi-entry indexes, query modifiers, JSON support etc.
- β± Asynchronous. Parallel query operations & multi-isolate support by default
- π¦ Open source. Everything is open source and free forever! Isar database can do much more (and we are just getting started)
- π΅οΈ Full-text search. Make searching fast and fun
- π± Multiplatform. iOS, Android, Desktop
- π§ͺ ACID semantics. Rely on database consistency
- π Static typing. Compile-time checked and autocompleted queries
- β¨ Beautiful documentation. Readable, easy to understand and ever-improving