intelligentsia_forms 1.0.0
intelligentsia_forms: ^1.0.0 copied to clipboard
A Flutter package for customizable Forms (Email, gender, counrty, etc..).
CountrySelector Component #
The CountrySelector component is a Flutter widget that enables users to select a country from a list. It displays the
selected country's name and flag and can also show an information message via a Flushbar notification.
Features #
-
Allows users to select a country and returns the country name, code, and flag.
-
Customizable appearance, including colors, icons, borders, and padding.
-
Optional Flushbar notification for displaying additional information to users.
Installation #
Add the package containing CountrySelector to your pubspec.yaml:
dependencies:
intelligentsia_forms: 1.0.0
Usage #
import 'package:intelligentsia_forms/country_selector.dart';
CountrySelector(
onCountrySelected: (countryName, countryCode, countryFlag) {
print("Selected country: $countryName, Code: $countryCode, Flag: $countryFlag");
},
fieldName: "Choose Your Country",
primaryColor: Colors.blue,
fillColor: Colors.white,
iconColor: Colors.blue,
flushBarMessage: "Select carefully, this can't be changed later.",
);
Constructor Parameters #
| Parameter | Type | Description | Default Value |
|---|---|---|---|
onCountrySelected |
Function(String, String, String) |
Callback function invoked when a country is selected. Provides countryName, countryCode, and countryFlag. |
** |
| Required** | |||
fieldName |
String |
The label text displayed above the country selector field. | "Country" |
fieldNameColor |
Color? |
Color of the fieldName text. Uses primaryColor if not specified. |
null |
fieldFontSize |
double |
Font size of the fieldName text. |
15 |
fieldFontWeight |
FontWeight |
Font weight of the fieldName text. |
FontWeight.w500 |
iconColor |
Color? |
Color for the prefix and suffix icons. Uses primaryColor if not specified. |
null |
iconSize |
double |
Size of the icons (prefix and suffix). | 20 |
showInfoSuffixIcon |
bool |
Whether to display an information icon on the right side of the field. | true |
outlinedIcon |
bool |
If true, displays outlined icons. | false |
showFlushBar |
bool |
If true, displays a Flushbar message when the info icon is tapped. |
true |
flushBarMessage |
String |
Message displayed in the Flushbar. |
"You can select a country now. Once your account is created, the country cannot be changed." |
flushBarDurationMessageInSec |
int |
Duration (in seconds) that the Flushbar message is displayed. |
3 |
flushBarPosition |
FlushbarPosition |
Position of the Flushbar on the screen (FlushbarPosition.TOP or FlushbarPosition.BOTTOM). |
FlushbarPosition.TOP |
primaryColor |
Color |
Main color for the widget (used in text, borders, and icons). | ThemeColors.primary |
fillColor |
Color |
Background color of the country selector field. | ThemeColors.backgroundColor |
borderRadius |
BorderRadius |
Border radius for the country selector field. | BorderRadius.circular(10) |
outsidePadding |
EdgeInsets |
Padding outside the country selector field. | EdgeInsets.symmetric(vertical: 0, horizontal: 16) |
insidePadding |
EdgeInsets |
Padding inside the country selector field. | EdgeInsets.only(right: 0, left: 15, top: 10, bottom: 10) |
borderStyle |
BoxBorder? |
Custom border style for the field. Uses a default border with primaryColor if not specified. |
null |
Methods #
onCountrySelected #
This callback function is triggered when a country is selected, and it provides:
- countryName:
String- The name of the selected country. - countryCode:
String- The ISO country code of the selected country. - countryFlag:
String- Emoji representation of the selected country’s flag.
Example #
CountrySelector(
onCountrySelected: (countryName, countryCode, countryFlag) {
print("Country selected: $countryName, Code: $countryCode, Flag: $countryFlag");
},
fieldName: "Select Country",
primaryColor: Colors.blue,
showFlushBar: true,
flushBarMessage: "Choose your country carefully.",
);
Note #
The CountrySelector widget uses the Flushbar package for displaying notifications. Ensure the another_flushbar
dependency is added to your project.
ThemeColors is a custom color class. Replace it with your app's color theme as needed.
Dependencies #
dependencies:
flutter:
sdk: flutter
another_flushbar: ^1.10.0
country_picker: ^2.0.9