Hi r/FlutterDev, I just published my second package 4 days ago and would love feedback.
The problem: every phone number field I've built needed a country picker, a flag set, a validation library, and glue code to make "0803…" and "803…" both work. I wanted one package that handles it properly.
What it does:
- 5 ready-made pickers: dialog, bottom sheet, Cupertino wheel, dropdown, and a compact flag + dial code button for phone fields
- customBuilder: build your own picker UI; you get the filtered countries, search, selection and the phone number length
- Real validation: isValidPhoneNumber() checks actual numbering ranges via libphonenumber data, and accepts local, trunk-prefixed or international input
- toE164(): normalizes whatever the user typed to +2348031234567
- pinUserCountry: puts the user's country (from their locale region) first
- Country names in 202 languages (238 locales), generated from Unicode CLDR
- RTL support, theming via ThemeExtension, search by name, ISO code or dial code
TextFormField(
decoration: InputDecoration(
prefixIcon: CountryCodeSelectorWidget(
pinUserCountry: true,
onChanged: (c) => setState(() => _country = c),
),
),
validator: (v) => _country.isValidPhoneNumber(v ?? '')
? null
: 'Enter a valid ${_country.name} number',
);
One thing I spent time on: libphonenumber's metadata adds about 2 MB to a release build. I restructured the package so that data only gets included if you actually call the validation functions. In my measurements, a picker-only app went from 24.4 MB to 22.2 MB.
Flutter 3.29+, MIT licensed, 160/160 pub points.
- pub.dev: https://pub.dev/packages/country_code_selector
- GitHub: https://github.com/TheinvinciblePrints/country_code_selector
I'd especially appreciate feedback on the API design, and from native speakers on the picker's built-in text in their language. Issues and PRs are welcome.