show_country_picker_flutter 1.0.0 copy "show_country_picker_flutter: ^1.0.0" to clipboard
show_country_picker_flutter: ^1.0.0 copied to clipboard

show_country_picker_flutter is a customizable Flutter package that provides an easy-to-use country code picker. It enables users to select countries and their respective codes from a predefined list, [...]

example/lib/main.dart

import 'dart:developer';

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

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

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  late TextEditingController textEditingController;
  late FocusNode focusNode;
  @override
  void initState() {
    super.initState();
    textEditingController = TextEditingController();
    focusNode = FocusNode();
  }

  @override
  void dispose() {
    textEditingController.dispose();
    focusNode.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: openCountryWidget(),
      ),
    );
  }

  Widget openCountryWidget() {
    return GestureDetector(
      onTap: () => showModalBottomSheet(
        context: context,
        builder: (context) {
          return ShowCountryPickerFlutter(
            textEditingController: textEditingController,
            focusNode: focusNode,
            onTap: (Map<String, dynamic> countryDetail) =>
                log(countryDetail.toString()),
            // isDisplayDialCode: true,
          );
        },
      ),
      child: Container(
        width: 150,
        height: 40,
        decoration: BoxDecoration(
          color: Colors.red,
          borderRadius: BorderRadius.circular(12),
        ),
        alignment: Alignment.center,
        child: const Text(
          "Open Country List",
          style: TextStyle(color: Colors.white),
        ),
      ),
    );
  }
}
3
likes
125
points
12
downloads

Publisher

verified publishercagatayoney.com

Weekly Downloads

show_country_picker_flutter is a customizable Flutter package that provides an easy-to-use country code picker. It enables users to select countries and their respective codes from a predefined list, perfect for integrating into profile creation, registration forms, and more. With smooth animations and a user-friendly interface, this package enhances the user experience by providing a seamless way to choose country codes.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on show_country_picker_flutter