showMapListCascadePicker<V> function
Future<Map?>
showMapListCascadePicker<V>({
- required BuildContext context,
- required List<
Map> source, - String? valueKey,
- String? labelKey,
- String? idKey,
- String? pidKey,
- String? rootId,
- String? title,
- Map? initialData,
- V? initialValue,
- DataWidgetBuilder<
Map> ? subtitleBuilder, - ValueMapper<
Map, bool> ? disabledWhen, - PickerItemBuilder<
Map> ? itemBuilder, - bool? isScrollControlled,
- bool? showSearchField,
- Widget? placeholder,
- ListTileThemeData? listTileTheme,
- bool? parentCheckable,
弹出数据为 Map 列表类型级联选择器
Implementation
Future<Map?> showMapListCascadePicker<V>({
required BuildContext context,
required List<Map> source,
String? valueKey,
String? labelKey,
String? idKey,
String? pidKey,
String? rootId,
String? title,
Map? initialData,
V? initialValue,
DataWidgetBuilder<Map>? subtitleBuilder,
ValueMapper<Map, bool>? disabledWhen,
PickerItemBuilder<Map>? itemBuilder,
bool? isScrollControlled,
bool? showSearchField,
Widget? placeholder,
ListTileThemeData? listTileTheme,
bool? parentCheckable,
}) async {
Map? result = source.getInitialData<V>(
initialValue: initialValue,
initialData: initialData,
valueMapper: (data) => data[valueKey ?? idKey],
);
return showDefaultBottomSheet<Map>(
context,
title: title ?? '请选择',
contentBuilder: (context) {
return TxCascadePicker<Map, V>.fromMapList(
source: source,
labelKey: labelKey,
valueKey: valueKey,
idKey: idKey,
pidKey: pidKey,
rootId: rootId,
initialData: initialData,
itemBuilder: itemBuilder,
subtitleBuilder: subtitleBuilder,
listTileTheme: listTileTheme,
placeholder: placeholder,
parentCheckable: parentCheckable,
onChanged: (val) {
if (parentCheckable == true) {
result = val;
} else {
result = val;
}
},
disabledWhen: disabledWhen,
showSearchField: showSearchField,
);
},
onConfirm: () => Navigator.pop(context, result),
actionsPosition: ActionsPosition.header,
isScrollControlled: true,
contentPadding: EdgeInsets.zero,
);
}