原文
https://itnext.io/flutter-state-management-with-riverpod-ef8d4ef77392
代码
https://github.com/iisprey/riverpod_example
参考
- https://itnext.io/a-minimalist-guide-to-riverpod-4eb24b3386a1
- https://pub.dev/packages/state_notifier
- https://iisprey.medium.com/get-rid-of-all-kind-of-boilerplate-code-with-flutter-hooks-2e17eea06ca0
- https://iisprey.medium.com/how-to-handle-complex-json-in-flutter-4982015b4fdf
正文
正如我上周所承诺的,我将向您展示我自己的最终国家管理解决方案路径
Riverpod + StateNotifier + Hooks + Freezed
Riverpod 太棒了!但是好的例子并不多。只有最基本的,就这样。这一次,我试图使一个例子既可理解又复杂。我的目的是通过这个例子教你什么时候使用 Riverpod,以及如何使用它。尽管我简化了过程。希望你喜欢!
动机
在这个例子中我们要做什么?
我们只需要从 API 中获取一些数据,然后在 UI 中对它们进行排序和过滤
基本上,我们会;
- Create simple and complex providers and combine them
- 创建简单和复杂的提供程序并将它们组合起来 <