multiSelectFormEntry method
Widget
multiSelectFormEntry({
- String title = 'Multi Select',
- String subTitle = 'Choose multiple options from the list',
- required List<
String> options, - required void onChanged(),
- String? validator()?,
- List<
String> ? defaultValues, - bool searchable = true,
- String confirmText = 'Select',
- String cancelText = 'Cancel',
- bool isRequired = false,
Implementation
Widget multiSelectFormEntry({
String title = 'Multi Select',
String subTitle = 'Choose multiple options from the list',
required List<String> options,
required void Function(List<String>) onChanged,
String? Function(List<String>?)? validator,
List<String>? defaultValues,
bool searchable = true,
String confirmText = 'Select',
String cancelText = 'Cancel',
bool isRequired = false,
}) {
if (options.isEmpty) {
throw ArgumentError('Options list cannot be empty');
}
return formEntry(
title: title,
subTitle: subTitle,
inputWidget: MultiSelectDialogField<String>(
validator:
validator ??
(isRequired
? (values) => values == null || values.isEmpty
? '$title is required'
: null
: null),
items: options
.map((item) => MultiSelectItem<String>(item, item))
.toList(),
selectedColor: Colors.blue[100],
separateSelectedItems: true,
selectedItemsTextStyle: const TextStyle(
color: Colors.black87,
fontSize: 16,
fontWeight: FontWeight.w500,
),
itemsTextStyle: const TextStyle(
color: Colors.black87,
fontSize: 16,
fontWeight: FontWeight.w400,
),
searchTextStyle: const TextStyle(
color: Colors.black87,
fontSize: 16,
fontWeight: FontWeight.w400,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.grey[300]!, width: 1.0),
color: Colors.grey[50],
),
searchable: searchable,
confirmText: Text(
confirmText,
style: const TextStyle(
color: Colors.blue,
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
cancelText: Text(
cancelText,
style: const TextStyle(
color: Colors.grey,
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
dialogWidth: 400,
chipDisplay: MultiSelectChipDisplay(
items: options
.map((item) => MultiSelectItem<String>(item, item))
.toList(),
chipColor: Colors.blue[50],
textStyle: const TextStyle(
color: Colors.black87,
fontSize: 14,
fontWeight: FontWeight.w500,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
side: BorderSide(color: Colors.blue[200]!, width: 1.0),
),
),
listType: MultiSelectListType.CHIP,
buttonIcon: const Icon(Icons.list),
buttonText: Text(
'Select $title',
style: const TextStyle(
color: Colors.black87,
fontSize: 16,
fontWeight: FontWeight.w400,
),
),
onConfirm: (values) {
onChanged(values);
widget.formKey.currentState?.save();
widget.onModified?.call();
},
initialValue: defaultValues ?? [],
),
);
}