TxDropdownFormField<T, V>.custom constructor
TxDropdownFormField<T, V>.custom ({
- required List<
DropdownMenuItem< items,T> > - Key? key,
- T? initialValue,
- FormFieldSetter<
T> ? onSaved, - FormFieldValidator<
T> ? validator, - bool? enabled,
- AutovalidateMode? autovalidateMode = AutovalidateMode.onUserInteraction,
- String? restorationId,
- InputDecoration? decoration,
- ValueChanged<
T?> ? onChanged, - bool? required,
- FocusNode? focusNode,
- String? hintText,
- Widget? hint,
- Widget? disabledHint,
- VoidCallback? onTap,
- int? elevation,
- TextStyle? style,
- Widget? icon,
- Color? iconDisabledColor,
- Color? iconEnabledColor,
- double? iconSize,
- bool? isDense,
- bool? isExpanded,
- double? itemHeight,
- Color? focusColor,
- bool? autofocus,
- Color? dropdownColor,
- bool? enableFeedback,
- AlignmentGeometry? alignment,
- BorderRadius? borderRadius,
- DropdownButtonBuilder? selectedItemBuilder,
- 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,
- bool? dense,
- bool? colon,
- double? minLabelWidth,
- double? minVerticalPadding,
Implementation
TxDropdownFormField.custom({
required List<DropdownMenuItem<T>> items,
super.key,
super.initialValue,
super.onSaved,
FormFieldValidator<T>? validator,
super.enabled,
super.autovalidateMode,
super.restorationId,
super.decoration,
super.onChanged,
super.required,
FocusNode? focusNode,
String? hintText,
Widget? hint,
Widget? disabledHint,
VoidCallback? onTap,
int? elevation,
TextStyle? style,
Widget? icon,
Color? iconDisabledColor,
Color? iconEnabledColor,
double? iconSize,
bool? isDense,
bool? isExpanded,
double? itemHeight,
Color? focusColor,
bool? autofocus,
Color? dropdownColor,
double? menuMaxHeight,
bool? enableFeedback,
AlignmentGeometry? alignment,
BorderRadius? borderRadius,
EdgeInsetsGeometry? menuPadding,
DropdownButtonBuilder? selectedItemBuilder,
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.dense,
super.colon,
super.minLabelWidth,
super.minVerticalPadding,
}) : super(
builder: (field) {
final AlignmentGeometry effectiveAlign = alignment ??
(layoutDirection == Axis.horizontal
? Alignment.centerRight
: Alignment.centerLeft);
return DropdownButtonFormField<T>(
items: items,
selectedItemBuilder: selectedItemBuilder,
value: field.value,
hint: hint ?? Text(hintText ?? '请选择'),
disabledHint: disabledHint ?? const Text('无'),
onChanged: field.didChange,
onTap: onTap,
elevation: elevation ?? 4,
style: style ?? Theme.of(field.context).textTheme.bodyLarge,
icon: icon,
iconDisabledColor: iconDisabledColor,
iconEnabledColor: iconEnabledColor,
iconSize: iconSize ?? 24.0,
isDense: isDense ?? true,
isExpanded: isExpanded ?? true,
itemHeight: itemHeight,
focusColor: focusColor,
focusNode: focusNode,
autofocus: autofocus ?? false,
dropdownColor: dropdownColor,
decoration: field.effectiveDecoration,
menuMaxHeight: menuMaxHeight,
enableFeedback: enableFeedback,
alignment: effectiveAlign,
borderRadius: borderRadius,
padding: menuPadding,
);
},
validator: (val) =>
TxPickerFormField.generateValidator(val, validator, required),
hintText: hintText ?? '请选择',
);