Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: This widget has been unmounted, so the State no longer has a context. #51

Open
amrogad opened this issue Aug 9, 2024 · 0 comments

Comments

@amrogad
Copy link

amrogad commented Aug 9, 2024

======== Exception caught by foundation library ====================================================
The following assertion was thrown while dispatching notifications for AdvancedDrawerController:
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.
When the exception was thrown, this was the stack: 
#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      _AdvancedDrawerState._handleControllerChanged (package:flutter_advanced_drawer/src/widget.dart:250:7)
#3      ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:433:24)
#4      ValueNotifier.value= (package:flutter/src/foundation/change_notifier.dart:555:5)
#5      AdvancedDrawerController.showDrawer (package:flutter_advanced_drawer/src/controller.dart:11:5)
#6      HomeView.build.<anonymous closure> (package:smarterblinds/widgets/scaffolds/home.dart:66:84)
#7      _InkResponseState.handleTap (package:flutter/src/material/ink_well.dart:1183:21)
#8      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:315:24)
#9      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:652:11)
#10     BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:309:5)
#11     BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:279:7)
#12     GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:167:27)
#13     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:499:20)
#14     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:475:22)
#15     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:430:11)
#16     GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:420:7)
#17     GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:383:5)
#18     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:330:7)
#19     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:299:9)
#20     _invoke1 (dart:ui/hooks.dart:328:13)
#21     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:429:7)
#22     _dispatchPointerDataPacket (dart:ui/hooks.dart:262:31)
The AdvancedDrawerController sending notification was: AdvancedDrawerController#0459d(Instance of 'AdvancedDrawerValue')
====================================================================================================

even though in the new package version context is mounted in _HandleControllerChanged I still get the error

void _handleControllerChanged() {
    // Check if the widget is still mounted
    if (context.mounted) {
      // If the value of _controller is visible, forward the animation; otherwise, reverse it
      _controller.value.visible ? _animationController.forward() : _animationController.reverse();
    }
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant