PhoneInput class

Phone input extending form field.

controller:

Use a PhoneController for PhoneFormField when you need to dynamically change the value.

Whenever the user modifies the phone field with an associated controller, the phone field updates the display value and the controller notifies its listeners.

You can also use an initialValue: The initial value used.

Only one of initialValue and controller can be specified. If controller is specified the initialValue will be the first value of the PhoneController

formatting:

Specify whether the field will format the national number with shouldFormat = true (default) eg: +33677784455 will be displayed as +33 6 77 78 44 55.

The formats are localized for the country code. eg: +1 677-784-455 & +33 6 77 78 44 55

This does not affect the output value, only the display. Therefor onSizeFound will still return a PhoneNumber with nsn of 677784455.

Country picker:

specify which type of country selector will be shown with selectorNavigator.

Uses one of:

  • const BottomSheetNavigator()
  • const DraggableModalBottomSheetNavigator()
  • const ModalBottomSheetNavigator()
  • const DialogNavigator()
Inheritance

Constructors

PhoneInput({Key? key, PhoneController? controller, bool shouldFormat = true, ValueChanged<PhoneNumber?>? onChanged, FocusNode? focusNode, bool showFlagInInput = true, required CountrySelectorNavigator countrySelectorNavigator, dynamic onSaved(PhoneNumber?)?, 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(BuildContext, EditableTextState)?, 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})

Properties

autovalidateMode AutovalidateMode
Used to enable/disable this form field auto validation and update its error text.
finalinherited
builder FormFieldBuilder<PhoneNumber>
Function that returns the widget representing this form field.
finalinherited
controller PhoneController?
Use a PhoneController for PhoneFormField when you need to dynamically change the value.
final
defaultCountry IsoCode
country that is displayed when there is no value
final
enabled bool
Whether the form is able to receive user input.
finalinherited
errorBuilder FormFieldErrorBuilder?
Function that returns the widget representing the error to display.
finalinherited
focusNode FocusNode?
the focusNode of the national number
final
forceErrorText String?
An optional property that forces the FormFieldState into an error state by directly setting the FormFieldState.errorText property without running the validator function.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
initialValue PhoneNumber?
An optional value to initialize the form field to, or null otherwise.
finalinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onChanged ValueChanged<PhoneNumber?>?
callback called when the input value changes
final
onReset VoidCallback?
An optional method to call when the form field is reset via FormFieldState.reset.
finalinherited
onSaved ValueChanged<PhoneNumber?>?
An optional method to call with the final value when the form is saved via FormState.save.
finalinherited
restorationId String?
Restoration ID to save and restore the state of the form field.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shouldFormat bool
Specify whether the field will format the national number with shouldFormat = true (default) eg: +33677784455 will be displayed as +33 6 77 78 44 55.
final
validator FormFieldValidator<PhoneNumber>?
An optional method that validates an input. Returns an error string to display if the input is invalid, or null otherwise.
finalinherited

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() PhoneInputState
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited