flutter_showcaseview icon indicating copy to clipboard operation
flutter_showcaseview copied to clipboard

Hot Reload Error This widget has been unmounted, so the State no longer has a context

Open Cedar1012 opened this issue 4 years ago • 5 comments

FlutterError (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.)

Cedar1012 avatar Jul 15 '22 04:07 Cedar1012

@Stage18 Can you please share some code snippets and steps using which we can replicate the issue?

DhavalRKansara avatar Jul 15 '22 05:07 DhavalRKansara

It happens for sure when app UI is generated dynamically so the GlobalKey must be also generated on demand.

mapOfShowCaseGlobalKeys.putIfAbsent(nameOfTheGlobalKey, () => GlobalKey());

instead of

mapOfShowCaseGlobalKeys[nameOfTheGlobalKey] = GlobalKey();

Maybe it's the case in your issue @Stage18. Instead of generating new global keys for every UI state, try to generate it once, and keep them in memory and assign them to the same widgets.

ADeVNooN avatar Jul 17 '22 20:07 ADeVNooN

Thanks a lot @7AveNooN7 ! It was my issue

++ Adrien

leRayGorbella avatar Jul 18 '22 19:07 leRayGorbella

It happens for sure when app UI is generated dynamically so the GlobalKey must be also generated on demand.

mapOfShowCaseGlobalKeys.putIfAbsent(nameOfTheGlobalKey, () => GlobalKey());

instead of

mapOfShowCaseGlobalKeys[nameOfTheGlobalKey] = GlobalKey();

Maybe it's the case in your issue @Stage18. Instead of generating new global keys for every UI state, try to generate it once, and keep them in memory and assign them to the same widgets.

Hi @7AveNooN7 Thanks for contributing to the issue, @Stage18 Can you please confirm that your issue has been resolved by the changes suggested by @7AveNooN7?

DhavalRKansara avatar Jul 19 '22 12:07 DhavalRKansara

Seems like provided solutions by @7AveNooN7 fixes the issue, So closing this issue for now. Feel free to reopen the issue if any assistance is required.

DhavalRKansara avatar Jul 25 '22 06:07 DhavalRKansara