TxPickerFormField<T, V> constructor
TxPickerFormField<T, V> ({
- required List<
T> source, - required ValueMapper<
T, String?> labelMapper, - bool? clearable,
- Key? key,
- FormFieldSetter<
T> ? onSaved, - FormFieldValidator<
T> ? validator, - bool? enabled,
- AutovalidateMode? autovalidateMode = AutovalidateMode.onUserInteraction,
- String? restorationId,
- InputDecoration? decoration,
- ValueChanged<
T?> ? onChanged, - bool? required,
- ValueMapper<
T, V?> ? valueMapper, - DataWidgetBuilder<
T> ? subtitleBuilder, - PickerItemBuilder<
T> ? itemBuilder, - ValueMapper<
T, bool> ? disabledWhen, - T? initialData,
- V? initialValue,
- bool? showSearchField,
- Widget? placeholder,
- ListTileThemeData? listTileTheme,
- FocusNode? focusNode,
- String? hintText,
- TextAlign? textAlign,
- bool? bordered,
- TextEditingController? controller,
- UndoHistoryController? undoController,
- TextInputType? keyboardType,
- TextInputAction? textInputAction,
- TextCapitalization? textCapitalization,
- TextStyle? style,
- StrutStyle? strutStyle,
- TextAlignVertical? textAlignVertical,
- TextDirection? textDirection,
- bool? readOnly,
- bool? inputEnabled,
- bool? showCursor,
- bool? autofocus,
- MaterialStatesController? statesController,
- String? obscuringCharacter,
- bool? obscureText,
- bool? autocorrect,
- SmartDashesType? smartDashesType,
- SmartQuotesType? smartQuotesType,
- bool? enableSuggestions,
- int? maxLines,
- int? minLines,
- bool? expands,
- int? maxLength,
- MaxLengthEnforcement? maxLengthEnforcement,
- VoidCallback? onEditingComplete,
- ValueChanged<
String> ? onFieldSubmitted, - AppPrivateCommandCallback? onAppPrivateCommand,
- List<
TextInputFormatter> ? inputFormatters, - double? cursorWidth,
- double? cursorHeight,
- Radius? cursorRadius,
- bool? cursorOpacityAnimates,
- Color? cursorColor,
- Color? cursorErrorColor,
- BoxHeightStyle? selectionHeightStyle,
- BoxWidthStyle? selectionWidthStyle,
- Brightness? keyboardAppearance,
- EdgeInsets? scrollPadding,
- DragStartBehavior? dragStartBehavior,
- bool? enableInteractiveSelection,
- TextSelectionControls? selectionControls,
- GestureTapCallback? onTap,
- bool? onTapAlwaysCalled,
- TapRegionCallback? onTapOutside,
- MouseCursor? mouseCursor,
- InputCounterWidgetBuilder? buildCounter,
- ScrollController? scrollController,
- ScrollPhysics? scrollPhysics,
- Iterable<
String> ? autofillHints, - ContentInsertionConfiguration? contentInsertionConfiguration,
- Clip? clipBehavior,
- bool? scribbleEnabled,
- bool? enableIMEPersonalizedLearning,
- EditableTextContextMenuBuilder? contextMenuBuilder,
- bool? canRequestFocus,
- SpellCheckConfiguration? spellCheckConfiguration,
- TextMagnifierConfiguration? magnifierConfiguration,
- Widget? label,
- String? labelText,
- TextAlign? labelTextAlign,
- TextOverflow? labelOverflow,
- EdgeInsetsGeometry? padding,
- FieldActionsBuilder<
T> ? actionsBuilder, - TextStyle? labelStyle,
- double? horizontalGap,
- Color? tileColor,
- Axis? layoutDirection,
- TxFormFieldBuilder<
T> ? trailingBuilder, - Widget? leading,
- VisualDensity? visualDensity,
- ShapeBorder? shape,
- Color? iconColor,
- Color? textColor,
- TextStyle? leadingAndTrailingTextStyle,
- double? minLeadingWidth,
- double? minLabelWidth,
- double? minVerticalPadding,
- bool? dense,
- bool? colon,
- Color? focusColor,
Implementation
TxPickerFormField({
required List<T> source,
required ValueMapper<T, String?> labelMapper,
super.clearable,
super.key,
super.onSaved,
FormFieldValidator<T>? validator,
super.enabled,
super.autovalidateMode,
super.restorationId,
super.decoration,
super.onChanged,
super.required,
ValueMapper<T, V?>? valueMapper,
DataWidgetBuilder<T>? subtitleBuilder,
PickerItemBuilder<T>? itemBuilder,
ValueMapper<T, bool>? disabledWhen,
T? initialData,
V? initialValue,
bool? showSearchField,
Widget? placeholder,
ListTileThemeData? listTileTheme,
super.focusNode,
String? hintText,
super.textAlign,
super.bordered,
super.controller,
super.undoController,
super.keyboardType,
super.textInputAction,
super.textCapitalization,
super.style,
super.strutStyle,
super.textAlignVertical,
super.textDirection,
bool? readOnly,
bool? inputEnabled,
super.showCursor,
super.autofocus,
super.statesController,
super.obscuringCharacter,
super.obscureText,
super.autocorrect,
super.smartDashesType,
super.smartQuotesType,
super.enableSuggestions,
super.maxLines,
super.minLines,
super.expands,
super.maxLength,
super.maxLengthEnforcement,
super.onEditingComplete,
super.onFieldSubmitted,
super.onAppPrivateCommand,
super.inputFormatters,
super.cursorWidth,
super.cursorHeight,
super.cursorRadius,
super.cursorOpacityAnimates,
super.cursorColor,
super.cursorErrorColor,
super.selectionHeightStyle,
super.selectionWidthStyle,
super.keyboardAppearance,
super.scrollPadding,
super.dragStartBehavior,
super.enableInteractiveSelection,
super.selectionControls,
super.onTap,
super.onTapAlwaysCalled,
super.onTapOutside,
super.mouseCursor,
super.buildCounter,
super.scrollController,
super.scrollPhysics,
super.autofillHints,
super.contentInsertionConfiguration,
super.clipBehavior,
super.scribbleEnabled,
super.enableIMEPersonalizedLearning,
super.contextMenuBuilder,
super.canRequestFocus,
super.spellCheckConfiguration,
super.magnifierConfiguration,
super.label,
super.labelText,
super.labelTextAlign,
super.labelOverflow,
super.padding,
super.actionsBuilder,
super.labelStyle,
super.horizontalGap,
super.tileColor,
super.layoutDirection,
super.trailingBuilder,
super.leading,
super.visualDensity,
super.shape,
super.iconColor,
super.textColor,
super.leadingAndTrailingTextStyle,
super.minLeadingWidth,
super.minLabelWidth,
super.minVerticalPadding,
super.dense,
super.colon,
super.focusColor,
}) : _readOnly = readOnly ?? false,
inputEnabled = inputEnabled ?? false,
super(
initialValue:
initData<T, V>(source, initialData, initialValue, valueMapper),
onFieldTap: readOnly == true
? null
: (field) => _onTap(
field,
(context, value) => showPickerBottomSheet<T, V>(
context,
source: readOnly == true
? source
: <T>{
...source,
if (field.value != null) field.value!
}.toList(),
labelMapper: labelMapper,
valueMapper: valueMapper,
initialData: value,
disabledWhen: disabledWhen,
title: labelText,
subtitleBuilder: subtitleBuilder,
itemBuilder: itemBuilder,
showSearchField: showSearchField,
placeholder: placeholder,
listTileTheme: listTileTheme,
),
),
readOnly: inputEnabled != true || readOnly == true,
onInputChanged: (field, text) => _onInputChanged<T>(
field,
text,
inputEnabled,
),
displayTextMapper: (context, val) => labelMapper(val) ?? '',
hintText: readOnly == true
? null
: hintText ?? (inputEnabled == true ? '请选择或输入' : '请选择'),
validator: readOnly == true
? null
: (val) => generateValidator(val, validator, required),
);