See subsections for FAQs on specific topics.
Is Flutter Data a state management solution?
Flutter Data can be understood as a very specific “stream controller” (essentially taking input from
delete and incoming streams) and exposing it as a stream/notifier. As such, it can manage global state through repositories and business models, coupled with a dependency injection solution.
Managing local state with Flutter Data (e.g. active tab state) would not make much sense. Use
setState or a
Repositorys from BLoCs or view-model layers is definitely possible and encouraged. It’s also encouraged to start using Flutter Data directly from the widget layer before it’s absolutely necessary to add more complex setups.
How do I get hold of Repositories with Provider?
Remember to use
Provider.of<Repository<T>>(listen: false)) as repositories don’t change.
For access from BLoCs or other non-widget layers, you can pass the
context.read locator around (or use a global, your call).
Use or extend the provided offline adapter.
Errors generating code
If you have trouble with the outputs, try:
flutter packages pub run build_runner build --delete-conflicting-outputs
If after generating code you still see errors in your files, try reopening the project. This is not a Flutter Data issue.
Local storage for long term persistence
tl;dr don’t save anything critical (with Flutter Data) just yet
- Flutter Data is in alpha state and therefore there are no data guarantees: APIs WILL change, local formats WILL change (this is why
clear=trueby default, meaning that local storage will be wiped out when the app restarts)
- Additionally, we are waiting for Hive 2 to come out for further optimizations