PhoneInput constructor
const
PhoneInput({
- Key? key,
- Country? initialCountry,
- PhoneNumber? initialValue,
- ValueChanged<
PhoneNumber?> ? onChanged, - TextEditingController? controller,
- @Deprecated('Plus code is now mandatory') bool filterPlusCode = true,
- @Deprecated('Plus code is now mandatory, leading zero is not a valid format') bool filterZeroCode = true,
- @Deprecated('Country code is now determined from input') 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(ValueChanged<PhoneNumber>?, optional): Callback for phone number changescontroller(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(List<Country>?, optional): Specific countries to show in selectorsearchPlaceholder(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,
@Deprecated('Plus code is now mandatory') this.filterPlusCode = true,
@Deprecated(
'Plus code is now mandatory, leading zero is not a valid format')
this.filterZeroCode = true,
@Deprecated('Country code is now determined from input')
this.filterCountryCode = true,
this.onlyNumber = true,
this.countries,
this.searchPlaceholder,
});