minikin / popover

Popover for Flutter. A popover is a transient view that appears above other content onscreen when you tap a control or in an area.
https://pub.dev/packages/popover
MIT License
166 stars 54 forks source link

How to manually turn it off #70

Closed wangjunjx8868 closed 1 year ago

wangjunjx8868 commented 1 year ago

Is your feature request related to a problem? Please describe. How to manually turn it off Describe the solution you'd like click a button hide popover .

minikin commented 1 year ago

Please, read documentation https://pub.dev/documentation/popover/latest/popover/showPopover.html

theashishsuthar commented 1 year ago

Could you please describe more? i didn't find any way to close the pop over progrmaticallty

LouisHaftmann commented 8 months ago

The popover behaves just like a Flutter Dialog. So you can use Navigator.of(context).pop(); to close it:

showPopover(
  context: context,
  bodyBuilder: (context) {
    return ElevatedButton(
      onPressed: () {
        Navigator.of(context).pop();
      },
      child: Text('Close'),
    );
  },
);

just in case someone still needs this :)

justincbeck commented 5 months ago

Sounds good. How can I tell if the popover is visible or not? I can't just blindly call Navigator.of(context.pop();.

LouisHaftmann commented 5 months ago

You would typically call Navigator.of(context).pop() from within the popover, so you know it's open.