showMapListCascadePicker<V> function

Future<Map?> showMapListCascadePicker<V>({
  1. required BuildContext context,
  2. required List<Map> source,
  3. String? valueKey,
  4. String? labelKey,
  5. String? idKey,
  6. String? pidKey,
  7. String? rootId,
  8. String? title,
  9. Map? initialData,
  10. V? initialValue,
  11. DataWidgetBuilder<Map>? subtitleBuilder,
  12. ValueMapper<Map, bool>? disabledWhen,
  13. PickerItemBuilder<Map>? itemBuilder,
  14. bool? isScrollControlled,
  15. bool? showSearchField,
  16. Widget? placeholder,
  17. ListTileThemeData? listTileTheme,
  18. 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,
  );
}