当我尝试使用Firebase注销时抛出错误。我尝试了此解决方案,但不适用于注销link。 Flutter Navigator给出了链接中提到的错误,但该解决方案不起作用。
//Walk the array and add the needed data into another array
array_walk($csv, function($row) use (&$data) {
if(!empty($data[$row[3]]))
{
$data[$row[3]] += (int) $row[8];
}
else {
$data[$row[3]] = (int) $row[8];
}
});
当我尝试使用AppBar的操作注销时,出现上述错误。我正在使用的代码。抖动导航器存在错误,但我无法修复。
E/flutter (17712): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: NoSuchMethodError: The method 'findAncestorStateOfType' was called on null.
E/flutter (17712): Receiver: null
E/flutter (17712): Tried calling: findAncestorStateOfType<NavigatorState>()
E/flutter (17712): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
E/flutter (17712): #1 Navigator.of
package:flutter/…/widgets/navigator.dart:2115
E/flutter (17712): #2 Navigator.pushReplacement
package:flutter/…/widgets/navigator.dart:1781
E/flutter (17712): #3 _HandleMainScreenState.checkAuthentication.<anonymous closure>
package:monktree/main.dart:55
E/flutter (17712): #4 _rootRunUnary (dart:async/zone.dart:1192:38)
E/flutter (17712): #5 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
E/flutter (17712): #6 _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)
E/flutter (17712): #7 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
E/flutter (17712): #8 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:266:7)
E/flutter (17712): #9 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:134:11)
E/flutter (17712): #10 _MapStream._handleData (dart:async/stream_pipe.dart:234:10)
E/flutter (17712): #11 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:166:13)
E/flutter (17712): #12 _rootRunUnary (dart:async/zone.dart:1192:38)
E/flutter (17712): #13 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
E/flutter (17712): #14 _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)
E/flutter (17712): #15 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
E/flutter (17712): #16 _DelayedData.perform (dart:async/stream_impl.dart:594:14)
E/flutter (17712): #17 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:710:11)
E/flutter (17712): #18 _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:670:7)
E/flutter (17712): #19 _rootRun (dart:async/zone.dart:1180:38)
答案 0 :(得分:0)
signout() {
FirebaseAuth.instance.signOut().then((value) {
print(widget.user.uid);
Navigator.pop(context);
}
将您的signout()
更改为以上即可。然后,使用三元表达式可以检查用户令牌还是uid != null
。
例如:
home: auth.isAuth ? AuthScreen() : TabsScreen(),