showMaterialSelectionPicker function
void
showMaterialSelectionPicker({
- required BuildContext context,
- String? title,
- required List<
String> items, - List<
String> ? values, - required String selectedValue,
- List<
Icon> ? icons, - Color? headerColor,
- Color? headerTextColor,
- Color? backgroundColor,
- Color? buttonTextColor,
- String? confirmText,
- String? cancelText,
- double? maxLongSide,
- double? maxShortSide,
- ValueChanged<
String> ? onChanged, - VoidCallback? onConfirmed,
- VoidCallback? onCancelled,
Allows selection of a single value via an icon label list
Implementation
void showMaterialSelectionPicker({
required BuildContext context,
String? title,
required List<String> items,
List<String>? values,
required String selectedValue,
List<Icon>? icons,
Color? headerColor,
Color? headerTextColor,
Color? backgroundColor,
Color? buttonTextColor,
String? confirmText,
String? cancelText,
double? maxLongSide,
double? maxShortSide,
ValueChanged<String>? onChanged,
VoidCallback? onConfirmed,
VoidCallback? onCancelled,
}) {
assert(icons == null || items.length == icons.length);
assert(values == null || items.length == values.length);
if (values == null) values = items;
showDialog<String>(
context: context,
builder: (BuildContext context) {
return SelectionPickerDialog(
items: items,
values: values!,
title: title,
initialValue: selectedValue,
icons: icons,
headerColor: headerColor,
headerTextColor: headerTextColor,
backgroundColor: backgroundColor,
buttonTextColor: buttonTextColor,
confirmText: confirmText,
cancelText: cancelText,
maxLongSide: maxLongSide,
maxShortSide: maxLongSide,
);
},
).then((selection) {
if (onChanged != null && selection != null) onChanged(selection);
if (onCancelled != null && selection == null) onCancelled();
if (onConfirmed != null && selection != null) onConfirmed();
});
}