Skip to main content

select_modal_flutter 1.0.0 copy "select_modal_flutter: ^1.0.0" to clipboard
select_modal_flutter: ^1.0.0 copied to clipboard

Flutter package to create a select field that opens its options in a modal window with search filter.

select_modal_flutter #

pub package license platforms

Flutter package to create a select field that opens its options in a modal window with a search filter. Supports single selection and multiple selection with chips, strong typing and full theming.

Single select Multi select
Single select modal Multi select modal
Bottom sheet Example app
Bottom sheet Example app

Features #

  • Single select and multi select in a modal dialog or bottom sheet.
  • Strongly typed values: SelectModalFlutter<T> / MultiSelectModalFlutter<T>.
  • Real-time search filter (also matches subtitle) with "no results" state.
  • Server-side search with loading, error and retry states (asyncLoader).
  • Debounced queries (searchDebounce) and onSearchChanged callback.
  • Custom rows and empty states with itemBuilder / emptyBuilder.
  • Multi select limits with maxSelection / minSelection, "select all", "clear" and an "N selected" counter.
  • ItemSelect.subtitle, icon and enabled (disabled options are greyed out and cannot be selected).
  • Pluggable styling through SelectModalStyle, globally via ThemeData.extensions or per widget via style.
  • Initial selection, validation with errorText and typed callbacks.
  • Read-only mode (readOnly) and custom tap handling (onTap) for the field.
  • Optional external controller / focusNode for the field.
  • Customizable/translatable texts (emptyText, retryText, selectAllText, clearText, selectedCountText, confirmText, closeText).
  • Accessibility: semantic labels, ListTile.selected state, scroll to the selected item, disabled field (enabled/readOnly) and 48 dp touch targets.
  • Modal header with title, close (cancel) button (showModalTitle, showCloseButton, closeText), configurable showDragHandle for bottom sheets, and RTL-safe layouts.
  • Custom modal animations: transitionAnimationController, sheetAnimationStyle and dialogAnimationStyle via showSelectModal.
  • Refreshed, professional UI: rounded modal, bold header, filled rounded search field, option rows with icon avatars and an animated selection indicator.
  • Multi select modal shows the selection as removable chips and a full-width confirm bar with the selected count (Confirm (3)).
  • Zero dependencies (only Flutter).

Why #

  • Strongly typed and safe: ItemSelect<T> with equality by value.
  • First-class theming via SelectModalStyle as a ThemeExtension (global or per widget).
  • Works as dialog or bottom sheet, with server-side search and custom builders.
  • Accessibility, RTL-safe layouts and polished UX out of the box.

Installation #

dependencies:
  select_modal_flutter: ^1.0.0

Single select #

SelectModalFlutter<int>(
  title: 'Name',
  searchText: 'Select name',
  listItemSelect: const [
    ItemSelect(value: 1, label: 'Pedro', subtitle: 'Developer'),
    ItemSelect(value: 2, label: 'Juan'),
    ItemSelect(value: 3, label: 'Maria', enabled: false),
  ],
  selectedItem: selectedItem, // initial value, optional
  icon: Icons.person,
  errorText: hasError ? 'Please select a name' : null,
  onItemSelect: (ItemSelect<int> item) {
    debugPrint('${item.value} - ${item.label}');
  },
),

Multi select #

MultiSelectModalFlutter<int>(
  title: 'City',
  searchText: 'Select city',
  listItemSelect: cities,
  listSelectedItem: const [ItemSelect(value: 1, label: 'Caracas')],
  showHorizontalSelected: true,
  closeChipOnTap: true, // remove a chip by tapping its close icon
  maxSelection: 3,
  minSelection: 1,
  showSelectAll: true,
  showSelectedCount: true,
  onItemSelect: (List<ItemSelect<int>> items) {
    debugPrint('$items');
  },
),

Server-side search (async) #

SelectModalFlutter<City>(
  title: 'City',
  asyncLoader: (query) => api.searchCities(query), // Future<List<ItemSelect<City>>>
  searchDebounce: const Duration(milliseconds: 350),
  presentation: SelectModalPresentation.bottomSheet,
  onItemSelect: (item) => debugPrint('${item.value}'),
),

The modal shows a spinner while loading, an error message with a Retry action on failure, and re-runs the loader (debounced) on every keystroke.

Custom rows #

SelectModalFlutter<int>(
  title: 'Name',
  listItemSelect: users,
  itemBuilder: (context, item, isSelected, onTap) => ListTile(
    leading: CircleAvatar(child: Text(item.label[0])),
    title: Text(item.label),
    trailing: isSelected ? const Icon(Icons.check) : null,
    onTap: onTap,
  ),
  onItemSelect: (_) {},
),

Theming #

SelectModalStyle is a ThemeExtension. Register it once for the whole app:

MaterialApp(
  theme: ThemeData(
    extensions: const [
      SelectModalStyle(
        accentColor: Colors.indigo,
        modalBackground: Colors.black,
        itemTextColor: Colors.white,
        modalShape: RoundedRectangleBorder(
          borderRadius: BorderRadius.all(Radius.circular(16)),
        ),
      ),
    ],
  ),
);

Or per widget (this always wins over the theme):

SelectModalFlutter<int>(
  // ...
  style: SelectModalStyle(
    boxDecoration: BoxDecoration(
      borderRadius: BorderRadius.circular(15),
      border: Border.all(color: Colors.grey),
    ),
    borderTextField: InputBorder.none,
    suffixIconColor: Colors.blue,
  ),
);

Available style fields: boxDecoration, borderTextField, suffixIconColor, inputTextColor, modalBackground, itemTextColor, selectedTileColor, accentColor, itemTextStyle, searchTextStyle, modalShape, searchFieldFillColor, searchFieldBorderColor, searchFieldBorderRadius, titleTextStyle, optionIconBackgroundColor.

Main parameters #

Widget Parameter Description
both title Hint text shown in the field
both searchText Label of the search field in the modal (default Search)
both listItemSelect Options shown in the modal (List<ItemSelect<T>>)
both asyncLoader Future<List<ItemSelect<T>>> Function(String query) for server-side search
both searchDebounce Debounce applied to asyncLoader (default 300 ms)
both onSearchChanged Called with the raw query on every change
both searchMatcher Custom local filter predicate
both itemBuilder, emptyBuilder Custom row / empty state
both presentation dialog (default) or bottomSheet
both emptyText, retryText Translatable state texts
both style SelectModalStyle for this widget
both icon Suffix icon of the field
both enabled When false the field is disabled and cannot open the modal (default true)
both errorText Shows the field in error state when not null
both readOnly When true the field prevents opening the modal (default false)
both onTap Optional override for field tap (falls back to opening the modal when enabled)
both useRootNavigator Present the modal with the root navigator (default true)
both showModalTitle Show modal header title (default true)
both showCloseButton Show close/cancel button in modal header (default true)
both closeText Tooltip/semantic label for close button (default Close)
both showDragHandle Show drag handle when using bottom sheet (default true)
SelectModalFlutter selectedItem Initial selection
SelectModalFlutter scrollToSelected Scroll the list to the selected item on open (default true)
SelectModalFlutter controller, focusNode External field controller/focus
SelectModalFlutter onItemSelect Called with the selected ItemSelect<T>
MultiSelectModalFlutter listSelectedItem Initial selection list
MultiSelectModalFlutter confirmText Tooltip/semantic label of the confirm action (default Confirm)
MultiSelectModalFlutter onItemSelect Called with the List<ItemSelect<T>>
MultiSelectModalFlutter showHorizontalSelected Lay chips out in a row
MultiSelectModalFlutter closeChipOnTap Allow removing chips outside the modal
MultiSelectModalFlutter maxSelection, minSelection Selection limits
MultiSelectModalFlutter showSelectAll Select all / clear actions in the modal
MultiSelectModalFlutter showSelectedCount Show "N selected" in the field
showSelectModal transitionAnimationController Optional animation controller for transitions
showSelectModal sheetAnimationStyle, dialogAnimationStyle Custom AnimationStyle for sheet/dialog

Example #

A complete example lives in the example/ folder.

Migrating from 0.x #

See the CHANGELOG for the full list. In short:

  • ItemSelect is now generic and requires value and label.
  • Style parameters (boxDecoration, borderTextField, color*, ...) are now inside SelectModalStyle.
  • bool? error is replaced by String? errorText.

API reference #

FAQ #

How do I disable items? Use ItemSelect(enabled: false).

How do I customize the rows? Use itemBuilder (receive isSelected and onTap).

Does it work with server-side search? Yes, use asyncLoader with searchDebounce.

Can I show it as a bottom sheet? Yes, set presentation: SelectModalPresentation.bottomSheet.

License #

MIT — see LICENSE.

1
likes
150
points
55
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Flutter package to create a select field that opens its options in a modal window with search filter.

Repository (GitHub)
View/report issues

Topics

#select #dropdown #modal #form

License

MIT (license)

Dependencies

flutter

More

Packages that depend on select_modal_flutter