showOptionsSearchSheet function

Future<void> showOptionsSearchSheet({
  1. required BuildContext context,
  2. required List<String> options,
  3. required ValueChanged<String> onSelected,
  4. FormlessTheme? theme,
  5. String title = 'Choose an option',
})

Modal sheet with a search field and scrollable list of options.

Implementation

Future<void> showOptionsSearchSheet({
  required BuildContext context,
  required List<String> options,
  required ValueChanged<String> onSelected,
  FormlessTheme? theme,
  String title = 'Choose an option',
}) {
  return showModalBottomSheet<void>(
    context: context,
    isScrollControlled: true,
    useSafeArea: true,
    showDragHandle: true,
    backgroundColor: Theme.of(context).colorScheme.surface,
    shape: const RoundedRectangleBorder(
      borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
    ),
    builder: (ctx) {
      return _OptionsSearchSheetBody(
        options: options,
        theme: theme,
        title: title,
        onSelected: (value) {
          Navigator.of(ctx).pop();
          onSelected(value);
        },
      );
    },
  );
}