几个小时以来,我一直在努力解决这个问题。BLoC 和 StreamController 有一些解决方案,但 GetX 没有合适的解决方案。
正如他们从 BloC 回答的建议,我知道它可能与GetXController dispose有关。然后我在初始化 user_controller 的页面上为控制器应用dispose()方法。但仍然有如下错误
Unhandled Exception: 'package:get/get_rx/src/rx_stream/get_stream.dart': Failed assertion: line 90 pos 12: '!isClosed': You cannot add event to closed Stream
E/flutter (21576): #0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:46:39)
E/flutter (21576): #1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5)
E/flutter (21576): #2 GetStream.add (package:get/get_rx/src/rx_stream/get_stream.dart:90:12)
E/flutter (21576): #3 NotifyManager.addListener.<anonymous closure> (package:get/get_rx/src/rx_types/rx_core/rx_impl.dart:139:15)
E/flutter (21576): #4 GetStream._notifyData (package:get/get_rx/src/rx_stream/get_stream.dart:47:21)
E/flutter (21576): #5 GetStream.add (package:get/get_rx/src/rx_stream/get_stream.dart:92:5)
E/flutter (21576): #6 RxObjectMixin.value= (package:get/get_rx/src/rx_types/rx_core/rx_impl.dart:101:13)
E/flutter (21576): #7 UserController.getUserData (package:hellobabybox/controllers/user_controller.dart:20:12)
提前致谢。