CountryPicker class

A widget that displays a searchable list of countries with their flags and calling codes.

This widget is the core UI component of the country_calling_code_kit package. It displays a list of countries with their flags, names, and optionally their calling codes. It also provides a search functionality to filter countries.

The widget attempts to determine the user's country based on the device's SIM card and displays it at the top of the list. It also supports displaying a list of preferred countries at the top.

This widget is used by showCountryPickerDialog and showCountryPickerModalSheet to provide a consistent UI for country selection.

Inheritance

Constructors

CountryPicker.new({Key? key, required ValueChanged<Country> onSelected, TextStyle? countryNameTextStyle, TextStyle? countryCallCodeTextStyle, Size? imageSize, List<Country> searchFilter(String text)?, Color? splashColor, Color? hoverColor, List<CountryCode>? preferredCountries, bool showCallCode = false, bool search = true})
Creates a new CountryPicker widget.
const

Properties

countryCallCodeTextStyle TextStyle?
Custom text style for country calling codes.
final
countryNameTextStyle TextStyle?
Custom text style for country names.
final
hashCode int
The hash code for this object.
no setterinherited
hoverColor Color?
Custom hover color for items (on web/desktop).
final
imageSize Size?
Custom size for flag images.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onSelected ValueChanged<Country>
Callback that is called when a country is selected.
final
preferredCountries List<CountryCode>?
List of country codes to display at the top of the list.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
Whether to show the search bar.
final
searchFilter List<Country> Function(String text)?
Custom function for filtering countries during search.
final
showCallCode bool
Whether to show calling codes next to country names.
final
splashColor Color?
Custom splash color for item selection.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<CountryPicker>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited