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

A few questions #5

Closed
modulovalue opened this issue Nov 23, 2019 · 1 comment
Closed

A few questions #5

modulovalue opened this issue Nov 23, 2019 · 1 comment

Comments

@modulovalue
Copy link

Hey,

Thank you for the widget, I always wanted to use Overlays. You've made it so easy that I had to give it a go :)

I ran into a couple of issues using overlay_container with my custom logic. I've managed to resolve them by changing a few things and I wanted to ask you if I may have missed something.

1: Why did you decide to put a Future.delayed in your _show method?
2: all WidgetsBinding.instance.addPostFrameCallback are ensured to be executed in the order in which they are called. Is there a reason why you're calling _overlayEntry.remove(); again in show?

I managed to resolve my issues by changing _show and _hide to:

  void _show() {
    if (!_opened) {
      WidgetsBinding.instance.addPostFrameCallback((_) async {
        _overlayEntry = _buildOverlayEntry();
        Overlay.of(context).insert(_overlayEntry);
        _opened = true;
      });
    }
  }

  void _hide() {
    if (_opened) {
      WidgetsBinding.instance.addPostFrameCallback((_) {
        _overlayEntry.remove();
        _opened = false;
      });
    }
  }

Am I missing something here?

@modulovalue
Copy link
Author

Oh, it's obvious, you wanted to leave it open for a while, duh!

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