IconDataExternalField constructor
IconDataExternalField({
- required String iconLabel(
- IconData value
- required Future<
IconData?> selection(- BuildContext context,
- IconData? data
- IconDataExternalFieldController? controller,
- FocusNode? focusNode,
- bool clearOnCancel = false,
- String? labelPrefix,
- String? label,
- Widget? labelWidget,
- FormFieldSetter<
IconData> ? onSaved, - FormFieldValidator<
IconData> ? validator, - IconData? initialValue,
- bool enabled = true,
- AutovalidateMode? autovalidateMode = AutovalidateMode.disabled,
- TextStyle? style,
- double? iconSize,
- InputDecoration? decoration,
- EdgeInsets padding = const EdgeInsets.all(8),
- Widget? suffixIcon = const Icon(FontAwesomeIcons.magnifyingGlass),
- EdgeInsets? contentPadding,
- int? sizeExtraSmall,
- int? sizeSmall,
- int? sizeMedium,
- int? sizeLarge,
- int? sizeExtraLarge,
- double? minHeight,
- Key? key,
Implementation
IconDataExternalField({
required this.iconLabel,
required this.selection,
this.controller,
this.focusNode,
this.clearOnCancel = false,
final String? labelPrefix,
final String? label,
final Widget? labelWidget,
super.onSaved,
final FormFieldValidator<IconData>? validator,
final IconData? initialValue,
super.enabled = true,
super.autovalidateMode = AutovalidateMode.disabled,
final TextStyle? style,
final double? iconSize,
final InputDecoration? decoration,
final EdgeInsets padding = const EdgeInsets.all(8),
final Widget? suffixIcon = const Icon(FontAwesomeIcons.magnifyingGlass),
final EdgeInsets? contentPadding,
super.sizeExtraSmall,
super.sizeSmall,
super.sizeMedium,
super.sizeLarge,
super.sizeExtraLarge,
super.minHeight,
super.key,
}) : assert(
initialValue == null || controller == null,
'initialValue or controller must be null.',
),
assert(
label == null || labelWidget == null,
'label or labelWidget must be null.',
),
super(
initialValue: controller?.value ?? initialValue,
validator: enabled ? validator : null,
builder: (final FormFieldState<IconData> field) {
_IconDataExternalFieldState state =
field as _IconDataExternalFieldState;
final ThemeData theme = Theme.of(state.context);
final bool hasFocus = state._effectiveFocusNode.hasFocus;
final Color? color = enabled
? hasFocus
? theme.colorScheme.primary
: null
: theme.disabledColor;
final TextStyle? effectiveStyle =
(style ??
theme.textTheme.titleMedium?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
))
?.copyWith(color: color);
final InputDecoration effectiveDecoration =
(decoration ??
InputDecoration(
border: const OutlineInputBorder(),
label: labelWidget,
labelText: <String?>[
labelPrefix,
label,
].nonNulls.join(' - '),
counterText: '',
contentPadding: contentPadding,
suffixIcon: suffixIcon,
))
.applyDefaults(theme.inputDecorationTheme)
.copyWith(
prefixIcon: state.value != null
? Icon(state.value, size: iconSize, color: color)
: null,
enabled: enabled,
errorText: state.errorText,
);
return Padding(
padding: padding,
child: Focus(
focusNode: state._effectiveFocusNode,
canRequestFocus: enabled,
skipTraversal: !enabled,
child: MouseRegion(
cursor: enabled
? SystemMouseCursors.click
: SystemMouseCursors.basic,
onEnter: (_) => state.hovering(enter: true),
onExit: (_) => state.hovering(enter: false),
child: GestureDetector(
onTap: enabled ? state._handleTap : null,
child: InputDecorator(
decoration: effectiveDecoration,
isEmpty: state.value == null,
isFocused: hasFocus,
isHovering: state._isHovering,
child: isNull(state.value)
? null
: Text(iconLabel(state.value!), style: effectiveStyle),
),
),
),
),
);
},
);