fl_country_code_picker 0.0.3+1
fl_country_code_picker: ^0.0.3+1 copied to clipboard
A Flutter package for showing a modal that contains country dial code. The user can also search for the available codes and select right from the modal.
fl_country_code_picker #
A Flutter package for showing a modal that contains country dial code. The user can also search for the available codes and select right from the modal.
Flutter Country Code Picker #
Disclaimer, this idea originally came from: country_code_picker package.
With this package you can show a country code selector and manipulate the selected CountryCode model.
π¨ Installation #
dependencies:
fl_country_code_picker: ^0.0.1
β Import #
import 'package:fl_country_code_picker/fl_country_code_picker.dart';
πΉοΈ Usage #
Instantiate FlCountryCodePicker to access the functionality and properties.
You can also pass some optional parameters to customize the picker's view.
final countryPicker = const FlCountryCodePicker();
GestureDetector(
onTap: () async {
final code = await countryPicker.showPicker(context: context);
if (code != null) print(code);
},
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 8.0, vertical: 4.0),
margin: const EdgeInsets.symmetric(horizontal: 8.0),
decoration: const BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.all(Radius.circular(5.0))),
child: Text('Show Picker',
style: const TextStyle(color: Colors.white)),
),
),
FlCountryCodePicker #
FlCountryCodePicker class contains all of the functionalities of this package. This contains (optional) properties that can be supply to achieve some customization at the picker's view.
| Fields | Type | Description |
|---|---|---|
| favorites | List | Favorite countries that can be shown at the top of the list. Should supply the 2 character ISO code of the country e.g. ['US', 'PH', 'AU'] |
| filteredCountries | List | Filters all of the [CountryCode]s available and only show the codes that are existing in this list. Should supply the 2 character ISO code of the country e.g. ['US', 'PH', 'AU'] |
| favoritesIcon | Icon | Custom icon of favorite countries. Defaults to Icons.favorite |
| showSearchBar | bool | Property for showing search bar. Defaults to true. |
showPicker #
showPicker method under FlCountryCodePicker class can be used to show a country code picker.
| Fields | Type | Description |
|---|---|---|
| context | BuildContext | A handle to the location of a widget in the widget tree. Required. |
| isFullScreen | bool | Shows the modal in full screen mode. Defaults to false. |
| pickerMinHeight | double | Picker modal constraints for minimum height. Defaults to 150. |
| pickerMaxHeight | double | Picker modal constraints for maximum height. Defaults to 500. |
| scrollToDeviceLocale | bool | Property to automatically scroll at device's locale within the picker. Defaults to false. |
| initialSelectedLocale | String? | The 2 character ISO code of the country where the scrollController will automatically scroll to. |
CountryCode #
CountryCode model can be used to manipulate the selected country code by the user.
| Fields | Type | Description |
|---|---|---|
| name | String | The name of the country |
| code | String | The 2 character ISO code of the country |
| dialCode | String | The country dial code. By convention, international telephone numbers are represented by prefixing the country code with a plus sign (+). e.g. +1 for US |
| flagImage | Widget | Widget that can be used on retrieving the selected country flag's image. |
Examples #
| Example View | Preview (from package's example folder) |
|---|---|
| Default Picker View | ![]() |
| Picker with Favorites | ![]() |
| Picker with Filter | ![]() |
| Picker with Filter | ![]() |
π Bugs/Requests #
If you encounter any problems feel open an issue. If you feel the library is missing a feature, please raise a ticket on Github and we'll look into it. Pull request are also welcome.
π License #
MIT License



