flutter常见问题

汇总个flutter常见问题
1、

'package:bloc/src/transition.dart': Failed assertion: line 23 pos 16: 'currentState != null': is not true.
I/System.out( 1080): #0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:42:39)
I/System.out( 1080): #1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:38:5)
I/System.out( 1080): #2      new Transition (package:bloc/src/transition.dart:23:16)
I/System.out( 1080): #3      Bloc._bindStateSubject. (package:bloc/src/bloc.dart:159:28)
I/System.out( 1080): #4      Stream.forEach.. (dart:async/stream.dart:897:45)
I/System.out( 1080): #5      _runUserCode (dart:async/stream_pipe.dart:13:23)
I/System.out( 1080): #6      Stream.forEach. (dart:async/stream.dart:897:11)
I/System.out( 1080): #7      _rootRunUnary (dart:async/zone.dart:1134:38)
I/System.out( 1080): #8      _CustomZone.runUnary (dart:async/zone.dart:1031:19)
I/System.out( 1080): #9      _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
I/System.out( 1080): #10     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:338:11)
I/System.out( 1080): #11     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:265:7)
I/System.out( 1080): #12     _SyncBroadcastStreamController._sendData (dart:async/broadcast_stream_controller.dart:377:20)
I/System.out( 1080): #13     _BroadcastStreamController._add (dart:async/broadcast_stream_controller.dart:289:5)
I/System.out( 1080): #14     _rootRunUnary (dart:async/zone.dart:1134:38)
I/System.out( 1080): #15     _CustomZone.runUnary (dart:async/zone.dart:1031:19)
I/System.out( 1080): #16     _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
I/System.out( 1080): #17     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:338:11)
I/System.out( 1080): #18     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:265:7)
I/System.out( 1080): #19     _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:134:11)
I/System.out( 1080): #20     _ForwardingStream._handleData (dart:async/stream_pipe.dart:100:10)
I/System.out( 1080): #21     _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:166:13)
I/System.out( 1080): #22     _rootRunUnary (dart:async/zone.dart:1134:38)
I/System.out( 1080): #23     _CustomZone.runUnary (dart:async/zone.dart:1031:19)
I/System.out( 1080): #24     _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
I/System.out( 1080): #25     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:338:11)
I/System.out( 1080): #26     _DelayedData.perform (dart:async/stream_impl.dart:593:14)
I/System.out( 1080): #27     _StreamImplEvents.handleNext (dart:async/stream_impl.dart:709:11)
I/System.out( 1080): #28     _PendingEvents.schedule. (dart:async/stream_impl.dart:669:7)
I/System.out( 1080): #29     _rootRun (dart:async/zone.dart:1122:38)
I/System.out( 1080): #30     _CustomZone.run (dart:async/zone.dart:1023:19)
I/System.out( 1080): #31     _CustomZone.runGuarded (dart:async/zone.dart:925:7)
I/System.out( 1080): #32     _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:965:23)
I/System.out( 1080): #33     _rootRun (dart:async/zone.dart:1126:13)
I/System.out( 1080): #34     _CustomZone.run (dart:async/zone.dart:1023:19)
I/System.out( 1080): #35     _CustomZone.runGuarded (dart:async/zone.dart:925:7)
I/System.out( 1080): #36     _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:965:23)
I/System.out( 1080): #37     _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
I/System.out( 1080): #38     _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)

是state没有初始化的问题

  @override
  get initialState => null;

加个初始化的state就好了

  @override
  get initialState => TestInitState();

你可能感兴趣的:(flutter)