jonataslaw / getx

Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get.
MIT License
10.25k stars 1.61k forks source link

Null check operator used on a null value #2092

Open doronnahum opened 2 years ago

doronnahum commented 2 years ago

Hi, in some cases when i change view i get this exception:

location: GetStream.removeSubscription (package:get/get_rx/src/rx_stream/get_stream.dart:22:17) error: Null check operator used on a null value code: " FutureOr<bool?> removeSubscription(LightSubscription subs) async { if (!_isBusy!) { "

0 GetStream.removeSubscription (package:get/get_rx/src/rx_stream/get_stream.dart:22:17)

1 LightSubscription.cancel (package:get/get_rx/src/rx_stream/get_stream.dart:148:24)

2 NotifyManager.close. (package:get/get_rx/src/rx_types/rx_core/rx_impl.dart:183:22)

3 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:539:8)

4 NotifyManager.close (package:get/get_rx/src/rx_types/rx_core/rx_impl.dart:181:20)

5 _ObxState.dispose (package:get/get_state_manager/src/rx_flutter/rx_obx_widget.dart:48:15)

6 StatefulElement.unmount (package:flutter/src/widgets/framework.dart:4818:11)

7 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1883:13)

8 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7)

9 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4642:14)

10 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13)

11 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7)

12 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6110:14)

13 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13)

14 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7)

15 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6110:14)

16 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13)

17 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7)

18 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6110:14)

19 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13)

20 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7)

21 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4642:14)

22 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13)

23 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7)

24 MultiChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6225:16)

25 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13)

26 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7)

27 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6110:14)

28 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13)

29 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7)

30 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4642:14)

31 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13)

32 ListIterable.forEach (dart:_internal/iterable.dart:39:13)

33 _InactiveElements._unmountAll (package:flutter/src/widgets/framework.dart:1892:25)

34 BuildOwner.finalizeTree. (package:flutter/src/widgets/framework.dart:2837:27)

35 BuildOwner.lockState (package:flutter/src/widgets/framework.dart:2468:15)

36 BuildOwner.finalizeTree (package:flutter/src/widgets/framework.dart:2836:7)

37 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:884:19)

38 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:363:5)

39 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1145:15)

40 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1082:9)

41 SchedulerBinding.scheduleWarmUpFrame. (package:flutter/src/scheduler/binding.dart:863:7)

42 Timer._createTimer. (dart:async-patch/timer_patch.dart:18:15)

43 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:395:19)

44 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:426:5)

45 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)

hungryemon commented 2 years ago

Same Issure

igorvidottof commented 1 year ago

Same here... Any updates on that?

GelidGeorge commented 1 year ago

try something like this...

Closing RxFoo in OnClose() { rxFoo.subject.isClosed? rxFoo.close() : null }

this is not healthy but a quick fix...

or Do Your Navigation and State Management Differently and Efficeiently.

macy11 commented 1 year ago

What's the reason?

GelidGeorge commented 1 year ago

Some streams might be closed in some other methods of a class, this results in trying to close a stream that's already closed. So better thing to do is check if the stream in question is already closed or create a clean code that will not result in this to happen. I recommend using “flutter_bloc” as this is an overkill and doesn't give many options like “go_router” and “flutter_bloc” gives you. Well, I have decided not use getx any time soon for any of the projects that I do in the near future.

jahidsakan commented 8 months ago

Im facing same issue . any solution?

ShafiMunshi commented 3 weeks ago

I am facing this issue when I try to navigating route or pop() from the stack. Where is the main issue?