country_selector_widget 0.0.2 copy "country_selector_widget: ^0.0.2" to clipboard
country_selector_widget: ^0.0.2 copied to clipboard

outdated

This Country Selector UI Library written by Dart and Fluter and supports three locales with country's name, achieves lazy loading, and country card animation on listview. This UI Library provides Coun [...]

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:country_selector_widget/country_selector.dart';

void main() {
  runApp(
    MaterialApp(
      title: 'Country Selector Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const App(title: 'Country Selector Demo Page'),
    ),
  );
}

class App extends StatelessWidget {
  const App({super.key, required this.title});
  final String title;

  Future<void> showSuccessDialog(
    BuildContext context,
    Country country,
  ) async {
    await showDialog(
      context: context,
      builder: (context) {
        return AlertDialog(
          title: const Text(
            '[onSelectedCountry]',
            style: TextStyle(
              fontWeight: FontWeight.bold,
            ),
          ),
          content: Text('${country.toJson()}'),
          actions: <Widget>[
            TextButton(
              onPressed: () => Navigator.pop(context),
              child: const Text(
                'Close',
                style: TextStyle(
                  fontWeight: FontWeight.bold,
                ),
              ),
            ),
          ],
        );
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.white,
        centerTitle: true,
        title: const Text(
          "Country Selector Widget",
          style: TextStyle(
            color: Colors.black,
          ),
        ),
        actions: [
          GestureDetector(
            onTap: () async {
              // show country selector bottom sheet widget
              await showCountrySelectorBottomSheet(
                context: context,
                // callback of the selected country
                onSelectedCountry: (country) async {
                  // dialog to show the info of the country object
                  await showSuccessDialog(
                    context,
                    country,
                  );
                },
              );
            },
            child: Center(
              child: Container(
                margin: const EdgeInsets.symmetric(horizontal: 10.0),
                padding: const EdgeInsets.symmetric(
                  vertical: 10.0,
                  horizontal: 10.5,
                ),
                color: Colors.grey.shade200,
                child: const Text(
                  "showBottomSheet",
                  style: TextStyle(
                    color: Colors.black,
                    fontWeight: FontWeight.bold,
                  ),
                ),
              ),
            ),
          )
        ],
      ),
      body: CountrySelectorWidget(
        //  select the Chinese locale to label the text rather than English
        selectedLocale: SelectedLocale.zhCH,
        // callback of the selected country
        onSelectedCountry: (country) async {
          // dialog to show the info of the country object
          await showSuccessDialog(
            context,
            country,
          );
        },
      ),
    );
  }
}
3
likes
0
pub points
1%
popularity

Publisher

unverified uploader

This Country Selector UI Library written by Dart and Fluter and supports three locales with country's name, achieves lazy loading, and country card animation on listview. This UI Library provides CountrySelectorWidget and showCountrySelectorBottomSheet to fulfill the needed usage.

Homepage

License

unknown (license)

Dependencies

flutter

More

Packages that depend on country_selector_widget