PhoneInput constructor
const
PhoneInput({
- Key? key,
- Country? initialCountry,
- PhoneNumber? initialValue,
- ValueChanged<
PhoneNumber> ? onChanged, - TextEditingController? controller,
- bool filterPlusCode = true,
- bool filterZeroCode = true,
- bool filterCountryCode = true,
- bool onlyNumber = true,
- List<
Country> ? countries, - Widget? searchPlaceholder,
Creates a PhoneInput widget.
The widget can be initialized with a specific country or complete phone number. Various filtering options control how user input is processed to ensure valid phone number format.
Parameters:
initialCountry
(Country?, optional): Default country when no initial value providedinitialValue
(PhoneNumber?, optional): Complete initial phone number with countryonChanged
(ValueChangedcontroller
(TextEditingController?, optional): Controller for the number input fieldfilterPlusCode
(bool, default: true): Whether to filter out plus symbolsfilterZeroCode
(bool, default: true): Whether to filter out leading zerosfilterCountryCode
(bool, default: true): Whether to filter out country codesonlyNumber
(bool, default: true): Whether to allow only numeric inputcountries
(ListsearchPlaceholder
(Widget?, optional): Placeholder for country search field
Example:
PhoneInput(
initialCountry: Country.canada,
filterPlusCode: true,
onChanged: (phone) => _validatePhoneNumber(phone),
);
Implementation
const PhoneInput({
super.key,
this.initialCountry,
this.initialValue,
this.onChanged,
this.controller,
this.filterPlusCode = true,
this.filterZeroCode = true,
this.filterCountryCode = true,
this.onlyNumber = true,
this.countries,
this.searchPlaceholder,
});