FormeCupertinoNumberField constructor
FormeCupertinoNumberField({
- Key? key,
- String? name,
- double? initialValue,
- FormeAsyncValidator<
double?> ? asyncValidator, - Duration? asyncValidatorDebounce,
- AutovalidateMode? autovalidateMode,
- FormeFieldDecorator<
double?> ? decorator, - bool enabled = true,
- FocusNode? focusNode,
- FormeFieldInitialized<
double?> ? onInitialized, - FormeFieldSetter<
double?> ? onSaved, - FormeFieldStatusChanged<
double?> ? onStatusChanged, - int? order,
- bool quietlyValidate = false,
- bool readOnly = false,
- bool requestFocusOnUserInteraction = true,
- FormeFieldValidationFilter<
double?> ? validationFilter, - FormeValidator<
double?> ? validator, - bool allowNegative = false,
- int decimal = 0,
- double? max,
- BoxDecoration? decoration = _kDefaultRoundedBorderDecoration,
- EdgeInsetsGeometry padding = const EdgeInsets.all(7.0),
- String? placeholder,
- TextStyle placeholderStyle = const TextStyle(fontWeight: FontWeight.w400, color: CupertinoColors.placeholderText),
- Widget? prefix,
- OverlayVisibilityMode prefixMode = OverlayVisibilityMode.always,
- Widget? suffix,
- OverlayVisibilityMode suffixMode = OverlayVisibilityMode.always,
- OverlayVisibilityMode clearButtonMode = OverlayVisibilityMode.never,
- TextInputType? keyboardType = TextInputType.number,
- TextInputAction? textInputAction,
- TextCapitalization textCapitalization = TextCapitalization.none,
- TextStyle? style,
- StrutStyle? strutStyle,
- TextAlign textAlign = TextAlign.start,
- TextAlignVertical? textAlignVertical,
- bool? showCursor,
- bool autofocus = false,
- String obscuringCharacter = '•',
- bool obscureText = false,
- bool autocorrect = true,
- SmartDashesType? smartDashesType,
- SmartQuotesType? smartQuotesType,
- bool enableSuggestions = true,
- int? minLines,
- bool expands = false,
- int? maxLength,
- MaxLengthEnforcement? maxLengthEnforcement,
- VoidCallback? onEditingComplete,
- ValueChanged<
String> ? onSubmitted, - List<
TextInputFormatter> ? inputFormatters, - double cursorWidth = 2.0,
- double? cursorHeight,
- Radius cursorRadius = const Radius.circular(2.0),
- Color? cursorColor,
- BoxHeightStyle selectionHeightStyle = BoxHeightStyle.tight,
- BoxWidthStyle selectionWidthStyle = BoxWidthStyle.tight,
- Brightness? keyboardAppearance,
- EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
- bool? enableInteractiveSelection,
- TextSelectionControls? selectionControls,
- DragStartBehavior dragStartBehavior = DragStartBehavior.start,
- ScrollController? scrollController,
- ScrollPhysics? scrollPhysics,
- GestureTapCallback? onTap,
- Iterable<
String> ? autofillHints, - bool enableIMEPersonalizedLearning = true,
- TextDirection? textDirection,
- Clip clipBehavior = Clip.hardEdge,
- bool scribbleEnabled = true,
- TapRegionCallback? onTapOutside,
- EditableTextContextMenuBuilder? contextMenuBuilder = _defaultContextMenuBuilder,
- SpellCheckConfiguration? spellCheckConfiguration,
- TextMagnifierConfiguration? magnifierConfiguration,
- int? maxLines = 1,
Implementation
FormeCupertinoNumberField({
super.key,
super.name,
super.initialValue,
super.asyncValidator,
super.asyncValidatorDebounce,
super.autovalidateMode,
super.decorator,
super.enabled = true,
super.focusNode,
super.onInitialized,
super.onSaved,
super.onStatusChanged,
super.order,
super.quietlyValidate = false,
super.readOnly = false,
super.requestFocusOnUserInteraction = true,
super.validationFilter,
super.validator,
this.allowNegative = false,
this.decimal = 0,
this.max,
this.decoration = _kDefaultRoundedBorderDecoration,
this.padding = const EdgeInsets.all(7.0),
this.placeholder,
this.placeholderStyle = const TextStyle(
fontWeight: FontWeight.w400,
color: CupertinoColors.placeholderText,
),
this.prefix,
this.prefixMode = OverlayVisibilityMode.always,
this.suffix,
this.suffixMode = OverlayVisibilityMode.always,
this.clearButtonMode = OverlayVisibilityMode.never,
this.keyboardType = TextInputType.number,
this.textInputAction,
this.textCapitalization = TextCapitalization.none,
this.style,
this.strutStyle,
this.textAlign = TextAlign.start,
this.textAlignVertical,
this.showCursor,
this.autofocus = false,
this.obscuringCharacter = '•',
this.obscureText = false,
this.autocorrect = true,
this.smartDashesType,
this.smartQuotesType,
this.enableSuggestions = true,
this.minLines,
this.expands = false,
this.maxLength,
this.maxLengthEnforcement,
this.onEditingComplete,
this.onSubmitted,
this.inputFormatters,
this.cursorWidth = 2.0,
this.cursorHeight,
this.cursorRadius = const Radius.circular(2.0),
this.cursorColor,
this.selectionHeightStyle = BoxHeightStyle.tight,
this.selectionWidthStyle = BoxWidthStyle.tight,
this.keyboardAppearance,
this.scrollPadding = const EdgeInsets.all(20.0),
this.enableInteractiveSelection,
this.selectionControls,
this.dragStartBehavior = DragStartBehavior.start,
this.scrollController,
this.scrollPhysics,
this.onTap,
this.autofillHints,
this.enableIMEPersonalizedLearning = true,
this.textDirection,
this.clipBehavior = Clip.hardEdge,
this.scribbleEnabled = true,
this.onTapOutside,
this.contextMenuBuilder = _defaultContextMenuBuilder,
this.spellCheckConfiguration,
this.magnifierConfiguration,
this.maxLines = 1,
}) : super.allFields(builder: (baseState) {
final _FormeCupertinoNumberFieldState state =
baseState as _FormeCupertinoNumberFieldState;
final List<TextInputFormatter> formatters =
FormeNumberField.numberFormatters(
decimal: decimal, allowNegative: allowNegative, max: max);
if (inputFormatters != null) {
formatters.addAll(inputFormatters);
}
void onChanged(String value) {
final double? parsed = double.tryParse(value);
if (parsed != null && parsed != state.value) {
state.updateController = false;
state.didChange(parsed);
} else {
if (value.isEmpty && state.value != null) {
state.didChange(null);
}
}
}
return CupertinoTextField(
onChanged: onChanged,
controller: state.textEditingController,
focusNode: state.focusNode,
decoration: decoration,
padding: padding,
placeholder: placeholder,
placeholderStyle: placeholderStyle,
prefix: prefix,
prefixMode: prefixMode,
suffix: suffix,
suffixMode: suffixMode,
clearButtonMode: clearButtonMode,
keyboardType: keyboardType,
textInputAction: textInputAction,
textCapitalization: textCapitalization,
style: style,
strutStyle: strutStyle,
textAlign: textAlign,
textAlignVertical: textAlignVertical,
textDirection: textDirection,
readOnly: state.readOnly,
showCursor: showCursor,
autofocus: autofocus,
obscuringCharacter: obscuringCharacter,
obscureText: obscureText,
autocorrect: autocorrect,
smartDashesType: smartDashesType,
smartQuotesType: smartQuotesType,
enableSuggestions: enableSuggestions,
maxLines: maxLines,
minLines: minLines,
expands: expands,
maxLength: maxLength,
maxLengthEnforcement: maxLengthEnforcement,
onEditingComplete: onEditingComplete,
onSubmitted: onSubmitted,
onTapOutside: onTapOutside,
inputFormatters: formatters,
enabled: state.enabled,
cursorWidth: cursorWidth,
cursorHeight: cursorHeight,
cursorRadius: cursorRadius,
cursorColor: cursorColor,
selectionHeightStyle: selectionHeightStyle,
selectionWidthStyle: selectionWidthStyle,
keyboardAppearance: keyboardAppearance,
scrollPadding: scrollPadding,
dragStartBehavior: dragStartBehavior,
enableInteractiveSelection: enableInteractiveSelection,
selectionControls: selectionControls,
onTap: onTap,
scrollController: scrollController,
scrollPhysics: scrollPhysics,
autofillHints: autofillHints,
clipBehavior: clipBehavior,
scribbleEnabled: scribbleEnabled,
enableIMEPersonalizedLearning: enableIMEPersonalizedLearning,
contextMenuBuilder: contextMenuBuilder,
spellCheckConfiguration: spellCheckConfiguration,
magnifierConfiguration: magnifierConfiguration,
);
});