stateNotifierProvider和notifierProvider在Riverpod中的区别是什么?

huangapple go评论54阅读模式
英文:

Difference between stateNotiferProvider and notifierProvider in Riverpod

问题

在Flutter Riverpod中,notifier provider和state notifier provider之间的区别是什么,以及何时使用它们。

在Riverpod文档中,他们建议使用notifier provider而不是state notifier provider。我需要帮助确定在我的项目中何时使用它们。

英文:

What is the difference between notifier provider and state notifier provider in flutter riverpod and when to use them.

In the riverpod docs they ask to use notifier provider instead of state notifier provider. I need help to determine when to use each of them in my project.

答案1

得分: 8

NotifierStateNotifier + ChangeNotifier 的替代品。

这是一种更灵活的方法,更适用于 Riverpod,并更符合 Riverpod 的使用方式。在使用时,请优先选择 NotifierAsyncNotifier,而不是 StateNotifier/ChangeNotifier

英文:

Notifier is a replacement of StateNotifier + ChangeNotifier.

It's a more flexible approach better fit for Riverpod and more in line with how to use Riverpod. Use Notifier or AsyncNotifier in favor of StateNotifier/ChangeNotifier.

huangapple
  • 本文由 发表于 2023年5月24日 17:59:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/76322288.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定