flutter_intl_phone_field 1.0.0
flutter_intl_phone_field: ^1.0.0 copied to clipboard
International phone number input for Flutter: country picker, as-you-type formatting, and libphonenumber-accurate validation for 250+ countries.
Changelog #
All notable changes to this project are documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
1.0.0 - 2026-10-04 #
Built on package:material_ui instead
of the SDK's package:flutter/material.dart. Phone number handling is
unchanged. See MIGRATION.md.
Breaking #
- The package uses
package:material_ui, and your app has to as well.decoration,buildCounterandPickerDialogStyle.searchFieldInputDecorationtakematerial_uitypes, and the field needs amaterial_uiMaterialancestor at runtime. - Minimum SDK is Dart 3.12 / Flutter 3.44 (was Dart 3.4 / Flutter 3.22).
- The deprecated import paths are removed:
package:flutter_intl_phone_field/countries.dart,phone_number.dart,country_picker_dialog.dartandhelpers.dart. Importpackage:flutter_intl_phone_field/flutter_intl_phone_field.dart. IntlPhoneField.searchTextis removed. Uselocalizations.searchHint.
Thanks #
- Thanks to Erik Rill (@codivo-erill) for
the
material_uimigration, migration guide, and minimum-SDK CI coverage in PR #23.
0.1.2 - 2026-09-13 #
Fixed #
- No "setState() or markNeedsBuild() called during build" when the field
updates. Changing
initialCountryCode,formatInput,countries,onlyCountries,excludeCountriesorinitialValueon a mounted field rewrote the controller fromdidUpdateWidget, in the middle of a build, and the field'sTextFormFieldthen rebuilt the enclosingForm. The rewrite, and theonCountryChangedandonChangedcalls that go with it, now run once the frame has been built. - Mounting on a controller whose text is already parsed notifies no one.
The field assigned the text back in
initStateeven when it was unchanged, which reset the selection and notified every listener, including another field bound to the same controller that was still on screen.
0.1.1 - 2026-09-12 #
Documentation and tooling only; no API or behaviour changes.
Added #
- Agent skills, bundled with the package and installable with
dart run skills@ get, so AI coding assistants write the real 0.1.0 API instead of recalling the unrelatedintl_phone_fieldpackage.flutter-intl-phone-field-usagecovers the API, the common recipes and the mistakes to avoid, with the full parameter reference alongside it;flutter-intl-phone-field-migrationcovers upgrading fromintl_phone_fieldor from 0.0.x. See Ship skills with packages. - A Showcase page in the example app: five configurations of the same field on one screen.
- A third registered screenshot, and captions on all three.
Changed #
- Rewrote the README opening: screenshots first, a table of contents, and a "why this package" summary in place of the long feature list. Added a section on using the package with an AI assistant, including a copy-pasteable prompt.
- Replaced the screenshots, which still showed the pre-0.1.0 interface.
Fixed #
- The country picker drew two dividers between the pinned favourites and the rest of the list.
0.1.0 - 2026-09-12 #
Country data is now generated from Google's libphonenumber metadata, with localised names from the Unicode CLDR, and the widget, picker and models were rewritten on top of it. See MIGRATION.md for an upgrade guide.
Breaking #
Country.dialCodeis the true calling code. Twenty-one +1 territories that used to carry an area code inside it — American Samoa was"1684", Antigua"1268"— now havedialCode: "1"with the area code inregionCode. UseCountry.fullCountryCode("1684") to build a number andCountry.displayCC("1 684") to show one.- Jamaica and Puerto Rico have several area codes each, so they carry no
regionCode: their national number now includes the area code and is 10 digits. - Guernsey, Isle of Man and Jersey no longer use a synthetic
regionCode(1481/1624/1534). They are +44 with a 10-digit national number, told apart from the United Kingdom by leading digits. TheirminLengthandmaxLengthchanged from 6 to 10. - 120 of the 243 territories present in 0.0.8 had their
minLength/maxLengthcorrected from libphonenumber. For 117 of them the range of numbers the field accepts genuinely changed, so numbers that used to validate may now fail, and vice versa; for the other three only the split betweenregionCodeandminLengthmoved. - Cayman Islands moved from
+345, which is not an assigned calling code and so could never match a real number, to+1 345. Vatican City moved from+379to+39; Vatican numbers are reported as Italian, as libphonenumber reports them. PhoneNumberis immutable — its fields arefinal. UsecopyWithinstead of assigning to them.PhoneNumber.countryCodealways carries a leading+, soPhoneNumber.fromCompleteNumbernow agrees with the widget andcompleteNumberkeeps its+.- The built-in length check runs even when a custom
validatoris supplied; 0.0.8 skipped it entirely, contradicting its own documentation. PassdisableLengthCheck: trueto own validation completely. - Async validators now display their message. Errors an app was previously swallowing will start appearing.
- The default
autofillHintslead withAutofillHints.telephoneNumberrather thantelephoneNumberNational, because iOS and macOS QuickType only honour the first hint. CountryPickerDialogwas replaced by theshowCountryPickerfunction and the embeddableCountryPickerBody.- 43 countries' English
namechanged to match the English translation that was actually being displayed: Italy was named"Campione d'Italia", and the rest carried mangled ISO long-forms such as"Bolivia, Plurinational State of bolivia". Match onCountry.code. - The minimum SDK is Dart 3.4 / Flutter 3.22. The old
">=2.12.0"constraint pinned the package's language version to 2.12, making every Dart 3 feature a compile error inside it.
Added #
- Eight missing territories: Cape Verde, Kosovo, Curaçao, Sint Maarten, Western Sahara, Bonaire, Ascension Island and Tristan da Cunha — 251 in all.
CountryResolver, which matches on the calling code and then on the leading digits of the national number, the way libphonenumber does. Every fixed-line and mobile example number libphonenumber publishes — 489 of them, covering the 239 territories it publishes any for — resolves to the right country and validates, asserted by a generated test fixture.- As-you-type national formatting, opt-in via
formatInput, driven by libphonenumber's formatting rules:2015550123renders as(201) 555-0123. Exposed asAsYouTypeFormatterandPhoneInputFormatter. - Per-country validation patterns, and
strictValidationon the field plusisValidNumber(strict: true)onPhoneNumber, to require that a number fall in an assigned fixed-line or mobile range rather than merely be the right length. PhoneController, aValueNotifier<PhoneNumber>for reading and driving the field from outside the widget, withfromCompleteNumberandfromPartsconstructors.PhoneNumber.parse, which throws on failure, alongside the non-throwingfromCompleteNumber;validate(), which throwsNumberTooShortException,NumberTooLongExceptionorInvalidCharactersException; andcopyWith,==,hashCode,toJsonandfromJson.Country.fullCountryCode,displayCC,displayDialCode,localizedName,example,nationalPrefix,leadingDigits,areaCodes,isMainCountryForDialCode,autoDetectable,copyWithand==.CountryFlagwidget withFlagShape.rectangle,rounded,squareandcircle, aforceImageescape hatch, andflagShape/flagSizeon both the field andPickerDialogStyle. (#17)flagBuilder,dialCodeBuilderandcountrySelectorBuilderonIntlPhoneField, so the flag, the dial code or the whole selector — dropdown arrow included — can be replaced outright. (#17, #18)onlyCountries,excludeCountriesandfavoriteCountriesfor controlling and pinning entries in the picker.IntlPhoneFieldLocalizations: every built-in string in one place, with no dependency onintlor generated delegates.DialogType.showDraggableBottomSheet,showFullScreenPageandadaptivejoinshowDialogandshowModalBottomSheet.PickerDialogStyle.autofocusSearchField,showSearchClearButtonandselectedTileColor.showExampleAsHint, which uses the country's real example number as the field's hint text.detectCountryOnPaste, which switches country when a full international number is pasted into the field.InitialValueFormat(auto,national,international), which says outright howinitialValueshould be read.restorationId, forwarded to the underlyingTextFormField.MIGRATION.md, and a.pubignoreso the published archive carries neither the example app's platform folders nor thetest/andtool/directories.
Fixed #
- A national
initialValuewhose leading digits matched the dial code had those digits silently stripped — a UAE971123456became123456. The country code is now removed only when the value is unambiguously international. (#19) PhoneNumber.getCountry()threwStateErroron an unknown code, because it scanned withfirstWhereand noorElse. It now falls back to India, as its documentation always claimed.- The first-match scan made roughly thirty countries unreachable: the United States resolved to Canada, Russia to Kazakhstan, Norway to Bouvet Island.
- Twelve territories sat at a placeholder length of 15/15 — Åland Islands, Bouvet Island, Christmas Island, Cocos Islands, French Guiana, French Southern Territories, Guadeloupe, Heard & McDonald Islands, Martinique, Norfolk Island, Puerto Rico and South Georgia — so every real number for them was rejected.
initStatecast(value as Future)and threw when a validator returnednull.didUpdateWidgetwas absent, soinitialValue,initialCountryCodeandcountrieswere dead after the first frame.- Changing country never fired
onChanged, leaving the parent with a stale country code, and could leave more digits in the field than the new country allows. disableLengthCheckstill capped typing at the country maximum.initialCountryCodeaccepted a dial code per its documentation but matched only ISO codes, silently falling back to the first country.- Flag emoji were used everywhere except web; Windows and Linux have no glyphs
for them and showed two letters or tofu.
CountryFlagnow picks the bundled PNG on those platforms and falls back image → emoji → ISO code, so a missing asset cannot red-screen the app. - Seven flag PNGs matched no country and were removed:
an(Netherlands Antilles, dissolved in 2010),eu,umand the four Great Britain subdivisions. - Dial codes rendered as
971+in RTL layouts. - The picker searched dial codes with
contains, so44matched Angola, and a leading+matched nothing at all. The diacritics table was misaligned and foldedotoö. debugPrintlogged the user's full phone number in release builds.- The bottom sheet nested a
Dialoginside itself and ignoredPickerDialogStyle.heightFactor.
Changed #
- The implementation moved to
lib/src/behind a single barrel export,package:flutter_intl_phone_field/flutter_intl_phone_field.dart. Every old top-level import path still resolves as a deprecated re-export shim. - The selector shows
+1 684rather than+1684, usingCountry.displayCC. - The country-lookup rewrite was inspired by JustifiedTech's PR #20, which first identified that a first-match scan over a shared calling code cannot attribute a number correctly.
Deprecated #
IntlPhoneField.searchText. Uselocalizations.searchHint, orPickerDialogStyle.searchFieldInputDecoration. Removed in 1.0.0.- The top-level import paths
countries.dart,phone_number.dart,country_picker_dialog.dartandhelpers.dart. Removed in 1.0.0;helpers.darthas no replacement, as those utilities were never meant to be public.
0.0.8 — never published #
This version was prepared in the repository but never released to pub.dev; everything in it ships as part of 0.1.0. It is kept here so the contributions it carries stay on the record.
Added #
showCountryCode, to hide the dial code while keeping the flag visible. (#6)PickerDialogStyle.searchFieldStyle, for the text style — colour, size and the rest — of the picker's search field. (#3)onTapOutside, to unfocus the field or run custom logic when the user taps away, plusPickerDialogStyle.heightFactorandscrollViewKeyboardDismissBehaviorfor the bottom sheet. Thanks to @bibek-saha-boon of Boon Infomate Private Limited (#13).- Russian country-name translations. Thanks to @orozDev (#7).
- Tests for the Kenya, United Kingdom and Crown Dependency number lengths and
for
searchFieldStyle.
Fixed #
- United Kingdom +44 numbers were validated as Guernsey numbers, because
Guernsey came first in the list and both carried a bare
44. Region codes were added for the Crown Dependencies — Guernsey1481, Isle of Man1624, Jersey1534— and the widget was made to usefullCountryCodeconsistently when building aPhoneNumber. (Superseded in 0.1.0 by leading-digit matching, which also handles Guernsey mobiles.) (#4) - Kenyan mobile numbers were rejected: the length was 9, which excluded the local format carrying the trunk prefix. Widened to 9–10. Thanks to @NOVACOAX (#8). (Corrected again in 0.1.0 to libphonenumber's 7–9.) (#5)
- The Syrian flag was updated to the post-Assad independence flag. Thanks to @Nidal-Bakir (#15). (#14)
0.0.7 - 2025-03-14 #
Changed #
initStateusesFuture.microtaskto initialise the country list and phone number.
