PhoneInput constructor
PhoneInput({
- Key? key,
- PhoneController? controller,
- bool shouldFormat = true,
- ValueChanged<
PhoneNumber?> ? onChanged, - FocusNode? focusNode,
- bool showFlagInInput = true,
- dynamic onSaved()?,
- IsoCode defaultCountry = IsoCode.US,
- InputDecoration decoration = const InputDecoration(border: UnderlineInputBorder()),
- AutovalidateMode autovalidateMode = AutovalidateMode.onUserInteraction,
- PhoneNumber? initialValue,
- double flagSize = 20,
- BoxShape flagShape = BoxShape.circle,
- PhoneNumberInputValidator? validator,
- bool isCountrySelectionEnabled = true,
- bool showArrow = true,
- TextInputType keyboardType = TextInputType.phone,
- TextInputAction? textInputAction,
- TextStyle? style,
- TextStyle? countryCodeStyle,
- StrutStyle? strutStyle,
- TextAlign textAlign = TextAlign.start,
- TextAlignVertical? textAlignVertical,
- bool autofocus = false,
- String obscuringCharacter = '*',
- bool obscureText = false,
- bool autocorrect = true,
- SmartDashesType? smartDashesType,
- SmartQuotesType? smartQuotesType,
- bool enableSuggestions = true,
- Widget contextMenuBuilder()?,
- bool? showCursor,
- VoidCallback? onEditingComplete,
- ValueChanged<
String> ? onSubmitted, - AppPrivateCommandCallback? onAppPrivateCommand,
- List<
TextInputFormatter> ? inputFormatters, - bool enabled = true,
- double cursorWidth = 2.0,
- double? cursorHeight,
- Radius? cursorRadius,
- Color? cursorColor,
- BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight,
- BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight,
- Brightness? keyboardAppearance,
- EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
- bool enableInteractiveSelection = true,
- TextSelectionControls? selectionControls,
- MouseCursor? mouseCursor,
- ScrollPhysics? scrollPhysics,
- ScrollController? scrollController,
- Iterable<
String> ? autofillHints, - String? restorationId,
- bool enableIMEPersonalizedLearning = true,
Implementation
PhoneInput({
super.key,
this.controller,
this.shouldFormat = true,
this.onChanged,
this.focusNode,
bool showFlagInInput = true,
required CountrySelectorNavigator countrySelectorNavigator,
Function(PhoneNumber?)? super.onSaved,
this.defaultCountry = IsoCode.US,
InputDecoration decoration = const InputDecoration(border: UnderlineInputBorder()),
AutovalidateMode super.autovalidateMode = AutovalidateMode.onUserInteraction,
PhoneNumber? initialValue,
double flagSize = 20,
BoxShape flagShape = BoxShape.circle,
PhoneNumberInputValidator? validator,
bool isCountrySelectionEnabled = true,
bool showArrow = true,
// textfield inputs
TextInputType keyboardType = TextInputType.phone,
TextInputAction? textInputAction,
TextStyle? style,
TextStyle? countryCodeStyle,
StrutStyle? strutStyle,
TextAlign textAlign = TextAlign.start,
TextAlignVertical? textAlignVertical,
bool autofocus = false,
String obscuringCharacter = '*',
bool obscureText = false,
bool autocorrect = true,
SmartDashesType? smartDashesType,
SmartQuotesType? smartQuotesType,
bool enableSuggestions = true,
Widget Function(BuildContext, EditableTextState)? contextMenuBuilder,
bool? showCursor,
VoidCallback? onEditingComplete,
ValueChanged<String>? onSubmitted,
AppPrivateCommandCallback? onAppPrivateCommand,
List<TextInputFormatter>? inputFormatters,
super.enabled,
double cursorWidth = 2.0,
double? cursorHeight,
Radius? cursorRadius,
Color? cursorColor,
ui.BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight,
ui.BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight,
Brightness? keyboardAppearance,
EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
bool enableInteractiveSelection = true,
TextSelectionControls? selectionControls,
MouseCursor? mouseCursor,
ScrollPhysics? scrollPhysics,
ScrollController? scrollController,
Iterable<String>? autofillHints,
super.restorationId,
bool enableIMEPersonalizedLearning = true,
}) : assert(
initialValue == null || controller == null,
'One of initialValue or controller can be specified at a time',
),
super(
initialValue: controller != null ? controller.value : initialValue,
validator: validator ?? PhoneValidator.valid(),
builder: (state) {
final field = state as PhoneInputState;
return PhoneField(
showArrow: showArrow,
controller: field._childController,
showFlagInInput: showFlagInInput,
selectorNavigator: countrySelectorNavigator,
errorText: field.getErrorText(),
flagShape: flagShape,
flagSize: flagSize,
decoration: decoration,
enabled: enabled,
isCountrySelectionEnabled: isCountrySelectionEnabled,
// textfield params
autofillHints: autofillHints,
keyboardType: keyboardType,
textInputAction: textInputAction,
style: style,
countryCodeStyle: countryCodeStyle,
strutStyle: strutStyle,
textAlign: textAlign,
textAlignVertical: textAlignVertical,
autofocus: autofocus,
obscuringCharacter: obscuringCharacter,
obscureText: obscureText,
autocorrect: autocorrect,
smartDashesType: smartDashesType,
smartQuotesType: smartQuotesType,
enableSuggestions: enableSuggestions,
contextMenuBuilder: contextMenuBuilder,
showCursor: showCursor,
onEditingComplete: onEditingComplete,
onSubmitted: onSubmitted,
onAppPrivateCommand: onAppPrivateCommand,
cursorWidth: cursorWidth,
cursorHeight: cursorHeight,
cursorRadius: cursorRadius,
cursorColor: cursorColor,
selectionHeightStyle: selectionHeightStyle,
selectionWidthStyle: selectionWidthStyle,
keyboardAppearance: keyboardAppearance,
scrollPadding: scrollPadding,
enableInteractiveSelection: enableInteractiveSelection,
selectionControls: selectionControls,
mouseCursor: mouseCursor,
scrollController: scrollController,
scrollPhysics: scrollPhysics,
restorationId: restorationId,
enableIMEPersonalizedLearning: enableIMEPersonalizedLearning,
inputFormatters: inputFormatters,
);
},
);