Popover class

A comprehensive popover overlay system for displaying contextual content.

Popover provides a flexible foundation for creating overlay widgets that appear relative to anchor elements. It handles positioning, layering, and lifecycle management for temporary content displays such as dropdowns, menus, tooltips, and dialogs. The system automatically manages positioning constraints and viewport boundaries.

The popover system consists of:

  • Popover: Individual popover instances with control methods
  • PopoverController: Manager for multiple popovers with lifecycle control
  • PopoverLayout: Positioning and constraint resolution
  • Overlay integration for proper z-ordering and event handling

Key features:

  • Intelligent positioning with automatic viewport constraint handling
  • Multiple attachment points and alignment options
  • Modal and non-modal display modes
  • Animation and transition support
  • Barrier dismissal with configurable behavior
  • Follow-anchor behavior for responsive positioning
  • Multi-popover management with close coordination

Positioning capabilities:

  • Flexible alignment relative to anchor widgets
  • Automatic inversion when space is constrained
  • Custom offset adjustments
  • Margin and padding controls
  • Width and height constraint options

Example usage:

final controller = PopoverController();

// Show a popover
final popover = await controller.show<String>(
  context: context,
  alignment: Alignment.bottomStart,
  anchorAlignment: Alignment.topStart,
  builder: (context) => PopoverMenu(
    children: [
      PopoverMenuItem(child: Text('Option 1')),
      PopoverMenuItem(child: Text('Option 2')),
    ],
  ),
);

Properties

currentState OverlayHandlerStateMixin<StatefulWidget>?
Gets the current overlay handler state if the popover is mounted.
no setter
entry OverlayCompleter
The overlay completer that manages this popover's lifecycle.
final
hashCode int
The hash code for this object.
no setterinherited
key GlobalKey<OverlayHandlerStateMixin<StatefulWidget>>
Global key for accessing the overlay handler state.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

close([bool immediate = false]) Future<void>
Closes this popover with optional immediate dismissal.
closeLater() → void
Schedules this popover to close after the current frame.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
remove() → void
Immediately removes this popover from the overlay without animations.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited