phone_number_text_input_formatter

Creator: coderz1093

Last updated:

Add to Cart

Description:

phone number text input formatter

Phone Number Text Input Formatter #
This is a Flutter package built to provide phone number formatting functionality
during text input. It's a key helper in creating phone number input fields that
need to restrict and validate user input in a formatted manner.
Features #

Zero dependency
Efficiently formats the phone numbers on-the-fly, with better performance than regular expression-based solutions.
You can customize the format according to your needs, giving you more flexibility and control.
Comes with pre-implemented popular international and national phone number formats.

Usage #
Format the phone number using all available international formats:
TextField(
keyboardType: TextInputType.phone,
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r'[0-9,+]')),
const PhoneNumberTextInputFormatter(prefix: '+'),
],
)
copied to clipboard
Format the US phone number in international format:
TextField(
keyboardType: TextInputType.phone,
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r'[0-9,+]')),
const NationalPhoneNumberTextInputFormatter.US(prefix: '+'),
],
)
copied to clipboard
Custom phone number format:
TextField(
keyboardType: TextInputType.phone,
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r'[0-9,+]')),
const NationalPhoneNumberTextInputFormatter(
prefix: '+',
countryCode: '28',
groups: [
(length: 4, leading: ' [', trailing: '] '),
(length: 3, leading: '', trailing: '-'),
(length: 3, leading: '', trailing: ' '),
],
),
],
)
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files:

Customer Reviews

There are no reviews.