Closed ibraheemalayan closed 7 months ago
in my case it doesn't crash BUT the same "Unhandled Exception" error appears in logs.
Fixed in v8.0.5.
@tlserver Still not fixed everywhere even in latest release, some places where there is a setState are stilling missing the if statement
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: This widget has been unmounted, so the State no longer has a context (and should be considered defunct).
Consider canceling any active work during “dispose” or using the “mounted” getter to determine if the State is still active.
#0 State.context.<anonymous closure> (package:flutter/src/widgets/framework.dart:951:9)
#1 State.context (package:flutter/src/widgets/framework.dart:957:6)
#2 _CurrentLocationLayerState._subscriptHeadingStream.<anonymous closure> (package:flutter_map_location_marker/src/widgets/current_location_layer.dart:443:14)
#3 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#4 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#5 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#6 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
#7 _MapStream._handleData (dart:async/stream_pipe.dart:218:10)
#8 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
#9 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#10 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#11 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#12 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
#13 _WhereStream._handleData (dart:async/stream_pipe.dart:195:12)
#14 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
#15 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#16 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#17 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#18 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
#19 _MapStream._handleData (dart:async/stream_pipe.dart:218:10)
#20 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
I can confirm. When running in VS Code it appears as an uncaught exception even if it doesn't crash my app.
When running directly on iPhone, the remaining issue from 8.0.5 described above surfaces as a "FlutterError". In my code I wrap the execution as follows, to be able to see any Exception or Error that might be thrown.
void main() async {
runZonedGuarded(
() async {
WidgetsFlutterBinding.ensureInitialized();
runApp(MyApp());
},
(Object e, StackTrace st) {
Logger.talker.handle(e, st, 'Uncaught app exception');
},
);
}
brilliant, thanks for 8.0.6, that fixed the Error at least for me.
Smartphone
Describe the bug
When going back to a previous page ( with some complex bloc builders ) that has map with the current location marker, the app crashes, probably because a stream listener callback was called and it uses
setState
on a disposed widget.Suggested Solution
Maybe wrap the
setState
in listeners callbacks with an if statement checking themounted
.