natintosh / intl_phone_number_input

MIT License
166 stars 510 forks source link

Country Picker resetting to initial value #288

Open iamngoni opened 2 years ago

iamngoni commented 2 years ago

Describe the bug After changing country the country picker immediately resets to the set initial value

Package version ^0.7.0+2

Flutter version 2.5.1

To Reproduce Steps to reproduce the behavior:

  1. Code Snippet
Container(
                                    padding: EdgeInsets.symmetric(
                                      horizontal: sx(20),
                                    ),
                                    decoration: BoxDecoration(
                                      color: Colors.transparent,
                                      borderRadius: BorderRadius.circular(7.0),
                                      border: Border.all(
                                        color: TumaiColors.TUMAI_TEXT_BLUE,
                                      ),
                                    ),
                                    child: InternationalPhoneNumberInput(
                                      key: phoneNumberKey,
                                      initialValue: PhoneNumber(
                                        isoCode: "ZW",
                                      ),
                                      textFieldController:
                                          phoneNumberController,
                                      onInputChanged: (PhoneNumber phone) {
                                        print("changed");
                                        phoneNumber = phone.phoneNumber!;
                                      },
                                      textStyle: TextStyle(
                                        color: Colors.black,
                                      ),
                                      inputDecoration: InputDecoration(
                                        border: InputBorder.none,
                                        errorBorder: InputBorder.none,
                                        focusedBorder: InputBorder.none,
                                        enabledBorder: InputBorder.none,
                                        disabledBorder: InputBorder.none,
                                        focusedErrorBorder: InputBorder.none,
                                        hintText: "Phone Number",
                                        hintStyle: TextStyle(
                                          color: TumaiColors.TUMAI_TEXT_NAVY,
                                          fontSize: sy(9),
                                        ),
                                        errorStyle: textFieldErrorStyle,
                                      ),
                                      keyboardType: TextInputType.phone,
                                      autoValidateMode:
                                          AutovalidateMode.onUserInteraction,
                                      selectorTextStyle: TextStyle(
                                        color: TumaiColors
                                            .TUMAI_PRIMARY_COLOR_LIGHT,
                                        fontWeight: FontWeight.bold,
                                        fontSize: sy(9),
                                      ),
                                      selectorConfig: SelectorConfig(
                                        selectorType:
                                            PhoneInputSelectorType.DIALOG,
                                        showFlags: true,
                                        useEmoji: false,
                                        setSelectorButtonAsPrefixIcon: false,
                                      ),
                                    ),
                                  ),

Expected behavior Expecting the country to change - I can change the country without using the textfield but once the textfield gets active it resets

Screenshots

untitled

Targeted platforms (please complete the following information):

chris-otani commented 2 years ago

I'm experiencing the exact same problem.

l00ai commented 2 years ago

me too

Justus-M commented 2 years ago

Any fix for this?

DaviSonego commented 2 years ago

I was having the same issue, and the way i solved this is by attributing the initial value to a variable, this solved the problem.

image

image

iamngoni commented 2 years ago

Thanks let me try that

Ngonidzashe Mangudya | IAMNGONI

On Wed, Mar 23, 2022 at 2:59 PM DaviSonego @.***> wrote:

I was having the same issue, and the way i solved this is by attributing the initial value to a variable, this solved the problem.

[image: image] https://user-images.githubusercontent.com/102232156/159704701-a2e3e8e9-12b8-4910-9b4c-36c730a91333.png

[image: image] https://user-images.githubusercontent.com/102232156/159704763-2eb27632-503c-4a72-b564-be95392f623c.png

— Reply to this email directly, view it on GitHub https://github.com/natintosh/intl_phone_number_input/issues/288#issuecomment-1076347112, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJDMGPGXIS5JRPBUYMLHK4LVBMIS7ANCNFSM5I2FGCYA . You are receiving this because you authored the thread.Message ID: @.***>

jamt0 commented 2 years ago

I think te problem is with the onInputChanged , I remove this, and the problem fix, i dont kwon why

jamt0 commented 2 years ago

I was having the same issue, and the way i solved this is by attributing the initial value to a variable, this solved the problem.

image

image

This works for me!

koorosh-k98 commented 1 year ago

I was having the same issue, and the way i solved this is by attributing the initial value to a variable, this solved the problem.

image

image

This works for me. Thank you.