Coder Social home page Coder Social logo

Comments (15)

natintosh avatar natintosh commented on July 20, 2024 3

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.

natintosh avatar natintosh commented on July 20, 2024 2

Hi guys, I just published a fix to this issue. Thank you so much for your contributions. Cheers ✨

from intl_phone_number_input.

natintosh avatar natintosh commented on July 20, 2024 1

Thanks for pointing that out @ZippyRainbow

from intl_phone_number_input.

natintosh avatar natintosh commented on July 20, 2024 1

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.

vanshg395 avatar vanshg395 commented on July 20, 2024 1

from intl_phone_number_input.

natintosh avatar natintosh commented on July 20, 2024 1

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.

vanshg395 avatar vanshg395 commented on July 20, 2024

I am facing the same error, please some fix this soon.

from intl_phone_number_input.

natintosh avatar natintosh commented on July 20, 2024

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.

flutter/flutter#9471

https://stackoverflow.com/questions/8122625/getextractedtext-on-inactive-inputconnection-warning-on-android

from intl_phone_number_input.

speroamey avatar speroamey commented on July 20, 2024

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.

ZippyRainbow avatar ZippyRainbow commented on July 20, 2024

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.

tudor07 avatar tudor07 commented on July 20, 2024

@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.

natintosh avatar natintosh commented on July 20, 2024

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.

nipunasudha avatar nipunasudha commented on July 20, 2024

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.

nipunasudha avatar nipunasudha commented on July 20, 2024

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

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.

natintosh avatar natintosh commented on July 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.