show<T extends Object> static method

Future<T?> show<T extends Object>({
  1. required BuildContext context,
  2. required List<T> items,
  3. required Widget itemBuilder(
    1. T data
    ),
  4. Widget buttonBuilder(
    1. int i,
    2. T data
    )?,
  5. void onSelected(
    1. T
    )?,
  6. GlobalKey<State<StatefulWidget>>? buttonKey,
  7. Alignment alignment = Alignment.topCenter,
  8. Duration? debounce,
  9. double width = 260,
  10. EdgeInsets margin = EdgeInsets.zero,
  11. T? initial,
  12. void onPointerUp(
    1. BuildContext
    )? = _popNavigator,
})

Displays a Selector wrapped in a modal popup.

Implementation

static Future<T?> show<T extends Object>({
  required BuildContext context,
  required List<T> items,
  required Widget Function(T data) itemBuilder,
  Widget Function(int i, T data)? buttonBuilder,
  void Function(T)? onSelected,
  GlobalKey? buttonKey,
  Alignment alignment = Alignment.topCenter,
  Duration? debounce,
  double width = 260,
  EdgeInsets margin = EdgeInsets.zero,
  T? initial,
  void Function(BuildContext)? onPointerUp = _popNavigator,
}) {
  final bool isMobile = context.isMobile;

  Widget builder(BuildContext context) {
    return Selector<T>(
      debounce: debounce,
      initial: initial,
      items: items,
      itemBuilder: itemBuilder,
      buttonBuilder: buttonBuilder,
      onSelected: onSelected,
      buttonKey: buttonKey,
      alignment: alignment,
      width: width,
      margin: margin,
      isMobile: isMobile,
      onPointerUp: onPointerUp,
    );
  }

  final style = Theme.of(context).style;

  return showDialog(
    context: context,
    barrierColor: style.colors.transparent,
    useSafeArea: false,
    builder: builder,
  );
}