vanshg395 / intl_phone_field Goto Github PK
View Code? Open in Web Editor NEWA customised Flutter TextFormField to input international phone number along with country code.
Home Page: https://pub.dev/packages/intl_phone_field
License: MIT License
A customised Flutter TextFormField to input international phone number along with country code.
Home Page: https://pub.dev/packages/intl_phone_field
License: MIT License
The current validation expects exactly ten digits, which is not universally correct. According to E.164, there might be up to 12 digits in the number, but possibly less.
Thanks for the package!
Wanted to change the position of the dropdown icon from the left side of the flag and number to the right of them but didn't get a way of doing it.
Hello, the maximum size for the number in Brazil is incorrect. Some time ago the size became 11 digits, and the component is with a maximum size of 10
The maximum length as a default is set to 10, however many international phone numbers are longer than 10 digits. The auto-validate method then just checks if the phone number is less than 10 digits (not max length, just the number 10). This should vary depending on the country code and be automatically updated
Would be nice to have a configuration area where you can modify the texts like : "Invalid phone Number" and other tags .. that way people could change easily.
I
Country flag doesnt display on android only ios is working, i guess thats an emoji not image
It could be great to have a similar property to readOnly
or enabled
for the country list dropdown.
I need the user to enter its phone number, and once validated I need to keep the IntlPhoneField widget but without the ability to change it. So I disable the textfield, but I can't disable the country list drop down, even if I hide the cursor icon using showDropdownIcon
=false.
As a quick fix I tried to change the countries
array after validating the phone number and set it to one unique value (the currently selected country) so even if the user access the dropdown he won't have the ability to change the country.
Unfortunately, this doesn't seems to work as the initial value of countries
seems to be permanent, even when updating it in a stateful widget.
Previous version used 10 numbers. Version 2.0 uses 9 numbers and has invalid phone number error.
If you select pakistan and then input number it allows 11 charachters when actually they should be 10.
Please fix this, this issue is also common with many other country lengths. If you fix these issues for all countries it will be the most popular package in pub.dev
Hello,
Please kindly migrate your package to support sound null safety in flutter.
The intl_phone_field.dart file is using the method showDialog(context: context, useRootNavigator: false, child : ...) and child is deprecated. It should be updated to builder.
How do I hide the country flag?
The Validation logic doesn't check according to the selected country's max length. It compares to constant value 10. Which fails on several country selection validations. Thus auto validation doesn't work.
Here is the code from the package.
validator = widget.autoValidate ? ((value) => value != null && value.length != 10 ? 'Invalid Mobile Number' : null) : widget.validator;
sometimes you need to disable the input field for example in case of Login we don't need the field of number, we just need the Username & password. especially if we do Animation, so the Field is here but we don't need it in login.
Can we add AutoFocus prop as well
/C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/intl_phone_field-1.4.2/lib/intl_phone_field.dart:192:7: Error: No named parameter with the name 'child'.
child: StatefulBuilder(
^^^^
Hi Vansh,
Looks like you did some great work with this library. Unfortunately, I've yet to test it because the GPLv3 is too restrictive for me. On that note, I'm hardly the only one that cannot use your library due to its strict licensing. Is there a concrete reason for you to have chosen the GPLv3? Aside from your noble free software goals, the license will only hurt this library's popularity, especially when there are other libraries out there solving the same problem (e.g. https://pub.dev/packages/intl_phone_number_input). Your library seems to have a nicer API though that's why I'm asking. Would you mind changing it to some less restrictive license like the LGPLv3, MIT or Apache v2? Thanks.
Kind regards,
Jonas
Feature request: Ability to prefill the number by using an API like the one in TextFormField (initialValue).
Used case: The requirement is when the number entered earlier can be edited.
If this is not in works already, I am happy to submit a PR.
Thanks!
Which event get called when change Country code?
If you can then you show replace all your flag with the flat/plain squire flag
When I tried to add Egyptian number, the field accepted only 9 inputs, although the numbers should be 10 inputs.
(+20) 1234567890
My app already has phone number coming from async, so i need to be able to set countryCode dynamically.
But initialCountryCode, only sets the initial value, if you change it later, the widget will NOT be rebuild.
I want a dark theme for the dropdown menu item
Unable to load asset: packages/intl_phone_field/assets/flags/in.png
Hey bro,
Thanks for the good package!
Would it be possible to add a parameter to the list 'maxLength' just like in the TextFormField ?
Thanks!
When using the widget in the web environment, the flags are not seen, only the codes and in a very large size
run the example app in flutter web try to change the country
error:
Error: setState() called after dispose(): _IntlPhoneFieldState#e0cb6(lifecycle state: defunct, not mounted)
This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback.
The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree.
This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose().
flutter version:
Flutter 1.20.0-3.0.pre.63 • channel master • https://github.com/flutter/flutter.git
Framework • revision 1e6e7150f3 (6 days ago) • 2020-06-26 12:01:59 +0800
Engine • revision 22b099bc63
Tools • Dart 2.9.0 (build 2.9.0-19.0.dev ea87c9b01a)
The problem is when using the widget in a page already on the stack.
We can resolve the issue by
adding the following code in file int_phone_field.dart
Future _changeCountry() async {
filteredCountries = countries;
await showDialog(
useRootNavigator: false,
Can't access in the onChange handler when country has been changed. There is no way to control changing the country
las banderas no se ven en web
some times the phone field has some number which can not remove by backspace. but, doesn't print that value in onChanged method and unfortunately displays on the phone field.
eg, the field has and display some number: 66605
onChanged method print: only country code (coz, I remove the field number by pressing backspace)
I need to change the text style of the flag button. But there are no mechanisms to do this.
I'll submit a PR.
Please note Swaziland has been changed to Eswatini, Eswatini is the new name of the country, please update.
Android phones allow auto detection of number.
Could we have some integration? There are packages out there already, but a single solution could be nice
https://github.com/ssk-flutter/get_phone_number
https://pub.dev/packages/sms_autofill
https://pub.dev/packages/mobile_number
could you insert a parameter to set the search string 'Search by Country Name'? Tnx
Hello,
Thank you for your useful plugin.
I want to mention that the length of phone number in Mauritania is 8 not 7.
We cannot use the plugin without rectifying this.
Thank you.
After the latest update the widget requires 9 digits for example where a country needs 10 (Egypt) which how it was initially, i also want to remove the x/9 validator but to no avail.
A receive this error on calling the IntlPhoneField():
The method 'copyWith' was called on null.
Receiver: null
Tried calling: copyWith(counter: Instance of 'SizedBox')
The relevant error-causing widget was
IntlPhoneField
I tried to call it a Column, Wrap and inside a simple container.
If we provide an initial value or a controller with a text prepopulated, then the flag and number don't update according to the provided value.
For example if initValue="+33123456789"
the flag should be the French one and the displayed number should be "123456789".
Instead it displays the US flag or whatever is the initialCountryCode and the displayed number remains "+33123456789"
imagine we have an application available only for 5 countries
we just need to list the 5 countries only and not all the countries
I was just using this package and this is what I did
IntlPhoneField(
style: TextStyle(fontSize: 16.0),
autofocus: true,
showDropdownIcon: false,
controller: phoneController, // <= on passing this phoneController to Firebase, it only passes the phone number
decoration: InputDecoration(
labelText: 'Phone Number',
border: UnderlineInputBorder(),
),
initialCountryCode: 'IN',
onChanged: (phone) {
print(phone.completeNumber);
},
onCountryChanged: (phone) {
print('Country code changed to: ' + phone.countryCode);
},
),
So am I doing anything wrong?
There is no limitation in how many characters the user can input maxLength must be provided.
code
IntlPhoneField(
decoration: InputDecoration(
hintText: "Phone Number",
hintStyle: TextStyle(color: Colors.grey[600], fontWeight: FontWeight.bold),
filled: true,
fillColor: Colors.white,
border: OutlineInputBorder(
borderSide: BorderSide(),
),
),
style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black),
initialCountryCode: 'BD',
onChanged: (phone) {
setState(() {
UserData.phone = phone.completeNumber;
});
print(phone.completeNumber);
},
),
Hello guys, thank you for the useful widget.
Do you plan to integrate a trigger for onChange event? I think it'll be good improvement since currently if the user enters the number and after that changes the flag the last triggered onChange event will be with the previous selected flag.
If you select Qatar and then input the number it allows 10 characters when actually they should be 8.
Please fix this, this issue is also common with many other country lengths.
The maximum characters for phone number of Togo is 7 but the real number is 8. Hope it will be set up very soon. Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.