showItemPicker<T> function
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,
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,
}) {
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) {
final theme = Theme.of(context);
final mediaQuery = MediaQuery.of(context);
return SurfaceCard(
padding: EdgeInsets.zero,
child: ConstrainedBox(
constraints: constraints ??
BoxConstraints(
maxWidth: 320 * theme.scaling,
maxHeight: 320 * theme.scaling,
),
child: MediaQuery(
data: mediaQuery.copyWith(
padding:
mediaQuery.padding + EdgeInsets.all(8.0 * theme.scaling)),
child: ItemPickerDialog<T>(
items: items,
builder: builder,
value: initialValue,
layout: layout,
onChanged: (value) {
closeOverlay<T>(context, value);
},
),
),
),
);
},
).future;
}