Comments (6)
@natintosh I see a similar error when I set autovalidate to true:
InternationalPhoneNumberInput(
countries: ["GB"],
initialValue: initialPhoneNumber,
ignoreBlank: true,
autoValidate: true,
textFieldController: controller,
inputBorder: OutlineInputBorder(),
selectorType: PhoneInputSelectorType.BOTTOM_SHEET,
),
I get an error saying setState() or markNeedsBuild called during build...
if I turn autovalidate off then I don't see the error?!
from intl_phone_number_input.
Hi @ISimplifyComplexity I published a fixed to this issue thanks for bringing this up
from intl_phone_number_input.
@b02505048 thanks for raising this issue. I have been unable to reproduce this issue and it seems to work fine at my end, but the cause of this is an external dependency that throws an exception when this is not true
if (!isViablePhoneNumber(nationalNumber)) {
throw new NumberParseException(NumberParseException.ErrorType.NOT_A_NUMBER,
"The string supplied did not seem to be a phone number.");
}
/**
* Checks to see if the string of characters could possibly be a phone number at all. At the
* moment, checks to see that the string begins with at least 2 digits, ignoring any punctuation
* commonly found in phone numbers.
* This method does not require the number to be normalized in advance - but does assume that
* leading non-number symbols have been removed, such as by the method extractPossibleNumber.
*
* @param number string to be checked for viability as a phone number
* @return true if the number could be a phone number of some sort, otherwise false
*/
// @VisibleForTesting
static boolean isViablePhoneNumber(CharSequence number) {
if (number.length() < MIN_LENGTH_FOR_NSN) {
return false;
}
Matcher m = VALID_PHONE_NUMBER_PATTERN.matcher(number);
return m.matches();
}
from intl_phone_number_input.
@natintosh Thanks for replying. Could we do the phone number validation outside the InternationalPhoneNumberInput
?
I think this error message would occur when the user is typing the first digit number since isViablePhoneNumber
function must have at least 2 digits?
from intl_phone_number_input.
Thanks for suggesting this, I will consider it for the next major update, but its chances are low.
from intl_phone_number_input.
Hello, I'm still having an issue with setState() inside onInputValidated().
When I tap the input area (to open the keyboard), I get this
W/IInputConnectionWrapper(24974): getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper(24974): getSelectedText on inactive InputConnection
W/IInputConnectionWrapper(24974): getTextAfterCursor on inactive InputConnection
W/IInputConnectionWrapper(24974): getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper(24974): getSelectedText on inactive InputConnection
W/IInputConnectionWrapper(24974): getTextAfterCursor on inactive InputConnection
Then when I type a 0 I get this
I/flutter (24974): +330
E/flutter (24974): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(NumberParseException, The string supplied is too short to be a phone number., null)
E/flutter (24974): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
E/flutter (24974): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33)
E/flutter (24974): <asynchronous suspension>
E/flutter (24974): #2 PhoneNumberUtil.getRegionInfo (package:libphonenumber/libphonenumber.dart:61:51)
E/flutter (24974): #3 PhoneNumber.getRegionInfoFromPhoneNumber (package:intl_phone_number_input/src/utils/phone_number.dart:41:51)
E/flutter (24974): #4 PhoneNumber.getParsableNumber (package:intl_phone_number_input/src/utils/phone_number.dart:60:34)
E/flutter (24974): #5 _InputWidgetState.initialiseWidget (package:intl_phone_number_input/src/widgets/input_widget.dart:262:31)
E/flutter (24974): #6 _InputWidgetState.didUpdateWidget (package:intl_phone_number_input/src/widgets/input_widget.dart:251:7)
E/flutter (24974): #7 StatefulElement.update (package:flutter/src/widgets/framework.dart:4396:58)
E/flutter (24974): #8 Element.updateChild (package:flutter/src/widgets/framework.dart:2977:15)
E/flutter (24974): #9 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5161:32)
E/flutter (24974): #10 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5561:17)
E/flutter (24974): #11 Element.updateChild (package:flutter/src/widgets/framework.dart:2977:15)
E/flutter (24974): #12 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5452:14)
E/flutter (24974): #13 Element.updateChild (package:flutter/src/widgets/framework.dart:2977:15)
E/flutter (24974): #14 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
E/flutter (24974): #15 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
E/flutter (24974): #16 StatelessElement.update (package:flutter/src/widgets/framework.dart:4298:5)
E/flutter (24974): #17 Element.updateChild (package:flutter/src/widgets/framework.dart:2977:15)
E/flutter (24974): #18 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
E/flutter (24974): #19 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
E/flutter (24974): #20 ProxyElement.update (package:flutter/src/widgets/framework.dart:4557:5)
E/flutter (24974): #21 Element.updateChild (package:flutter/src/widgets/framework.dart:2977:15)
E/flutter (24974): #22 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
E/flutter (24974): #23 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
E/flutter (24974): #24 ProxyElement.update (package:flutter/src/widgets/framework.dart:4557:5)
E/flutter (24974): #25 Element.updateChild (package:flutter/src/widgets/framework.dart:2977:15)
E/flutter (24974): #26 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5161:32)
E/flutter (24974): #27 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5561:17)
E/flutter (24974): #28 Element.updateChild (package:flutter/src/widgets/framework.dart:2977:15)
E/flutter (24974): #29 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
E/flutter (24974): #30 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
E/flutter (24974): #31 StatefulElement.update (package:flutter/src/widgets/framework.dart:4413:5)
E/flutter (24974): #32 Element.updateChild (package:flutter/src/widgets/framework.dart:2977:15)
E/flutter (24974): #33 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
E/flutter (24974): #34 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
E/flutter (24974): #35 ProxyElement.update (package:flutter/src/widgets/framework.dart:4557:5)
E/flutter (24974): #36 Element.updateChild (package:flutter/src/widgets/framework.dart:2977:15)
E/flutter (24974): #37 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
E/flutter (24974): #38 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
E/flutter (24974): #39 StatefulElement.update (package:flutter/src/widgets/framework.dart:4413:5)
E/flutter (24974): #40 Element.updateChild (package:flutter/src/widgets/framework.dart:2977:15)
E/flutter (24974): #41 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5452:14)
E/flutter (24974): #42 Element.updateChild (package:flutter/src/widgets/framework.dart:2977:15)
E/flutter (24974): #43 ComponentElement.performRebuild (package:flutter/src/widge
And if then I type any other number, onInputChange() goes into infinite loop and I can't type anything else anymore.
I'm using version ^0.4.6+2, which I think is the version that includes the fix to the original issue of this topic.
Btw, these are my parameters, in case it helps reproduce the error
InternationalPhoneNumberInput(
onInputChanged: (PhoneNumber number) {
this.number = number;
print(this.number.phoneNumber); //TODO: remove this line
},
onInputValidated: (bool value) {
setState(() {
// activate/deactivate the Done button
isDoneEnabled = value;
});
},
ignoreBlank: true,
autoValidate: true,
textStyle: TextStyle(fontSize: 20.0),
selectorTextStyle: TextStyle(color: Colors.black, fontSize: 20.0),
initialValue: number,
textFieldController: controller,
hintText: 'your phone number',
),
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.