Flutter amplify-authenticator 2.3.3 抛出StateError (Bad state: No element) 问题求助
Flutter amplify-authenticator 2.3.3 抛出StateError (Bad state: No element) 问题求助
我最近在用amplify-authenticator 2.3.3版本开发时,碰到个挺闹心的问题——运行测试代码时总是弹出StateError (Bad state: No element)的错误。仔细排查后发现,问题出在这段测试方法里:它直接调用了_authBloc.exceptions.first,但完全没提前检查_authBloc.exceptions集合里到底有没有元素!
下面是出问题的代码片段(原内容有部分截断):
@visibleForTesting Future<void> nextBlocEvent({BlocEventPredicate? where}) async { await Future.any([ _authBloc.exceptions.first, // Bloc emits current state first _au... // 原代码此处内容截断 ]); }
我本来想着回滚到2.0.0版本应该能解决这个问题,结果没想到回滚之后错误居然还存在!我实在搞不明白,这种连空集合判断都没做的明显问题,怎么会在版本迭代里留存这么久啊?有没有大佬能给我出出主意,怎么才能避开这个错误?
备注:内容来源于stack exchange,提问作者Oscar Montoya
相关产品推荐
相关产品推荐

