Search code examples
flutterdartmobile-application

How do I add a country code dropbox in a login page in flutter?


I am trying to add a country code drop box in a login page with the mobile number ,but it is showing some or the other errors .I need an easy approach to add country code drop box with phone number


Solution

  • Add this to the pubspec.yaml in the dependencies:

        intl_phone_field: ^3.0.1
    

    Import the following package:

       import 'package:intl_phone_field/intl_phone_field.dart';
    

    Add this code:

        IntlPhoneField(
        decoration: InputDecoration(
        labelText: 'Phone Number',
        border: OutlineInputBorder(
            borderSide: BorderSide(),
        ),
    ),
    initialCountryCode: 'IN',
    onChanged: (phone) {
        print(phone.completeNumber);
    },
    

    )