패키지, 저장소 및 앱 카테고리 검색

multi_dropdown 표지
패키지 상세v4.0.0

multi_dropdown

다양한 다중 선택을 위한 고도로 맞춤화 가능한 스트리밍된 Flutter 위젯.

AndroidiOSmacOSWindowsLinux
30일 다운로드
4.8만
좋아요
386
Pub 점수
160

패키지 설치

flutter pub add multi_dropdown

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

다양한 사용자 정의 옵션을 갖춘 유연한 다중 선택을 위한 최적화된 Flutter 위젯입니다. 부드러운 애니메이션과 유연한 스타일링을 통해 드롭다운 목록에서 여러 항목을 선택할 수 있도록 합니다. Android, iOS, macOS, Windows, Linux 등 다양한 플랫폼을 지원하여 크로스플랫폼 애플리케이션에 이상적입니다. 직관적인 API와 반응형 디자인으로 폼, 필터 및 설정 인터페이스에서 사용자 경험을 향상시킵니다. 성능과 사용성에 중점을 두어 기존 Flutter 프로젝트에 원활하게 통합됩니다.

사용 사례

  • 다중 선택 옵션을 가진 폼 입력
  • 여러 기준으로 데이터 필터링하기
  • 사용자 선호 설정
  • 다시보드에서 태그 선택
  • 동적 폼 필드

주요 기능

  • 사용자 정의 가능한 드롭다운 표시
  • 플랫폼별 동작 지원
  • 부드러운 전환 애니메이션
  • 풍부한 테마 옵션
  • 유연한 항목 선택 처리
  • 접근성 지원

적합한 대상

  • 복잡한 폼을 개발하는 개발자
  • 다중 선택 UI가 필요한 앱
  • 크로스플랫폼 플러터 애플리케이션
  • 재사용 가능한 컴포넌트가 필요한 디자인 시스템
  • UX 일관성을 우선시하는 팀

고려 사항

  • 대규모 데이터셋에 대한 주의 깊은 상태 관리가 필요합니다
  • 필터링/검색을 위한 추가 로직이 필요할 수 있습니다
  • 매우 긴 목록과 성능 영향
  • 제한된 내장 검색 기능
  • 사용자 정의 스타일은 Flutter 위젯에 대한 더 깊은 이해를 필요로 할 수 있습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

MultiSelect Dropdown

Pub Version License GitHub issues Very Good Analysis Flutter Dart

A powerful and highly customizable multi-select dropdown widget for Flutter. Supports single & multi-select, search, form validation, programmatic control, and extensive visual customization.

Preview

Features

  • ✅ Multi-select & single-select modes
  • ✅ Searchable dropdown with customizable search field
  • ✅ Form validation support with autovalidateMode
  • ✅ Programmatic control via MultiSelectController
  • ✅ Async data loading with MultiDropdown.future()
  • ✅ Extensive decoration classes (chips, field, dropdown, items, search)
  • ✅ Pre-selected & disabled items
  • ✅ Max selection limit with maxSelections
  • ✅ Chip overflow control with maxDisplayCount
  • ✅ Custom item builders & selected item builders
  • ✅ Header & footer widgets in the dropdown
  • ✅ Expand direction control (auto, up, down)
  • ✅ Close on back button support
  • ✅ Full InputDecoration override for form consistency
  • ✅ Grouped items with customizable section headers
  • ✅ Select All / Deselect All toggle with customizable labels
  • ✅ Custom search filter for fuzzy matching and multi-field search
  • ✅ Bottom sheet mode for mobile-friendly item selection

Installation

Add to your pubspec.yaml:

dependencies:
  multi_dropdown: ^3.2.1

Quick Start

Basic Multi-Select
MultiDropdown<String>(
  items: [
    DropdownItem(label: 'Australia', value: 'AU'),
    DropdownItem(label: 'Canada', value: 'CA'),
    DropdownItem(label: 'India', value: 'IN'),
    DropdownItem(label: 'United States', value: 'US'),
  ],
  onSelectionChange: (selectedItems) {
    debugPrint('Selected: $selectedItems');
  },
);
Single Select
MultiDropdown<String>(
  items: items,
  singleSelect: true,
  fieldDecoration: FieldDecoration(
    hintText: 'Choose a role',
    suffixIcon: const Icon(Icons.keyboard_arrow_down_rounded),
  ),
  onSelectionChange: (values) {
    debugPrint('Selected: ${values.first}');
  },
);
Searchable Dropdown
MultiDropdown<String>(
  items: items,
  searchEnabled: true,
  searchDecoration: SearchFieldDecoration(
    hintText: 'Type to search...',
  ),
);
With Form Validation
MultiDropdown<String>(
  items: items,
  maxSelections: 4,
  autovalidateMode: AutovalidateMode.onUserInteraction,
  validator: (selectedItems) {
    if (selectedItems == null || selectedItems.isEmpty) {
      return 'Please select at least one item';
    }
    return null;
  },
);
Async Data Loading
MultiDropdown<int>.future(
  future: () async {
    final response = await http.get(Uri.parse('https://api.example.com/users'));
    final data = jsonDecode(response.body) as List;
    return data.map((e) => DropdownItem(
      label: e['name'] as String,
      value: e['id'] as int,
    )).toList();
  },
);

Controller

Use MultiSelectController to programmatically control the dropdown:

final controller = MultiSelectController<String>();

controller.setItems(items);       // Set/replace items
controller.addItem(item);         // Add a single item
controller.addItems(items);       // Add multiple items

controller.selectAll();           // Select all items
controller.clearAll();            // Deselect all items
controller.selectAtIndex(0);      // Select item at index
controller.selectWhere((i) => i.value == 'dart');   // Select by predicate
controller.unselectWhere((i) => i.value == 'dart'); // Deselect by predicate
controller.toggleWhere((i) => i.value == 'dart');   // Toggle by predicate
controller.disableWhere((i) => i.value == 'admin'); // Disable by predicate

controller.openDropdown();        // Open the dropdown
controller.closeDropdown();       // Close the dropdown
controller.clearSearch();         // Clear search query

controller.items;                 // All items
controller.selectedItems;         // Selected items
controller.disabledItems;         // Disabled items
controller.isOpen;                // Dropdown open state

Examples

The example app contains 8 dedicated examples, each in its own file:

Example File Description
🌍 Country Picker basic_example.dart Multi-select with flag emojis and chip wrapping
🎯 Task Priority single_select_example.dart Single-select with color-coded result card
👥 Team Members searchable_example.dart Search with custom itemBuilder (avatars)
🏷️ Issue Labels custom_style_example.dart Color-coded chips, maxDisplayCount, disabled items
🍳 Recipe Ingredients controller_example.dart All MultiSelectController methods
💼 Job Application form_validation_example.dart Form validation, maxSelections, submit flow
🌐 Async Loading future_example.dart MultiDropdown.future() with loading spinner
♿ Accessibility accessibility_example.dart Font scaling slider, high contrast, Semantics

Run the example:

cd example
flutter run

API Reference

MultiDropdown
Parameter Type Description Default
items List<DropdownItem<T>> The list of dropdown items Required
singleSelect bool Single-select mode false
chipDecoration ChipDecoration Chip styling configuration ChipDecoration()
fieldDecoration FieldDecoration Field styling configuration FieldDecoration()
dropdownDecoration DropdownDecoration Dropdown panel configuration DropdownDecoration()
searchDecoration SearchFieldDecoration Search field configuration SearchFieldDecoration()
dropdownItemDecoration DropdownItemDecoration Item styling configuration DropdownItemDecoration()
itemBuilder DropdownItemBuilder<T>? Custom item widget builder null
selectedItemBuilder SelectedItemBuilder<T>? Custom selected item builder null
itemSeparator Widget? Separator between items null
validator String? Function(...) Form validation callback null
autovalidateMode AutovalidateMode When to auto-validate .disabled
controller MultiSelectController<T>? Programmatic controller null
maxSelections int Max selectable items (0 = unlimited) 0
enabled bool Whether the dropdown is enabled true
searchEnabled bool Whether search is enabled false
focusNode FocusNode? Custom focus node null
future FutureRequest<T>? Async item loading null
onSelectionChange OnSelectionChanged<T>? Selection change callback null
onSearchChange ValueChanged<String>? Search text change callback null
closeOnBackButton bool Close on back button press false
DropdownItem
Parameter Type Description Default
label String Display label Required
value T Associated value Required
disabled bool Whether item is disabled false
selected bool Whether item is pre-selected false
ChipDecoration
Parameter Type Description Default
deleteIcon Widget? Chip delete icon Icon(Icons.close)
backgroundColor Color? Chip background color Color(0xFFE0E0E0)
labelStyle TextStyle? Chip label text style null
padding EdgeInsets Chip padding EdgeInsets.symmetric(horizontal: 12, vertical: 4)
border BoxBorder Chip border Border()
spacing double Spacing between chips 8.0
runSpacing double Spacing between chip rows 12.0
borderRadius BorderRadiusGeometry Chip border radius BorderRadius.circular(12)
wrap bool Wrap chips or scroll horizontally true
maxDisplayCount int? Max visible chips (shows "+N more") null
FieldDecoration
Parameter Type Description Default
labelText String? Label text above the field null
hintText String? Hint text in the field 'Select'
border InputBorder? Field border null
focusedBorder InputBorder? Border when focused null
disabledBorder InputBorder? Border when disabled null
errorBorder InputBorder? Border on validation error null
suffixIcon Widget? Trailing icon Icon(Icons.arrow_drop_down)
prefixIcon Widget? Leading icon null
labelStyle TextStyle? Label text style null
hintStyle TextStyle? Hint text style null
borderRadius double Border radius 12.0
animateSuffixIcon bool Animate suffix icon rotation true
padding EdgeInsets? Content padding EdgeInsets.symmetric(horizontal: 12, vertical: 8)
backgroundColor Color? Background fill color null
showClearIcon bool Show clear/deselect icon true
selectedItemTextStyle TextStyle? Selected item text style (single-select) null
inputDecoration InputDecoration? Full InputDecoration override null
DropdownDecoration
Parameter Type Description Default
backgroundColor Color Dropdown background color Colors.white
elevation double Dropdown elevation 1.0
maxHeight double Maximum dropdown height 400.0
borderRadius BorderRadius Dropdown border radius BorderRadius.circular(12)
marginTop double Gap between field and dropdown 0.0
header Widget? Header widget inside dropdown null
footer Widget? Footer widget inside dropdown null
noItemsFoundText String Text when no items match search 'No items found'
expandDirection ExpandDirection Dropdown expand direction ExpandDirection.auto
SearchFieldDecoration
Parameter Type Description Default
hintText String Search hint text 'Search'
border InputBorder? Search field border OutlineInputBorder(...)
focusedBorder InputBorder? Border when focused OutlineInputBorder(...)
searchIcon Icon Search icon Icon(Icons.search)
textStyle TextStyle? Search input text style null
hintStyle TextStyle? Search hint text style null
fillColor Color? Search field fill color null
filled bool? Whether search field is filled null
cursorColor Color? Cursor color null
showClearIcon bool Show clear button in search true
autofocus bool Auto-focus search on open false
DropdownItemDecoration
Parameter Type Description Default
backgroundColor Color? Item background color null
disabledBackgroundColor Color? Disabled item background color null
selectedBackgroundColor Color? Selected item background color null
selectedTextColor Color? Selected item text color null
textColor Color? Item text color null
disabledTextColor Color? Disabled item text color null
selectedIcon Widget? Selected item trailing icon Icon(Icons.check)
disabledIcon Widget? Disabled item trailing icon null
textStyle TextStyle? Item label text style null
selectedTextStyle TextStyle? Selected item label text style null

Migration from v2.x

See the CHANGELOG for details on breaking changes in v3.0.0.

Key changes:

  • MultiSelectDropDown → MultiDropdown
  • ValueItem → DropdownItem
  • .network() → .future()
  • onOptionsSelected → onSelectionChange

License

MIT License

카테고리

의존성

의존성 목록 1 개

소스 저장소

이 패키지를 사용하는 프로젝트