showModal<T> method

Future<T?> showModal<T>(
  1. BuildContext context, {
  2. ThemeData? themeData,
  3. bool isScrollControlled = false,
  4. bool useRootNavigator = false,
  5. Color? backgroundColor,
  6. ShapeBorder? shape,
  7. Clip? clipBehavior,
  8. 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 modal
  • themeData - Optional theme for styling
  • isScrollControlled - Whether the modal can scroll beyond 50% height
  • useRootNavigator - Whether to use the root navigator
  • backgroundColor - Background color of the modal
  • shape - Custom shape for the modal
  • clipBehavior - How to clip the modal content
  • builder - 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);
      });
}