PhoneInput constructor

const PhoneInput({
  1. Key? key,
  2. Country? initialCountry,
  3. PhoneNumber? initialValue,
  4. ValueChanged<PhoneNumber>? onChanged,
  5. TextEditingController? controller,
  6. bool filterPlusCode = true,
  7. bool filterZeroCode = true,
  8. bool filterCountryCode = true,
  9. bool onlyNumber = true,
  10. List<Country>? countries,
  11. 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 provided
  • initialValue (PhoneNumber?, optional): Complete initial phone number with country
  • onChanged (ValueChanged
  • controller (TextEditingController?, optional): Controller for the number input field
  • filterPlusCode (bool, default: true): Whether to filter out plus symbols
  • filterZeroCode (bool, default: true): Whether to filter out leading zeros
  • filterCountryCode (bool, default: true): Whether to filter out country codes
  • onlyNumber (bool, default: true): Whether to allow only numeric input
  • countries (List
  • searchPlaceholder (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,
});