showItemPicker<T> function

Future<T?> showItemPicker<T>(
  1. BuildContext context, {
  2. required ItemChildDelegate<T> items,
  3. required ItemPickerBuilder<T> builder,
  4. T? initialValue,
  5. ItemPickerLayout layout = const GridItemPickerLayout(),
  6. AlignmentGeometry? alignment,
  7. AlignmentGeometry? anchorAlignment,
  8. BoxConstraints? constraints,
  9. Offset? offset,
  10. Widget? title,
})

Implementation

Future<T?> showItemPicker<T>(
  BuildContext context, {
  required ItemChildDelegate<T> items,
  required ItemPickerBuilder<T> builder,
  T? initialValue,
  ItemPickerLayout layout = const GridItemPickerLayout(),
  AlignmentGeometry? alignment,
  AlignmentGeometry? anchorAlignment,
  BoxConstraints? constraints,
  Offset? offset,
  Widget? title,
}) {
  final theme = Theme.of(context);
  return showPopover<T>(
    context: context,
    alignment: alignment ?? AlignmentDirectional.topStart,
    anchorAlignment: anchorAlignment ?? AlignmentDirectional.bottomStart,
    offset: offset ?? Offset(0, 8.0 * theme.scaling),
    builder: (context) {
      return SurfaceCard(
        padding: EdgeInsets.zero,
        child: _InternalItemPicker<T>(
          items: items,
          builder: builder,
          initialValue: initialValue,
          layout: layout,
          title: title,
          constraints: constraints,
          onChanged: (value) {
            closeOverlay(context, value);
          },
        ),
      );
    },
  ).future;
}