Widget, mit dem der Benutzer über eine benutzerdefinierte Tastatur eingegebene Suchbegriffe in einer Liste mit einzelnen oder mehreren Auswahlmöglichkeiten suchen kann, die als Dropdown-Menü in einem Dialogfeld oder Menü angezeigt wird.
Aus öffentlichen Paketdaten erstellte Orientierung.
Ein Flutter-Widget, das Benutzern die Suche in einer Liste von Optionen mit einer anpassbaren Tastatur ermöglicht. Es unterstützt sowohl Einzel- als auch Mehrfachauswahl und präsentiert die Auswahlmöglichkeiten in einem Dropdown-Menü oder Dialogfeld. Ideal für Formulare und Dateneingabe, bei denen Benutzer schnell aus einer großen Liste wählen müssen. Das Widget ist hochgradig konfigurierbar und erlaubt die Anpassung des Eingabefelds, der Dropdown-Ansicht und des Suchverhaltens. Es verbessert die Benutzererfahrung, indem es die Navigationszeit in langen Listen verringert.
Anwendungsfälle
Formulareingaben mit großen Optionenlisten
Benutzerprofilauswahl mit Filterung
E-Commerce-Produktkategorienauswahl
Dynamische Datenfilterung in Administrationspanels
Mehrfachauswahl-Menüs mit Suche
Anpassbare Suchinterfaces
Hauptmerkmale
Suchbarer Dropdown mit Echtzeitfilterung
Unterstützung für einzelne und mehrfache Auswahl
Anpassbarer Tastatur und Eingabefeld
In Dialog oder Menü präsentierter Dropdown
Erweiterbare Stil- und Theme-Unterstützung
Effizienter Leistung mit großen Datensätzen
Geeignet für
Entwickler, die Formulare mit langen Optionslisten erstellen
Apps, die eine schnelle Datenabfrage erfordern
UI-intensiven Anwendungen, die eine intuitive Auswahl benötigen
Teams, die wiederverwendbare, konfigurierbare Dropdown-Komponenten benötigen
Projekte, die den Benutzererlebnis bei der Dateneingabe betonen
Kann zusätzliche Stilisierung für komplexe Themen erfordern
Die Leistung hängt von der Liste Größe und der Filterlogik ab
Keine integrierte Lokalisierungssupport
Nicht für sehr große Datensätze ohne Paginierung optimiert
Original-README
Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.
searchable_dropdown
Widget to let the user search through a keyword string typed on a customizable keyboard in a single or multiple choices list presented as a dropdown in a dialog box or a menu.
Platforms
This widget has been successfully tested on iOS, Android and Chrome.
Call either the single choice or the multiple choice constructor.
Single choice constructor
Search choices Widget with a single choice that opens a dialog or a menu to let the user do the selection conveniently with a search.
factorySearchableDropdown.single({
Key key,
@requiredList<DropdownMenuItem<T>> items,
@requiredFunction onChanged,
T value,
TextStyle style,
dynamic searchHint,
dynamic hint,
dynamic disabledHint,
dynamic icon = constIcon(Icons.arrow_drop_down),
dynamic underline,
dynamic doneButton,
dynamic label,
dynamic closeButton = "Close",
bool displayClearIcon = true,
Icon clearIcon = constIcon(Icons.clear),
Color iconEnabledColor,
Color iconDisabledColor,
double iconSize = 24.0,
bool isExpanded = false,
bool isCaseSensitiveSearch = false,
Function searchFn,
Function onClear,
Function selectedValueWidgetFn,
TextInputType keyboardType = TextInputType.text,
Function validator,
bool assertUniqueValue = true,
Function displayItem,
bool dialogBox = true,
BoxConstraints menuConstraints,
bool readOnly: false,
Color menuBackgroundColor,
}
)
items with child: Widget displayed ; value: any object with .toString() used to match search keyword.
onChanged Function with parameter: value not returning executed after the selection is done.
value value to be preselected.
style used for the hint if it is given is String.
searchHint String|Widget|Function with no parameter returning String|Widget displayed at the top of the search dialog box.
hint String|Widget|Function with no parameter returning String|Widget displayed before any value is selected or after the selection is cleared.
disabledHint String|Widget|Function with no parameter returning String|Widget displayed instead of hint when the widget is displayed.
icon String|Widget|Function with parameter: value returning String|Widget displayed next to the selected item or the hint if none.
underline String|Widget|Function with parameter: value returning String|Widget displayed below the selected item or the hint if none.
doneButton String|Widget|Function with parameter: value returning String|Widget displayed at the top of the search dialog box.
label String|Widget|Function with parameter: value returning String|Widget displayed above the selected item or the hint if none.
closeButton String|Widget|Function with parameter: value returning String|Widget displayed at the bottom of the search dialog box.
displayClearIcon whether or not to display an icon to clear the selected value.
clearIcon Icon to be used for clearing the selected value.
iconEnabledColor Color to be used for enabled icons.
iconDisabledColor Color to be used for disabled icons.
iconSize for the icons next to the selected value (icon and clearIcon).
isExpanded can be necessary to avoid pixel overflows (zebra symptom).
isCaseSensitiveSearch only used when searchFn is not specified.
searchFn Function with parameters: keyword, items returning List as the list of indexes for the items to be displayed.
onClear Function with no parameter not returning executed when the clear icon is tapped.
selectedValueWidgetFn Function with parameter: item returning Widget to be used to display the selected value.
keyboardType used for the search.
validator Function with parameter: value returning String displayed below selected value when not valid and null when valid.
assertUniqueValue whether to run a consistency check of the list of items.
displayItem Function with parameters: item, selected returning Widget to be displayed in the search list.
dialogBox whether the search should be displayed as a dialog box or as a menu below the selected value if any.
menuConstraints BoxConstraints used to define the zone where to display the search menu. Example: BoxConstraints.tight(Size.fromHeight(250)) . Not to be used for dialogBox = true.
readOnly bool whether to let the user choose the value to select or just present the selected value if any.
menuBackgroundColor Color background color of the menu whether in dialog box or menu mode.
Multiple choice constructor
Search choices Widget with a multiple choice that opens a dialog or a menu to let the user do the selection conveniently with a search.
SearchableDropdown<T>.multiple(
{
Key key,
@requiredList<DropdownMenuItem<T>> items,
@requiredFunction onChanged,
List<int> selectedItems: const [],
TextStyle style,
dynamic searchHint,
dynamic hint,
dynamic disabledHint,
dynamic icon: constIcon(Icons.arrow_drop_down),
dynamic underline,
dynamic doneButton: "Done",
dynamic label,
dynamic closeButton: "Close",
bool displayClearIcon: true,
Icon clearIcon: constIcon(Icons.clear),
Color iconEnabledColor,
Color iconDisabledColor,
double iconSize: 24.0,
bool isExpanded: false,
bool isCaseSensitiveSearch: false,
Function searchFn,
Function onClear,
Function selectedValueWidgetFn,
TextInputType keyboardType: TextInputType.text,
Function validator,
Function displayItem,
bool dialogBox: true,
BoxConstraints menuConstraints,
bool readOnly: false,
Color menuBackgroundColor,
}
)
items with child: Widget displayed ; value: any object with .toString() used to match search keyword.
onChanged Function with parameter: selectedItems not returning executed after the selection is done.
selectedItems indexes of items to be preselected.
style used for the hint if it is given is String.
searchHint String|Widget|Function with no parameter returning String|Widget displayed at the top of the search dialog box.
hint String|Widget|Function with no parameter returning String|Widget displayed before any value is selected or after the selection is cleared.
disabledHint String|Widget|Function with no parameter returning String|Widget displayed instead of hint when the widget is displayed.
icon String|Widget|Function with parameter: selectedItems returning String|Widget displayed next to the selected items or the hint if none.
underline String|Widget|Function with parameter: selectedItems returning String|Widget displayed below the selected items or the hint if none.
doneButton String|Widget|Function with parameter: selectedItems returning String|Widget displayed at the top of the search dialog box. Cannot be null in multiple selection mode.
label String|Widget|Function with parameter: selectedItems returning String|Widget displayed above the selected items or the hint if none.
closeButton String|Widget|Function with parameter: selectedItems returning String|Widget displayed at the bottom of the search dialog box.
displayClearIcon whether or not to display an icon to clear the selected values.
clearIcon Icon to be used for clearing the selected values.
iconEnabledColor Color to be used for enabled icons.
iconDisabledColor Color to be used for disabled icons.
iconSize for the icons next to the selected values (icon and clearIcon).
isExpanded can be necessary to avoid pixel overflows (zebra symptom).
isCaseSensitiveSearch only used when searchFn is not specified.
searchFn Function with parameters: keyword, items returning List as the list of indexes for the items to be displayed.
onClear Function with no parameter not returning executed when the clear icon is tapped.
selectedValueWidgetFn Function with parameter: item returning Widget to be used to display the selected values.
keyboardType used for the search.
validator Function with parameter: selectedItems returning String displayed below selected values when not valid and null when valid.
displayItem Function with parameters: item, selected returning Widget to be displayed in the search list.
dialogBox whether the search should be displayed as a dialog box or as a menu below the selected values if any.
menuConstraints BoxConstraints used to define the zone where to display the search menu. Example: BoxConstraints.tight(Size.fromHeight(250)) . Not to be used for dialogBox = true.
readOnly bool whether to let the user choose the value to select or just present the selected value if any.
menuBackgroundColor Color background color of the menu whether in dialog box or menu mode.
SearchableDropdown.single(
items: [
DropdownMenuItem(
child: Text(
"way too long text for a smartphone at least one that goes in a normal sized pair of trousers but maybe not for a gigantic screen like there is one at my cousin's home in a very remote country where I
wouldn't want to go right now"),
value:
"way too long text for a smartphone at least one that goes in a normal sized pair of trousers but maybe not for a gigantic screen like there is one at my cousin's home in a very remote country where I
wouldn't want to go right now",
)
],
value: "",
hint: "Select one",
searchHint: "Select one",
onChanged: (value) {
setState(() {
selectedValue = value;
});
},
dialogBox: true,
isExpanded: true,
),