-
Notifications
You must be signed in to change notification settings - Fork 476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I can not choose a country #37
Comments
@illiashvedov the package seems to work well on my end could you pls provide more information |
Hi @natintosh import 'package:flutter/material.dart';
import 'package:intl_phone_number_input/intl_phone_number_input.dart';
import 'package:my_project/assets/colors/colors.dart';
import 'package:my_project/localizations.dart';
import 'package:my_project/widgets/phone_number_input/const.dart';
class PhoneNumberInput extends StatefulWidget {
PhoneNumberInput({
Key key,
@required this.focusNode,
@required this.onSubmit,
@required this.onInputChanged,
this.inputDecoration,
this.hintText,
this.keyboardAction = TextInputAction.next,
this.phoneNumber,
this.autoValidate = false,
TextStyle textStyle,
TextEditingController textEditingController,
}) : assert(focusNode != null),
assert(onSubmit != null),
assert(onInputChanged != null),
textStyle = textStyle ?? TextStyle(fontSize: 20, color: greyColor),
textEditingController =
textEditingController ?? TextEditingController(),
super(key: key);
final FocusNode focusNode;
final VoidCallback onSubmit;
final ValueChanged<String> onInputChanged;
final InputDecoration inputDecoration;
final TextStyle textStyle;
final String hintText;
final String phoneNumber;
final TextInputAction keyboardAction;
final TextEditingController textEditingController;
final bool autoValidate;
@override
_PhoneNumberInputState createState() => _PhoneNumberInputState();
}
class _PhoneNumberInputState extends State<PhoneNumberInput> {
PhoneNumber _initialPhoneNumber;
@override
void initState() {
if (widget.phoneNumber != null) {
_parsablePhoneNumber(widget.phoneNumber);
}
super.initState();
}
Future _parsablePhoneNumber(String phoneNumber) async {
if (phoneNumber.isNotEmpty) {
PhoneNumber numberRegionInfo =
await PhoneNumber.getRegionInfoFromPhoneNumber(phoneNumber);
setState(() {
_initialPhoneNumber = numberRegionInfo;
});
}
}
@override
Widget build(BuildContext context) {
final local = CarWashLocalizations.of(context);
return InternationalPhoneNumberInput(
textFieldController: widget.textEditingController,
countries: countries,
textStyle: widget.textStyle,
hintText: widget.hintText,
errorMessage: local.invalidPhoneNumber,
keyboardAction: widget.keyboardAction,
initialValue: _initialPhoneNumber,
selectorType: PhoneInputSelectorType.DIALOG,
inputDecoration: widget.inputDecoration,
onInputChanged: _onInputChanged,
ignoreBlank: true,
focusNode: widget.focusNode,
onSubmit: widget.onSubmit,
autoValidate: widget.autoValidate,
);
}
void _onInputChanged(PhoneNumber phoneNumber) =>
widget.onInputChanged(phoneNumber.phoneNumber);
} As you can see, I have a wrapper for your class, it is possible that it will explicitly null as the value passed to your class, after null gets there I cannot change the country, and also I can`t enter any values. I don’t exclude that I can do something wrong |
Oh please forgive me, because I just realized that this is my personal problem with my project, I just made a new project and this problem did not reproduce, I apologize for the extra nerves |
In the last update I can not choose another country
The text was updated successfully, but these errors were encountered: