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

'_overlay != null': is not true #329

Open
imrikim opened this issue May 28, 2024 · 2 comments
Open

'_overlay != null': is not true #329

imrikim opened this issue May 28, 2024 · 2 comments

Comments

@imrikim
Copy link

imrikim commented May 28, 2024

Exception Log :

======== Exception caught by widgets library =======================================================
The following assertion was thrown while finalizing the widget tree:
'package:flutter/src/widgets/overlay.dart': Failed assertion: line 207 pos 12: '_overlay != null': is not true.

When the exception was thrown, this was the stack: 
#2      OverlayEntry.remove (package:flutter/src/widgets/overlay.dart:207:12)
#3      _SpeedDialState.dispose (package:flutter_speed_dial/src/speed_dial.dart:252:48)
#4      StatefulElement.unmount (package:flutter/src/widgets/framework.dart:5689:11)
#5      _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:2076:13)
#6      _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:2074:7)
#7      ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:5532:14)
#8      _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:2072:13)
#9      ListIterable.forEach (dart:_internal/iterable.dart:49:13)
#10     _InactiveElements._unmountAll (package:flutter/src/widgets/framework.dart:2085:25)
#11     BuildOwner.lockState (package:flutter/src/widgets/framework.dart:2764:15)
#12     BuildOwner.finalizeTree (package:flutter/src/widgets/framework.dart:3174:7)
#13     WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:992:19)
#14     RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:448:5)
#15     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1386:15)
#16     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1311:9)
#17     SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1169:5)
#18     _invoke (dart:ui/hooks.dart:312:13)
#19     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:399:5)
#20     _drawFrame (dart:ui/hooks.dart:283:31)
(elided 2 frames from class _AssertionError)

Caused by overlayEntry != null :

  @override
  void dispose() {
    if (overlayEntry != null) {
      if (overlayEntry!.mounted) overlayEntry!.remove();
      overlayEntry!.dispose();
    }
    if (widget.renderOverlay && backgroundOverlay != null) {
      if (backgroundOverlay!.mounted) backgroundOverlay!.remove();
      backgroundOverlay!.dispose();
    }
    _controller.dispose();
    widget.openCloseDial?.removeListener(_onOpenCloseDial);
    super.dispose();
  }

suggested solution , do this instead:

  @override
 void dispose() {
   if (overlayEntry != null) {
     if (overlayEntry!.mounted) {
       overlayEntry!.remove();
       overlayEntry = null;
     }
     overlayEntry!.dispose();
   }
   if (widget.renderOverlay && backgroundOverlay != null) {
     if (backgroundOverlay!.mounted) backgroundOverlay!.remove();
     backgroundOverlay!.dispose();
   }
   _controller.dispose();
   widget.openCloseDial?.removeListener(_onOpenCloseDial);
   super.dispose();
 }
@imrikim
Copy link
Author

imrikim commented May 28, 2024

no OverlayEntry inserted to the Overlay and you try to call the remove method. that is why '_overlay != null': is not true.

@prateekmedia do you have a different approach to resolve this issue ?

@94Sip
Copy link

94Sip commented Sep 24, 2024

I also just started getting this error, again. Looking at the change log, it looks like this was solved with version 6.2, but something has caused it to reappear.

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

2 participants