Comments (15)
I'll close the issue now. Please feel free to fork this repo to add new features and bugs or open a new issue if you encounter any problem
from intl_phone_number_input.
Hi guys, I just published a fix to this issue. Thank you so much for your contributions. Cheers ✨
from intl_phone_number_input.
Thanks for pointing that out @ZippyRainbow
from intl_phone_number_input.
I found cause of this issue and fixed it, but I won't be able to publish an update because the fix causes a major bug. I'll still leave this issue opened till I publish a fix, for now try not using setState in onInputChange and pass a final textEditingController field variable into the textFieldController argument
from intl_phone_number_input.
from intl_phone_number_input.
Using a UniqueKey inside a stateless widget is a weird thing to do
You are without a doubt right, I also found it weird, but the issue there is the StatefulWidget it wraps. That widget is notorious for rebuilding itself and assigning a new label key. This behavior is the primary cause of this issue.
replacing with a ObjectKey(SomeClass) can introduce bugs when there are multiple phone input widgets in the same view.
You are also right, this could also introduce a bug with multiple widgets in the same view
from intl_phone_number_input.
I am facing the same error, please some fix this soon.
from intl_phone_number_input.
Hell @usamabse048 @vanshg395 I'm still trying to recreate this issue
Soft keyboard automatically go back
so far I've not been able to do say but note that those logs you see are Android generated logs.
from intl_phone_number_input.
I am facing the same error...
getting:
E/AccessibilityBridge( 1542): VirtualView node must not be the root node.
E/flutter ( 1542): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(NumberParseException, The string supplied did not seem to be a phone number., null)
from intl_phone_number_input.
Hi @natintosh
I was able to replicate the problem by adding a setState inside the onChange action, without this the problem doesn't occur.
Sorry, I am new to flutter development and am not familiar with how to create an Andriod Log.
import 'package:flutter/material.dart';
import 'package:intl_phone_number_input/intl_phone_number_input.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
appBar: AppBar(title: Text('Demo')),
body: MyHomePage(),
),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
final TextEditingController controller = TextEditingController();
String initialCountry = 'NG';
PhoneNumber number = PhoneNumber(isoCode: 'NG');
**String textPhoneNumber = '';**
@override
Widget build(BuildContext context) {
return Form(
key: formKey,
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
InternationalPhoneNumberInput(
onInputChanged: (PhoneNumber number) {
print(number.phoneNumber);
**setState(
() => textPhoneNumber = number.phoneNumber);**
},
onInputValidated: (bool value) {
print(value);
},
ignoreBlank: false,
autoValidate: false,
initialValue: number,
textFieldController: controller,
inputBorder: OutlineInputBorder(),
),
RaisedButton(
onPressed: () {
formKey.currentState.validate();
},
child: Text('Validate'),
),
RaisedButton(
onPressed: () {
getPhoneNumber('+15417543010');
},
child: Text('Update'),
),
],
),
),
);
}
void getPhoneNumber(String phoneNumber) async {
PhoneNumber number =
await PhoneNumber.getRegionInfoFromPhoneNumber(phoneNumber, 'US');
setState(() {
this.number = number;
});
}
@override
void dispose() {
controller?.dispose();
super.dispose();
}
}
from intl_phone_number_input.
@natintosh what is this major bug that it causes? I plan to use you git version since "don't use setState in onInputChange" fix does not work for me
from intl_phone_number_input.
It turned out that the problem was with the key, I was using a UniqueKey()
so the widget basic rebuilds every single time setState
is called in onInputChange
before but I've updated that. So with the updated, you can't update the initialValue
your initial value with setState
like as it is in the example but you can use setState in onInputChange
from intl_phone_number_input.
Happens when using inside a flutter_form_builder
custom form field too. I guess it's because flutter_form_builder
rebuilds it on change. Waiting for a fix 😢
from intl_phone_number_input.
It turned out that the problem was with the key, I was using a
UniqueKey()
so the widget basic rebuilds every single timesetState
is called inonInputChange
before but I've updated that. So with the updated, you can't update theinitialValue
your initial value withsetState
like as it is in the example but you can use setState inonInputChange
Using a UniqueKey
inside a stateless widget is a weird thing to do as I can understand because the widget becomes prone to unexpected rebuilds. Could you explain a bit about it's purpose?
Also fixing it by replacing with a ObjectKey(SomeClass)
can introduce bugs when there are multiple phone input widgets in the same view.
Please correct me if I'm wrong on these. Thank you.
from intl_phone_number_input.
Hi guys, I just published a fix to this issue. Thank you so much for your contributions. Cheers ✨
To fix this issue I had to revert back to one of my previous builds that worked, then removed dependencies for providers and removed the StatelessWidget
that nested this input widget
from intl_phone_number_input.
Related Issues (20)
- mobile number is incorrect HOT 2
- Get Phone Detail from contact list
- isoCode: 'MA' validators accept only 06 prefix !
- Allow Usage of ISO Codes Instead of Country Logos in the Leading of Input Field
- Version soloving failed
- Material 3 SubTitle Style is Deprecated . can you please change as per the Material 3 and Make a Release HOT 2
- Change the type of initCountry to String
- validatorMessage doesnt appear if is different of AutovalidateMode.always or doesnt triggered onChanged
- Not compatible with xcode 15 phonenumberkit deployment target 12 HOT 8
- Add Korean Translation Support
- PROJECT STILL ACTIVE?? kindly update please
- Programmatically change selected country code, or fill fields (flag and text input) using PhoneNumber
- selector customization needed HOT 1
- I
- IOS error : Compiling for iOS 11.0, but module 'PhoneNumberKit' has a minimum deployment target of iOS 12.0:
- In IOS, white backgroud while selecting coundtry code
- search dialog need to customize the search field style
- include curaçao
- flag with initial country code width
- Bum js version HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from intl_phone_number_input.