showModal<T> method
Future<T?>
showModal<T>(
- BuildContext context, {
- ThemeData? themeData,
- bool isScrollControlled = false,
- Color? backgroundColor,
- ShapeBorder? shape,
- Clip? clipBehavior,
- PickerWidgetBuilder? builder,
Displays the picker in a modal bottom sheet.
This is the most common way to show a picker. The modal appears from the bottom of the screen and can be dismissed by tapping outside or using the cancel button.
Parameters:
context
- Build context for showing the modalthemeData
- Optional theme for stylingisScrollControlled
- Whether the modal can scroll beyond 50% heightuseRootNavigator
- Whether to use the root navigatorbackgroundColor
- Background color of the modalshape
- Custom shape for the modalclipBehavior
- How to clip the modal contentbuilder
- Optional custom builder to wrap the picker
Returns a Future that completes when the modal is dismissed.
The result contains the selected values or null
if cancelled.
Example:
final result = await picker.showModal<List<int>>(context);
if (result != null) {
print('Selected indices: $result');
}
Implementation
Future<T?> showModal<T>(BuildContext context,
{material.ThemeData? themeData,
bool isScrollControlled = false,
bool useRootNavigator = false,
Color? backgroundColor,
ShapeBorder? shape,
Clip? clipBehavior,
PickerWidgetBuilder? builder}) async {
return await material.showModalBottomSheet<T>(
context: context, //state.context,
isScrollControlled: isScrollControlled,
useRootNavigator: useRootNavigator,
backgroundColor: backgroundColor,
shape: shape,
clipBehavior: clipBehavior,
builder: (BuildContext context) {
final picker = makePicker(themeData, true);
return builder == null ? picker : builder(context, picker);
});
}