showZdsPopOver<T> function

Future<T?> showZdsPopOver<T>(
  1. {required BuildContext context,
  2. required WidgetBuilder builder,
  3. Color? backgroundColor,
  4. double radius = 6,
  5. double contentDyOffset = 0.0,
  6. Duration transitionDuration = const Duration(milliseconds: 100),
  7. BoxConstraints? constraints,
  8. VoidCallback? onPop,
  9. String? barrierLabel}
)

Future that creates a popover.

  • context (required) The context of the popover.
  • builder (required) A WidgetBuilder that builds the content of the popover. This will be wrapped in a popover of Zds style. Usually a function that returns a Text.
  • backgroundColor The background color of the popover. Defaults to ColorScheme.surface.
  • radius Radius of the popover's body. Defaults to 6.
  • contentDyOffset The vertical offset of the popover from the icon.
  • constraints Defines the constraints for the child of the popover.
  • onPop VoidCallback function that is called when the popover is popped.
  • barrierLabel Semantic label used for a dismissible barrier.

Implementation

Future<T?> showZdsPopOver<T>({
  required BuildContext context,
  required WidgetBuilder builder,
  Color? backgroundColor,
  double radius = 6,
  double contentDyOffset = 0.0,
  Duration transitionDuration = const Duration(milliseconds: 100),
  BoxConstraints? constraints,
  VoidCallback? onPop,
  String? barrierLabel,
}) {
  final Offset parentPosition = context.widgetGlobalPosition;
  final bool parentIsAtTopHandSide = (parentPosition.dy + contentDyOffset) < MediaQuery.of(context).size.height / 2;
  final PopoverDirection direction = parentIsAtTopHandSide ? PopoverDirection.bottom : PopoverDirection.top;

  return showPopover<T>(
    context: context,
    transitionDuration: transitionDuration,
    bodyBuilder: builder,
    onPop: onPop,
    direction: direction,
    arrowHeight: 10,
    arrowWidth: 25,
    radius: radius,
    backgroundColor: backgroundColor ?? Theme.of(context).colorScheme.surface,
    barrierColor: Colors.transparent,
    contentDyOffset: contentDyOffset,
    constraints: constraints,
    barrierLabel: barrierLabel,
  );
}