๐Ÿ“ฑ Country Code Picker

Example Screenshot

A lightweight and customizable Flutter package to pick country codes easily. ๐ŸŒ


โœจ Features

  • ๐Ÿ”น Searchable country list (name, ISO, dial code)
  • ๐Ÿ”น Default selection support
  • ๐Ÿ”น Works with TextField or forms
  • ๐Ÿ”น Callback when user selects a country
  • ๐Ÿ”น Emoji flags support ๐Ÿ‡ฎ๐Ÿ‡ณ ๐Ÿ‡บ๐Ÿ‡ธ ๐Ÿ‡ฌ๐Ÿ‡ง
  • ๐Ÿ”น Simple API, no heavy dependencies

๐Ÿš€ Installation

Add the dependency in your pubspec.yaml:

dependencies:
  world_code_picker: ^2.0.0

Run:

flutter pub get

๐Ÿ“– Example

Hereโ€™s a minimal usage example:

import 'package:flutter/material.dart';
import 'package:world_code_picker/country.dart';
import 'package:world_code_picker/world_code_picker.dart';

void main() => runApp(const MyApp());

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Country Code Picker Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: const MyHomePage(),
    );
  }
}

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

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  Country? _selected;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("Country Code Picker")),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            FilledButton.icon(
              icon: const Icon(Icons.flag),
              label: const Text('Pick Country Code'),
              onPressed: () async {
                final result = await showCountryCodePickerBottomSheet(
                  context: context,
                  style: const CountryPickerStyle(
                    sheetTitle: 'Select your country',
                    searchHintText: 'Search country, ISO, or +code',
                    cornerRadius: 20,
                  ),
                );
                if (result != null) {
                  setState(() => _selected = result);
                }
              },
            ),
            const SizedBox(height: 16),
            Text(
              _selected == null
                  ? 'Selected: None'
                  : 'Selected: ${_selected!.flagEmoji} ${_selected!.name} (${_selected!.dialCode})',
              style: Theme.of(context).textTheme.titleMedium,
            ),
          ],
        ),
      ),
    );
  }
}

๐Ÿ“ธ Screenshots

Country Picker Search Feature

โš™๏ธ Parameters

Parameter Type Description
sheetTitle String Title shown at the top of bottom sheet
searchHintText String Placeholder in the search field
cornerRadius double Corner radius of the bottom sheet

๐Ÿค Contributing

Contributions are welcome! ๐ŸŽ‰

  • Open an issue for bugs/feature requests
  • Submit a PR for fixes and improvements

๐Ÿ“„ License

This project is licensed under the MIT License.
See the LICENSE file for details.