Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

get full phone number from intl_phone_field package

I want to get full number from IntlPhoneField (package intl_phone_field )

I use controller to get number. but it not includes country code,

        IntlPhoneField(
                    disableLengthCheck: true,
                    controller: phoneNumberCon,
                    decoration: InputDecoration(
                      hintText: 'Phone Number',
                    ),
        ),

I tried,

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

            String input = phoneNumberCon.text.trim();
            String finalone = "${phone.countrycode} + $input";

It not working because phone.countrycode is not working.

>Solution :

You can use onChanged method and try to pass out its value like this, First define new variable like this:

String fullPhone = '';

then try this:

IntlPhoneField(
   disableLengthCheck: true,
   controller: phoneNumberCon,
   decoration: InputDecoration(
       hintText: 'Phone Number',
   ),
   onChanged: (phone) {
      print(phone.completeNumber);
      setState(() {
         fullPhone = phone.completeNumber;
      });
   },
),
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading