Code generation • Different kinds of providers ◦ Function Provider ◦ Class Provider • How to read a provider • How does provider works? • How to install • Todo App demo - Let’s code!
provider, freezed, and more. • riverpod (an anagram of provider) is a reactive caching framework for Flutter/Dart. • riverpod is a complete rewrite of the provider package to make improvements. • Catch errors at compile-time rather than at runtime.
and allows listening to the changes. • Allows easily accessing to a state from multiple locations. • A replacement of patterns like Singletons, Service Locators, Dependency Injection, or InheritedWidgets. @riverpod String helloWorld(HelloWorldRef ref) { return 'Hello world'; }
automatically decides and creates the best provider for the use case. • Code generation is pretty common pattern in Flutter or Dart programming. • Static metaprogramming feature is coming to dart.
New in 2.0 StateProvider - Legacy StateNotifierProvider - Legacy ChangeNotifierProvider - Legacy StreamNotifierProvider - New in 2.0 Function Provider Class Provider
from a widget or another provider. • ref.watch() to observe a provider change. ◦ It triggers rebuilding a widget or provider when it’s changed. • ref.listen() to react to a provider change. ◦ It calls the callback function registered when it’s changed. • ref.read() to obtain the state of a provider. ◦ It only read once. Whenever possible, prefer using ref.watch over ref.listen or ref.read to implement a feature. This way, the application becomes reactive and declarative.
Riverpod. • Fork the demo app code. • Add the delete feature. • Add the edit feature. • Convert selectedFilter into Provider in todo_page.dart. • Share your achievements or get help from discord.
recommended! • Riverpod snippet extension for Visual Studio Code • Build runner extension for Visual Studio Code • Code with Andrea’s tutorial - Awesome tutorials!