flutter_simple_country_picker 0.2.1 flutter_simple_country_picker: ^0.2.1 copied to clipboard
The Flutter package that provides an easy-to-use country selection widget. It allows users to select a country from a comprehensive list of countries, making it simple to integrate country picking fun [...]
flutter_simple_country_picker #
Description #
The Flutter package that provides an easy-to-use country selection widget. It allows users to select a country from a comprehensive list of countries, making it simple to integrate country picking functionality into your Flutter applications. The package supports Android, iOS, and web platforms, and offers customization options for fonts and styles.
Getting Started #
Add the package to your pubspec.yaml:
flutter_simple_country_picker: <version>
Installation #
In your dart file, import the library:
import 'package:flutter_simple_country_picker/flutter_simple_country_picker.dart';
Example #
Add the CountriesLocalization.delegate
in the list of your app delegates. Set supported locales [Locale('ru'), Locale('en')]. And set your locale ru
or en
.
MaterialApp(
locale: const Locale('ru'), // Locale('en'),
supportedLocales: const <Locale>[
Locale('ru'),
Locale('en'),
],
localizationsDelegates: [
GlobalCupertinoLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
/// Add [CountriesLocalization] in app [localizationsDelegates]
CountriesLocalization.delegate,
],
home: HomePage(),
);
Example usage of the showCountryPicker
function:
showCountryPicker(
context: context,
exclude: ['RU', 'EN'],
onDone: () {
print('CountryPicker dismissed');
},
onSelect: (Country country) {
print('Selected country: ${country.displayName}');
},
);
Optional argumets of the showCountryPicker
function:
Argument | Description |
---|---|
exclude |
List of countries to exclude from the list. |
filter |
List of countries to filter the list. |
favorite |
List of countries to show at the top of the list. |
showPhoneCode |
Displays the phone code before the country name. |
showWorldWide |
Shows the "World Wide" option at the beginning of the list. |
useAutofocus |
Automatically opens the keyboard when the picker is loaded. |
showSearch |
Enables or disables the search bar. |
isDismissible |
Allows the user to close the modal by swiping it down. |
isScrollControlled |
Controls the scrolling behavior of the modal window. |
useHaptickFeedback |
Enables haptic feedback. |
useSafeArea |
Enables the safe area for the modal window. |
onSelect |
Callback when the select a country. |
onDone |
Callback when the CountryPicker is dismissed, whether a country is selected or not. |
All countries list #
To view a complete list of countries, please refer to the All countries list.
Changelog #
Refer to the Changelog to get all release notes.
Maintainers #
Funding #
If you want to support the development of our library, there are several ways you can do it: