所以我正在使用最新的 Riverpod 提供商,我想听它,这些是我要听的代码
ref.listen<AccountManagementController>(
accountManagementControllerProvider, (prev, next) {
// if(next.hasError){
// }
});
但是,我遇到了一些错误或问题
The argument type 'AsyncNotifierProviderImpl<AccountManagementController, void>' can't be assigned to the parameter type 'ProviderListenable'
最佳答案
顺便说一句,我修复了它。
ref.listen<AsyncValue<void>>(accountManagementControllerProvider,
(prev, next) {
if (!next.isLoading && next.hasError) {
_showErrorMessage(
context,
next.error.toString(),
() {
Navigator.pop(context);
},
);
}
});
关于riverpod - 如何在 flutter Riverpod 中引用监听 AsyncNotifier,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75462106/