我正在使用Riverpod作为我的Flutter 翼项目的状态管理,目前正在进行身份验证服务.我正在让AuthNotifier扩展AsyncNotifier.例如,当我调用AuthService时,问题是:
Future<void> logout() async {
state = const AsyncValue.loading();
state = await AsyncValue.guard(() async {
return await authService.logout();
});
state.when(
data: (data){},
error: (error, stackTrace){
ref.read(errorProvider.notifier).createException(exception: error.toString(), errorTitle: "Logout Error");
},
loading: (){},
);
}
我只是在使用状态中的错误.但我也有这个未使用的代码.
我试着寻找国家或国家的方法,但找不到任何东西,要么是因为答案不在那里,要么是因为我没有看到它.如果任何人在处理通告程序内部的错误方面有其他 Select ,我愿意接受建议.