From 3cb716226fbb50c45f24bebdc89a6adcbfc51b55 Mon Sep 17 00:00:00 2001 From: jhonathanqz Date: Tue, 26 Nov 2024 09:42:43 -0300 Subject: [PATCH] feat: add new propertie readOnly --- .gitignore | 5 + CHANGELOG.md | 377 +++++++++++++++++------------- lib/src/widgets/input_widget.dart | 78 ++----- pubspec.yaml | 5 +- 4 files changed, 246 insertions(+), 219 deletions(-) diff --git a/.gitignore b/.gitignore index ac0ad20f57..065acb5bff 100644 --- a/.gitignore +++ b/.gitignore @@ -74,3 +74,8 @@ build/ !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages .metadata + +# FVM Version Cache +.fvm/ +.fvmrc +settings.json \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 5371665da9..d1d23d2e6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,251 +1,302 @@ +## [0.8.0] + +- Add propertie readOnly +- Update package to flutter version 3.24.4 + ## [0.7.5] -* Fixed bug in `AsYouTypeFormatter` that could throw a `RangeError` if the user typed non digit characters + +- Fixed bug in `AsYouTypeFormatter` that could throw a `RangeError` if the user typed non digit characters ## [0.7.4] -* Updated minimum os version on iOS -* Updated dependencies + +- Updated minimum os version on iOS +- Updated dependencies ## [0.7.3+1] -* Added pub example + +- Added pub example ## [0.7.3] -* Updated dependency in libphonenumber -* Update AsYouTypeFormatter -* Replaced `headline` with `headlineSmall` in countries_search_list_widget.dart -* Totally removed `getNameForNumber` + +- Updated dependency in libphonenumber +- Update AsYouTypeFormatter +- Replaced `headline` with `headlineSmall` in countries_search_list_widget.dart +- Totally removed `getNameForNumber` ## [0.7.2] -* Updated libphonenumber and PhoneNumberToCarrierMapper on Android -* Removed dependency on libphonenumber -* Switch from libphonenumber-iOS to PhoneNumberKit on iOS -* Update libphonenumber.js file -* Depreciating `getNameForNumber` in future updates + +- Updated libphonenumber and PhoneNumberToCarrierMapper on Android +- Removed dependency on libphonenumber +- Switch from libphonenumber-iOS to PhoneNumberKit on iOS +- Update libphonenumber.js file +- Depreciating `getNameForNumber` in future updates ## [0.7.1] -* Massive thanks to the community + +- Massive thanks to the community ## [0.7.0+2] -* Fixed validator defined with wrong type #207 -* PlatformException thrown when isValidPhoneNumber is passed a 0 or 1 character phoneNumber parameter. #209 + +- Fixed validator defined with wrong type #207 +- PlatformException thrown when isValidPhoneNumber is passed a 0 or 1 character phoneNumber parameter. #209 ## [0.7.0+1] -* Replaced `FutureOr<>` with `Future<>` + +- Replaced `FutureOr<>` with `Future<>` ## [0.7.0] -* Co-contributors discussion now opened, view this [link](https://github.com/natintosh/intl_phone_number_input/discussions/201) for more info. -* Null Safety Migration -* Upgraded dependencies -* Breaking Change Depreciated `SelectorConfig.backgroundColor` and replaced with `Theme.of(context).canvasColor` -* Fixed Dominican Republic dial_code at country_list.dart #196 -* Fixed change country when initialValue is set with the widget #170 -* Fixed PhoneNumberUtil.getNumberType on mobile and web #188 -* Added translations for Turkish and Romanian #190 -* Updated Taiwan country name #181 -* Added style config for selector button #177 -* Removed any potential duplicates on countries list #175 -* Fixed ignore selector and text field spacing in prefixIcon mode #161 -* :sweat_smile: Well, Actually using cursorColor #160 -* Fixed initialValue should not be formatted if formatInput is false #192 -* Fixed Bottom Sheet RenderFlex overflow bug #187, similar to Search by Country name or dial code bug #197 -* Updated README.md file to fix Web release does not recognize the packages #186 -* Fixed onSaved callback in the InternationalPhoneNumberInput is not synchronous #180 -* Cherry picked pending fixes and pull request from repo. + +- Co-contributors discussion now opened, view this [link](https://github.com/natintosh/intl_phone_number_input/discussions/201) for more info. +- Null Safety Migration +- Upgraded dependencies +- Breaking Change Depreciated `SelectorConfig.backgroundColor` and replaced with `Theme.of(context).canvasColor` +- Fixed Dominican Republic dial_code at country_list.dart #196 +- Fixed change country when initialValue is set with the widget #170 +- Fixed PhoneNumberUtil.getNumberType on mobile and web #188 +- Added translations for Turkish and Romanian #190 +- Updated Taiwan country name #181 +- Added style config for selector button #177 +- Removed any potential duplicates on countries list #175 +- Fixed ignore selector and text field spacing in prefixIcon mode #161 +- :sweat_smile: Well, Actually using cursorColor #160 +- Fixed initialValue should not be formatted if formatInput is false #192 +- Fixed Bottom Sheet RenderFlex overflow bug #187, similar to Search by Country name or dial code bug #197 +- Updated README.md file to fix Web release does not recognize the packages #186 +- Fixed onSaved callback in the InternationalPhoneNumberInput is not synchronous #180 +- Cherry picked pending fixes and pull request from repo. ## [0.6.1] -* Upgrade dependencies -* cherrypick pending fixes from repo + +- Upgrade dependencies +- cherrypick pending fixes from repo ## [0.6.0] - - Added support for Flutter Web :fire: :fire: :fire: :rocket: :rocket: :rocket: . - - Added textAlign, textAlignVertical. - - Fixed French translation of Egypt. - - Added option to make selector button a prefix icon in `SelectorConfig`. - - Added `cursorColor` option. - - Added `scrollPadding` option. - - Added new language translations for Serbia, with two scripts. - - Updated onSaved into `ValueChange`. now onSaved returns a `PhoneNumber` object. - - Added `keyboardType` option and improvements on iOS keyboard, see [#147](https://github.com/natintosh/intl_phone_number_input/pull/147), [#148](https://github.com/natintosh/intl_phone_number_input/pull/148) for more details. - - Added locale zh-TW. - - Added locale ar. - - Added support of nb and nn locale. - - Fixed issue with AsYouType formatter injecting country dial code on every input for phone numbers with North American Numbering Plan. - - Fixed issue with Selector Button onTap when enable is false. - - Breaking Change for v0.7.0, `SelectorConfig.backgroundColor` would be removed and replaced with `Theme.of(context).canvasColor`. - - Added `spaceBetweenSelectorAndTextField` for padding between selector button and text field. - - Fixed Bug with cursor position on typing, see [#130](https://github.com/natintosh/intl_phone_number_input/issues/130) for illustration and more information. - - Fixed Bug with selector button country restoring to initialValue after updating/changing value, see [#155](https://github.com/natintosh/intl_phone_number_input/issues/155) for more information. - - Tap outside `selectorType` `PhoneInputSelectorType.BOTTOM_SHEET` now dismisses the dialog. +- Added support for Flutter Web :fire: :fire: :fire: :rocket: :rocket: :rocket: . +- Added textAlign, textAlignVertical. +- Fixed French translation of Egypt. +- Added option to make selector button a prefix icon in `SelectorConfig`. +- Added `cursorColor` option. +- Added `scrollPadding` option. +- Added new language translations for Serbia, with two scripts. +- Updated onSaved into `ValueChange`. now onSaved returns a `PhoneNumber` object. +- Added `keyboardType` option and improvements on iOS keyboard, see [#147](https://github.com/natintosh/intl_phone_number_input/pull/147), [#148](https://github.com/natintosh/intl_phone_number_input/pull/148) for more details. +- Added locale zh-TW. +- Added locale ar. +- Added support of nb and nn locale. +- Fixed issue with AsYouType formatter injecting country dial code on every input for phone numbers with North American Numbering Plan. +- Fixed issue with Selector Button onTap when enable is false. +- Breaking Change for v0.7.0, `SelectorConfig.backgroundColor` would be removed and replaced with `Theme.of(context).canvasColor`. +- Added `spaceBetweenSelectorAndTextField` for padding between selector button and text field. +- Fixed Bug with cursor position on typing, see [#130](https://github.com/natintosh/intl_phone_number_input/issues/130) for illustration and more information. +- Fixed Bug with selector button country restoring to initialValue after updating/changing value, see [#155](https://github.com/natintosh/intl_phone_number_input/issues/155) for more information. +- Tap outside `selectorType` `PhoneInputSelectorType.BOTTOM_SHEET` now dismisses the dialog. ## [0.5.2+2] + ## [0.5.2+1] - - Fixed issue with pub.dev analysis + +- Fixed issue with pub.dev analysis ## [0.5.2] - - Updated dependencies - - Breaking Change Changed autoValidate to autoValidateMode - - Added getPhoneNumberType static method to PhoneNumber. - - Added bottomSheet background color property to SelectorConfig - - Updated Egypt country name - - Enable alpha 3 code in country search criteria - - Added country comparator to SelectorConfig to sort Country on initial load - ```dart - // Should return -1 if A precedes B, 0 if A is equal to B and 1 if B precedes A - ``` + +- Updated dependencies +- Breaking Change Changed autoValidate to autoValidateMode +- Added getPhoneNumberType static method to PhoneNumber. +- Added bottomSheet background color property to SelectorConfig +- Updated Egypt country name +- Enable alpha 3 code in country search criteria +- Added country comparator to SelectorConfig to sort Country on initial load + +```dart + // Should return -1 if A precedes B, 0 if A is equal to B and 1 if B precedes A +``` ## [0.5.1] - - Fixed issue with pt_br.png asset not loading + +- Fixed issue with pt_br.png asset not loading ## [0.5.0] - - Fixed issue with text input autoFocus when formatInput is set to false - - Added new locale translations for ["sk" "se" "pl" "no" "ja" "it" "zh" "nl" "de" "fr" "es" "en" "pt_BR"] - * Made possible by [@SimonFM](https://github.com/SimonFM) and [@diefferson](https://github.com/diefferson) - - Added selector configuration `selectorConfig` parameter which enables you to - * Add emoji flag support - * Add option to turn off flags - - Breaking Change `selectorType` has been moved to `selectorConfig` - - Fixed autoFocus search search field - - Fixed keyboard covers bottom sheet while search - - Breaking Change Removed factory constructors `withCustomBorder` and `withCustomDecoration` +- Fixed issue with text input autoFocus when formatInput is set to false +- Added new locale translations for ["sk" "se" "pl" "no" "ja" "it" "zh" "nl" "de" "fr" "es" "en" "pt_BR"] + - Made possible by [@SimonFM](https://github.com/SimonFM) and [@diefferson](https://github.com/diefferson) +- Added selector configuration `selectorConfig` parameter which enables you to + - Add emoji flag support + - Add option to turn off flags +- Breaking Change `selectorType` has been moved to `selectorConfig` +- Fixed autoFocus search search field +- Fixed keyboard covers bottom sheet while search +- Breaking Change Removed factory constructors `withCustomBorder` and `withCustomDecoration` ## [0.4.6+2] - - Removed selector button left padding + +- Removed selector button left padding ## [0.4.6+1] - - Fixed setState() or markNeedsBuild called during build + +- Fixed setState() or markNeedsBuild called during build ## [0.4.6] - - Fixed incorrect cursor positioning while editing + +- Fixed incorrect cursor positioning while editing ## [0.4.5] - - Added maxLength property to set length limit - - Fixed getter 'hash' was called on null. + +- Added maxLength property to set length limit +- Fixed getter 'hash' was called on null. ## [0.4.4] - - Updated package documentation - - Added selector button padding on error - - Fixed issue with first digit getting removed + +- Updated package documentation +- Added selector button padding on error +- Fixed issue with first digit getting removed ## [0.4.3] - - Fixed issue with first digit getting removed + +- Fixed issue with first digit getting removed ## [0.4.2] - - Fixed issue with keyboard and multiple rebuilds + +- Fixed issue with keyboard and multiple rebuilds ## [0.4.1+1] - - Fixed issue with PhoneInputSelectorType.DIALOG + +- Fixed issue with PhoneInputSelectorType.DIALOG ## [0.4.1] - - Updated Cayman Island dial code - - Added selectorTextStyle parameter - - Improve load up time - - Fixed NoSuchMethodError: The getter 'owner' was called on null + +- Updated Cayman Island dial code +- Added selectorTextStyle parameter +- Improve load up time +- Fixed NoSuchMethodError: The getter 'owner' was called on null ## [0.4.0+2] - - Fixed NoSuchMethodError: The getter 'owner' was called on null + +- Fixed NoSuchMethodError: The getter 'owner' was called on null ## [0.4.0+1] - - Fixed issue with Validation error on initial value + +- Fixed issue with Validation error on initial value ## [0.4.0] - - Added new initialValue parameter that accepts a PhoneNumber object - - Added autoFocus option - - Added Keys and Helper class for testing - - Updated static method getParsableNumber from PhoneNumber - - Removed initialCountry2letterCode parameter - - Fixed issue with textController calling disposed if user defines the controller - - Fixed issue with with country picker alignment gone wrong when a single country is set - - Fixed NullPointerException thrown on getRegionInfoFromPhoneNumber + +- Added new initialValue parameter that accepts a PhoneNumber object +- Added autoFocus option +- Added Keys and Helper class for testing +- Updated static method getParsableNumber from PhoneNumber +- Removed initialCountry2letterCode parameter +- Fixed issue with textController calling disposed if user defines the controller +- Fixed issue with with country picker alignment gone wrong when a single country is set +- Fixed NullPointerException thrown on getRegionInfoFromPhoneNumber ## [0.3.0] - - Added support for RTL languages to be presented in the correct alignment - - Added new mode selection for dropdown, bottom sheet and dialog - - Added country names to bottom sheet and dialog country list - - Added search box to filter countries in the bottom sheet and country list - - Added For the above - an option to pass in a search box decoration - - Added ignoreBlank boolean to avoid input error message when left blank - - Added nameTranslations map to country model as preparation for future country name translation support - - Added Also for the above added the locale String field option (When translations will be supported this will define the requested translation language e.g. en_US, fr_FR etc.) - - Added function to get initial country ISO2 code when the input has pre-defined phone number (good for an "edit" input) - - Improved loading time for country list - - Changed When only one country passed in there is no need for any selector widget so a plain "Item" widget will be shown instead - + +- Added support for RTL languages to be presented in the correct alignment +- Added new mode selection for dropdown, bottom sheet and dialog +- Added country names to bottom sheet and dialog country list +- Added search box to filter countries in the bottom sheet and country list +- Added For the above - an option to pass in a search box decoration +- Added ignoreBlank boolean to avoid input error message when left blank +- Added nameTranslations map to country model as preparation for future country name translation support +- Added Also for the above added the locale String field option (When translations will be supported this will define the requested translation language e.g. en_US, fr_FR etc.) +- Added function to get initial country ISO2 code when the input has pre-defined phone number (good for an "edit" input) +- Improved loading time for country list +- Changed When only one country passed in there is no need for any selector widget so a plain "Item" widget will be shown instead + ## [0.2.1] - - Bug fixes - - Improvement for reliability + +- Bug fixes +- Improvement for reliability ## [0.2.0] - - As You Type Formatter: The Package now formats the input to it's selected national format - - You can now disable input formatting by setting inputFormat to false - - Replaced TextField with - - AutoValidate - - TextStyle + +- As You Type Formatter: The Package now formats the input to it's selected national format +- You can now disable input formatting by setting inputFormat to false +- Replaced TextField with +- AutoValidate +- TextStyle ## [0.1.3] - - onInputChanged now returns a new PhoneNumber Model - - You can create a PhoneNumber object from PhoneNumber.getRegionInfoFromPhoneNumber(String phoneNumber, [String isoCode]); - - You can now parse phoneNumber by calling PhoneNumber.getParsableNumber(String phoneNumber, String isoCode) or `PhoneNumber Reference`.parseNumber() + +- onInputChanged now returns a new PhoneNumber Model +- You can create a PhoneNumber object from PhoneNumber.getRegionInfoFromPhoneNumber(String phoneNumber, [String isoCode]); +- You can now parse phoneNumber by calling PhoneNumber.getParsableNumber(String phoneNumber, String isoCode) or `PhoneNumber Reference`.parseNumber() ## [0.1.2+2] - - Bug fixed + +- Bug fixed ## [0.1.2] - - TextField now formats whenever TextEditingController Text is changed + +- TextField now formats whenever TextEditingController Text is changed ## [0.1.1] - - Added TextEditingController - - Added KeyboardActionType - - Added callback that listens to keyboard action + +- Added TextEditingController +- Added KeyboardActionType +- Added callback that listens to keyboard action ## [0.1.0] - - Minor bug fixed - - #### What's new - * Added focus node - * Custom list of countries e.g. ['NG', 'GH', 'BJ' 'TG', 'CI'] - * Country Flag and Logo now formatted + +- Minor bug fixed +- #### What's new + - Added focus node + - Custom list of countries e.g. ['NG', 'GH', 'BJ' 'TG', 'CI'] + - Country Flag and Logo now formatted ## [0.0.10] - - Minor changes to the source file - + +- Minor changes to the source file + ## [0.0.9] - - Critical bug fixed caused by changing source files and packages - + +- Critical bug fixed caused by changing source files and packages + ## [0.0.8] - - Minor changes to the source file - - Added example - - Updated README.md - - Added examples to README.md + +- Minor changes to the source file +- Added example +- Updated README.md +- Added examples to README.md ## [0.0.7] - - Critical bug fixed - - Updated README.md + +- Critical bug fixed +- Updated README.md ## [0.0.6] - - Updated README.md - - Fixed issues with text input not validating - - Fixed issues with text input not parsing + +- Updated README.md +- Fixed issues with text input not validating +- Fixed issues with text input not parsing ## [0.0.5] - - Critical bug fixed - - Removed example - - Fixed countries.json assets not loading - + +- Critical bug fixed +- Removed example +- Fixed countries.json assets not loading + ## [0.0.4] - - Critical bug fixed - - Fixed image assets not loading + +- Critical bug fixed +- Fixed image assets not loading ## [0.0.3] - - Critical bug fixed - - Added examples - - Fixed image assets not loading + +- Critical bug fixed +- Added examples +- Fixed image assets not loading ## [0.0.2] - - Critical bug fixed - - Updated README.md + +- Critical bug fixed +- Updated README.md ## [0.0.1] - ###### Initial project release - - Updated README.md - - Added support for custom input decoration - - Added support for custom input border \ No newline at end of file + +###### Initial project release + +- Updated README.md +- Added support for custom input decoration +- Added support for custom input border diff --git a/lib/src/widgets/input_widget.dart b/lib/src/widgets/input_widget.dart index 94972bad18..7325575c66 100644 --- a/lib/src/widgets/input_widget.dart +++ b/lib/src/widgets/input_widget.dart @@ -80,6 +80,7 @@ class InternationalPhoneNumberInput extends StatefulWidget { final TextAlign textAlign; final TextAlignVertical textAlignVertical; final EdgeInsets scrollPadding; + final bool readOnly; final FocusNode? focusNode; final Iterable? autofillHints; @@ -124,6 +125,7 @@ class InternationalPhoneNumberInput extends StatefulWidget { this.focusNode, this.cursorColor, this.autofillHints, + this.readOnly = false, this.countries}) : super(key: key); @@ -176,17 +178,10 @@ class _InputWidgetState extends State { /// [initialiseWidget] sets initial values of the widget void initialiseWidget() async { if (widget.initialValue != null) { - if (widget.initialValue!.phoneNumber != null && - widget.initialValue!.phoneNumber!.isNotEmpty && - (await PhoneNumberUtil.isValidNumber( - phoneNumber: widget.initialValue!.phoneNumber!, - isoCode: widget.initialValue!.isoCode!))!) { - String phoneNumber = - await PhoneNumber.getParsableNumber(widget.initialValue!); - - controller!.text = widget.formatInput - ? phoneNumber - : phoneNumber.replaceAll(RegExp(r'[^\d+]'), ''); + if (widget.initialValue!.phoneNumber != null && widget.initialValue!.phoneNumber!.isNotEmpty && (await PhoneNumberUtil.isValidNumber(phoneNumber: widget.initialValue!.phoneNumber!, isoCode: widget.initialValue!.isoCode!))!) { + String phoneNumber = await PhoneNumber.getParsableNumber(widget.initialValue!); + + controller!.text = widget.formatInput ? phoneNumber : phoneNumber.replaceAll(RegExp(r'[^\d+]'), ''); phoneNumberControllerListener(); } @@ -196,8 +191,7 @@ class _InputWidgetState extends State { /// loads countries from [Countries.countryList] and selected Country void loadCountries({Country? previouslySelectedCountry}) { if (this.mounted) { - List countries = - CountryProvider.getCountriesData(countries: widget.countries); + List countries = CountryProvider.getCountriesData(countries: widget.countries); Country country = previouslySelectedCountry ?? Utils.getInitialSelectedCountry( @@ -208,8 +202,7 @@ class _InputWidgetState extends State { // Remove potential duplicates countries = countries.toSet().toList(); - final CountryComparator? countryComparator = - widget.selectorConfig.countryComparator; + final CountryComparator? countryComparator = widget.selectorConfig.countryComparator; if (countryComparator != null) { countries.sort(countryComparator); } @@ -225,20 +218,14 @@ class _InputWidgetState extends State { /// the `ValueCallback` [widget.onInputValidated] void phoneNumberControllerListener() { if (this.mounted) { - String parsedPhoneNumberString = - controller!.text.replaceAll(RegExp(r'[^\d+]'), ''); + String parsedPhoneNumberString = controller!.text.replaceAll(RegExp(r'[^\d+]'), ''); - getParsedPhoneNumber(parsedPhoneNumberString, this.country?.alpha2Code) - .then((phoneNumber) { + getParsedPhoneNumber(parsedPhoneNumberString, this.country?.alpha2Code).then((phoneNumber) { if (phoneNumber == null) { - String phoneNumber = - '${this.country?.dialCode}$parsedPhoneNumberString'; + String phoneNumber = '${this.country?.dialCode}$parsedPhoneNumberString'; if (widget.onInputChanged != null) { - widget.onInputChanged!(PhoneNumber( - phoneNumber: phoneNumber, - isoCode: this.country?.alpha2Code, - dialCode: this.country?.dialCode)); + widget.onInputChanged!(PhoneNumber(phoneNumber: phoneNumber, isoCode: this.country?.alpha2Code, dialCode: this.country?.dialCode)); } if (widget.onInputValidated != null) { @@ -247,10 +234,7 @@ class _InputWidgetState extends State { this.isNotValid = true; } else { if (widget.onInputChanged != null) { - widget.onInputChanged!(PhoneNumber( - phoneNumber: phoneNumber, - isoCode: this.country?.alpha2Code, - dialCode: this.country?.dialCode)); + widget.onInputChanged!(PhoneNumber(phoneNumber: phoneNumber, isoCode: this.country?.alpha2Code, dialCode: this.country?.dialCode)); } if (widget.onInputValidated != null) { @@ -264,16 +248,13 @@ class _InputWidgetState extends State { /// Returns a formatted String of [phoneNumber] with [isoCode], returns `null` /// if [phoneNumber] is not valid or if an [Exception] is caught. - Future getParsedPhoneNumber( - String phoneNumber, String? isoCode) async { + Future getParsedPhoneNumber(String phoneNumber, String? isoCode) async { if (phoneNumber.isNotEmpty && isoCode != null) { try { - bool? isValidPhoneNumber = await PhoneNumberUtil.isValidNumber( - phoneNumber: phoneNumber, isoCode: isoCode); + bool? isValidPhoneNumber = await PhoneNumberUtil.isValidNumber(phoneNumber: phoneNumber, isoCode: isoCode); if (isValidPhoneNumber!) { - return await PhoneNumberUtil.normalizePhoneNumber( - phoneNumber: phoneNumber, isoCode: isoCode); + return await PhoneNumberUtil.normalizePhoneNumber(phoneNumber: phoneNumber, isoCode: isoCode); } } on Exception { return null; @@ -318,13 +299,11 @@ class _InputWidgetState extends State { /// /// Also updates [selectorButtonBottomPadding] String? validator(String? value) { - bool isValid = - this.isNotValid && (value!.isNotEmpty || widget.ignoreBlank == false); + bool isValid = this.isNotValid && (value!.isNotEmpty || widget.ignoreBlank == false); WidgetsBinding.instance.addPostFrameCallback((timeStamp) { if (isValid && widget.errorMessage != null) { setState(() { - this.selectorButtonBottomPadding = - widget.selectorButtonOnErrorPadding; + this.selectorButtonBottomPadding = widget.selectorButtonOnErrorPadding; }); } else { setState(() { @@ -346,17 +325,12 @@ class _InputWidgetState extends State { void _phoneNumberSaved() { if (this.mounted) { - String parsedPhoneNumberString = - controller!.text.replaceAll(RegExp(r'[^\d+]'), ''); + String parsedPhoneNumberString = controller!.text.replaceAll(RegExp(r'[^\d+]'), ''); - String phoneNumber = - '${this.country?.dialCode ?? ''}' + parsedPhoneNumberString; + String phoneNumber = '${this.country?.dialCode ?? ''}' + parsedPhoneNumberString; widget.onSaved?.call( - PhoneNumber( - phoneNumber: phoneNumber, - isoCode: this.country?.alpha2Code, - dialCode: this.country?.dialCode), + PhoneNumber(phoneNumber: phoneNumber, isoCode: this.country?.alpha2Code, dialCode: this.country?.dialCode), ); } } @@ -370,20 +344,17 @@ class _InputWidgetState extends State { String? get locale { if (widget.locale == null) return null; - if (widget.locale!.toLowerCase() == 'nb' || - widget.locale!.toLowerCase() == 'nn') { + if (widget.locale!.toLowerCase() == 'nb' || widget.locale!.toLowerCase() == 'nn') { return 'no'; } return widget.locale; } } -class _InputWidgetView - extends WidgetView { +class _InputWidgetView extends WidgetView { final _InputWidgetState state; - _InputWidgetView({Key? key, required this.state}) - : super(key: key, state: state); + _InputWidgetView({Key? key, required this.state}) : super(key: key, state: state); @override Widget build(BuildContext context) { @@ -424,6 +395,7 @@ class _InputWidgetView textDirection: TextDirection.ltr, controller: state.controller, cursorColor: widget.cursorColor, + readOnly: widget.readOnly, focusNode: widget.focusNode, enabled: widget.isEnabled, autofocus: widget.autoFocus, diff --git a/pubspec.yaml b/pubspec.yaml index 6d12146429..87c079f7ea 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,10 +1,10 @@ name: intl_phone_number_input description: A simple and customizable flutter package for inputting phone number in intl / international format uses Google's libphonenumber. -version: 0.7.5 +version: 0.8.0 homepage: https://github.com/natintosh/intl-phone-number-input environment: - sdk: '>=3.0.2 <4.0.0' + sdk: ">=3.5.4 <4.0.0" dependencies: flutter: @@ -18,7 +18,6 @@ dev_dependencies: flutter_test: sdk: flutter - # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec