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

Tap screen to dismiss popup item widget #15

Open
Charon922 opened this issue Mar 13, 2020 · 7 comments
Open

Tap screen to dismiss popup item widget #15

Charon922 opened this issue Mar 13, 2020 · 7 comments

Comments

@Charon922
Copy link

hi,

Are there any ways to dismiss the popup item widget by tapping the screen?

thanks

@Charon922
Copy link
Author

image
And when I scroll the screen, it is being wired.

@rosbal
Copy link

rosbal commented Mar 15, 2020

Same question. There should be a way to dismiss the popup by tapping anywhere outside the popup (at the very least on tapping the TextField). The only way to dismiss the popup seems to be selecting a list item.

@Charon922
Copy link
Author

@rosbal Hi, I figured out how to solve it.

Need to modify the original code.
Add a dismiss function
static void dismissMenu() { if (overlayEntry != null) { overlayEntry.remove(); overlayEntry = null; _controller.clear(); _focusNode.unfocus(); } }
And then make the overlay into a stack and make the bottom layer take up the full screen, wrap it's child in a GestureDetector that calls:
return Stack(children: <Widget>[ Positioned.fill( child: GestureDetector( onTap: dismissMenu, child: Container( color: Colors.transparent, ), )), Positioned( left: position.left, width: width, child: CompositedTransformFollower( .....

@rosbal
Copy link

rosbal commented Mar 23, 2020

@Charon922

Worked like a charm. Thanks for sharing.

@Enigma-I-am
Copy link

@rosbal Hi, I figured out how to solve it.

Need to modify the original code.
Add a dismiss function
static void dismissMenu() { if (overlayEntry != null) { overlayEntry.remove(); overlayEntry = null; _controller.clear(); _focusNode.unfocus(); } }
And then make the overlay into a stack and make the bottom layer take up the full screen, wrap it's child in a GestureDetector that calls:
return Stack(children: <Widget>[ Positioned.fill( child: GestureDetector( onTap: dismissMenu, child: Container( color: Colors.transparent, ), )), Positioned( left: position.left, width: width, child: CompositedTransformFollower( .....

Hello...
@Charon922 I am having this same issue and I don't understand your solution, Where do you make these changes?? and would you be able to give a more detailed example.

Please do forgive me If this sounds like an awkward request I am new to flutter

@dleurs
Copy link

dleurs commented May 8, 2020

Here is the code thanks to Charon922 comment ! I will try to make a pull request
search_widget copie.dart.txt

@Enigma-I-am
Copy link

Thank you much @dleurs

umerf52 added a commit to umerf52/search_widget that referenced this issue Aug 14, 2020
@umerf52 umerf52 mentioned this issue Aug 14, 2020
apgapg pushed a commit that referenced this issue Oct 6, 2020
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

4 participants