This plugin provides a TextEditingController that formats international phone numbers as you type them.
Two steps:
- In a stateful widget, define a
PhoneNumberController
:
final _controller = PhoneNumberController(countryCode: 'us');
- When building the text field, specify the controller:
TextFormField(
controller: _controller,
keyboardType: TextInputType.phone,
...
);