cupertino_country_picker 1.0.2 copy "cupertino_country_picker: ^1.0.2" to clipboard
cupertino_country_picker: ^1.0.2 copied to clipboard

An iOS-style country picker with flags, dial codes, and search—ideal for phone inputs and region selection in Flutter apps.

example/lib/main.dart

import 'package:cupertino_country_picker/cupertino_country_picker.dart';
import 'package:cupertino_country_picker/helper/country_picker_helper.dart' show CountryPickerHelper;
import 'package:cupertino_country_picker/model/country_model.dart' show CountryModel;
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(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(brightness: Brightness.dark),
      home: const HomePage(),
    );
  }
}

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

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  CountryModel? selectedCountry;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: false,
      appBar: AppBar(
        centerTitle: true,
        automaticallyImplyLeading: false,
        title: const Text(
          'Country Picker Example',
          style: TextStyle(fontSize: 18),
        ),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            if (selectedCountry != null) ...[
              ClipRRect(
                borderRadius: BorderRadius.circular(10),
                child: Image.asset(
                  selectedCountry!.flag,
                  package: CountryPickerHelper.packageName,
                  height: 50,
                ),
              ),
              const SizedBox(height: 10),
              Text(
                'Selected Country: ${selectedCountry!.name}',
                style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
                textAlign: TextAlign.center,
              ),
              Text(
                'Calling Code: ${selectedCountry!.callingCode}',
                textAlign: TextAlign.center,
              ),
              Text(
                'Country Code: ${selectedCountry!.countryCode}',
                textAlign: TextAlign.center,
              ),
              const SizedBox(height: 10),
            ],
            ElevatedButton(
              onPressed: toggleButton,
              style: ButtonStyle(
                backgroundColor: WidgetStatePropertyAll(Colors.blue),
                shape: WidgetStatePropertyAll(RoundedRectangleBorder(borderRadius: BorderRadius.circular(10))),
              ),
              child: Text(
                'Open Country Picker',
                style: TextStyle(color: Colors.white),
              ),
            ),
          ],
        ),
      ),
    );
  }

  Future<void> toggleButton() async {
    await showCupertinoCountryPicker(
      context: context,
      onCountryPicked: (country) {
        setState(() {
          selectedCountry = country;
        });
      },
    );
  }
}
3
likes
0
points
21
downloads

Publisher

unverified uploader

Weekly Downloads

An iOS-style country picker with flags, dial codes, and search—ideal for phone inputs and region selection in Flutter apps.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, simple_animations, supercharged

More

Packages that depend on cupertino_country_picker