phone_flag_input 0.0.1 copy "phone_flag_input: ^0.0.1" to clipboard
phone_flag_input: ^0.0.1 copied to clipboard

A beautiful and customizable phone number input widget with country flag selector and international phone number formatting for Flutter.

Phone Flag Input #

A beautiful and customizable phone number input widget for Flutter with country flag selector and international dial code support.

pub package License: MIT

Screenshots #

Phone Input Demo Country Picker

Features #

Beautiful Country Flag Display - Shows country flags using the country_flags package
🔍 Searchable Country Picker - Easily find countries by name, dial code, or country code
🌍 100+ Countries Supported - Comprehensive list of countries with dial codes
🎨 Fully Customizable - Theme support for colors, sizes, and border radius
📱 Input Filtering - Automatic filtering of plus codes, leading zeros, and country codes
⌨️ Keyboard Optimization - Phone keyboard with digit-only input support

Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  phone_flag_input: ^0.0.1

Then run:

flutter pub get

Usage #

Basic Usage #

import 'package:phone_flag_input/phone_flag_input.dart';

PhoneInput(
  initialCountry: Country.unitedStates,
  onChanged: (phoneNumber) {
    print('Full number: ${phoneNumber.fullNumber}');
    print('Country: ${phoneNumber.country.name}');
    print('Number: ${phoneNumber.number}');
  },
)

With Initial Value #

PhoneInput(
  initialValue: PhoneNumber(Country.india, '9876543210'),
  onChanged: (phone) => setState(() => _phone = phone),
)

With Custom Theme #

PhoneInput(
  initialCountry: Country.unitedKingdom,
  theme: PhoneInputTheme(
    flagHeight: 24,
    flagWidth: 36,
    maxWidth: 300,
    borderRadius: BorderRadius.circular(16),
    padding: EdgeInsets.symmetric(horizontal: 16, vertical: 12),
    flagGap: 12,
    countryGap: 8,
  ),
  phoneHint: 'Enter your phone number',
  onChanged: (phone) => print(phone.fullNumber),
)

Limited Countries #

Show only specific countries in the picker:

PhoneInput(
  countries: [
    Country.unitedStates,
    Country.canada,
    Country.unitedKingdom,
    Country.india,
  ],
  searchHint: 'Search available countries...',
  onChanged: (phone) => print(phone),
)

Disabled State #

PhoneInput(
  initialValue: PhoneNumber(Country.germany, '1234567890'),
  enabled: false,
  onChanged: (phone) {},
)

API Reference #

PhoneInput #

Property Type Default Description
initialCountry Country? Country.unitedStates Default country when no initial value is provided
initialValue PhoneNumber? null Initial phone number with country
onChanged ValueChanged<PhoneNumber>? null Callback when phone number changes
controller TextEditingController? null Controller for the number input field
filterPlusCode bool true Filter out plus (+) symbols from input
filterZeroCode bool true Filter out leading zeros from input
filterCountryCode bool true Filter out country codes from input
onlyNumber bool true Allow only numeric characters
countries List<Country>? null Specific countries to show in selector
searchHint String? 'Search country...' Hint text in search field
phoneHint String? 'Phone number' Hint text in phone input field
theme PhoneInputTheme? null Custom theme for styling
decoration InputDecoration? null Decoration for phone text field
enabled bool true Whether the input is enabled
focusNode FocusNode? null Focus node for the text field

PhoneInputTheme #

Property Type Default Description
padding EdgeInsetsGeometry? 12px horizontal, 14px vertical Padding inside country selector
borderRadius BorderRadius? 8px Border radius of components
popupConstraints BoxConstraints? null Constraints for country picker popup
maxWidth double? 200 Maximum width of phone text field
flagHeight double? 20 Height of country flag
flagWidth double? 28 Width of country flag
flagGap double? 8 Gap between flag and dial code
countryGap double? 4 Gap between dial code and dropdown icon

PhoneNumber #

Property Type Description
country Country The country associated with this phone number
number String The phone number without country code
fullNumber String Complete phone number including country code
value String? Full number or null if empty

Country #

Pre-defined country constants with name, dialCode, and code properties.

// Access pre-defined countries
Country.unitedStates  // US, +1
Country.india         // IN, +91
Country.unitedKingdom // GB, +44
Country.germany       // DE, +49

// Get all countries
Country.values

// Find by code
Country.findByCode('US')      // Returns Country.unitedStates
Country.findByDialCode('+91') // Returns Country.india

Example #

Check out the example directory for a complete demo application showing all features.

License #

MIT License - see the LICENSE file for details.

Contributing #

Contributions are welcome! Please feel free to submit a Pull Request.

1
likes
150
points
0
downloads

Publisher

verified publisherdivyanshdev.tech

Weekly Downloads

A beautiful and customizable phone number input widget with country flag selector and international phone number formatting for Flutter.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

country_flags, flutter

More

Packages that depend on phone_flag_input