country_geocode_picker 0.0.3 copy "country_geocode_picker: ^0.0.3" to clipboard
country_geocode_picker: ^0.0.3 copied to clipboard

A searchable country picker and phone number field for Flutter, with flags, dial codes, and a bundled 200+ country dataset. No network calls required.

example/lib/main.dart

import 'package:country_geocode_picker/country_geocode_picker.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'country_geocode_picker example',
      theme: ThemeData(colorSchemeSeed: Colors.deepPurple, useMaterial3: true),
      home: const ExamplePage(),
    );
  }
}

class ExamplePage extends StatefulWidget {
  const ExamplePage({super.key});

  @override
  State<ExamplePage> createState() => _ExamplePageState();
}

class _ExamplePageState extends State<ExamplePage> {
  Country? _dropdownCountry;
  PhoneNumberValue? _phoneValue;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('country_geocode_picker')),
      body: ListView(
        padding: const EdgeInsets.all(16),
        children: [
          const Text(
            'Country dropdown',
            style: TextStyle(fontWeight: FontWeight.bold),
          ),
          const SizedBox(height: 8),
          CountryDropdown(
            favoriteCountryCodes: const ['NP', 'IN', 'US'],
            decoration: const InputDecoration(
              border: OutlineInputBorder(),
              labelText: 'Country',
            ),
            showDialCode: true,
            onChanged: (country) => setState(() => _dropdownCountry = country),
          ),
          if (_dropdownCountry != null) ...[
            const SizedBox(height: 8),
            Text(
              'Selected: ${_dropdownCountry!.name} '
              '(${_dropdownCountry!.dialCode})',
            ),
          ],
          const SizedBox(height: 24),
          const Text(
            'Phone number field',
            style: TextStyle(fontWeight: FontWeight.bold),
          ),
          const SizedBox(height: 8),
          CountryCodePhoneField(
            favoriteCountryCodes: const ['NP', 'IN', 'US'],
            decoration: const InputDecoration(
              border: OutlineInputBorder(),
              hintText: 'Phone number',
            ),
            onChanged: (value) => setState(() => _phoneValue = value),
          ),
          if (_phoneValue != null) ...[
            const SizedBox(height: 8),
            Text('E.164: ${_phoneValue!.e164}'),
          ],
        ],
      ),
    );
  }
}
0
likes
155
points
63
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A searchable country picker and phone number field for Flutter, with flags, dial codes, and a bundled 200+ country dataset. No network calls required.

Repository (GitHub)
View/report issues

Topics

#country-picker #phone-field #dial-code #flags #i18n

License

MIT (license)

Dependencies

flutter

More

Packages that depend on country_geocode_picker