CitySearchField class
A searchable text field that searches across all cities for a given country without requiring a pre-selected state. When a city is selected the parent state is resolved automatically.
CitySearchField(
countryIso2: 'US',
onChanged: (result) {
if (result != null) {
print('${result.city.name}, ${result.state.name}');
}
},
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- CitySearchField
Constructors
-
CitySearchField({required String countryIso2, Key? key, int? initialCityId, String? initialCityName, ValueChanged<
CitySearchResult?> ? onChanged, CountrifyFieldStyle? style, GeoPickerTheme? pickerTheme, GeoPickerConfig? pickerConfig, String? placeholder, String? emptyPlaceholder, bool enabled = true, FocusNode? focusNode, GeoRepository? repository}) -
A searchable text field that searches across all cities for a given country
without requiring a pre-selected state. When a city is selected the parent
state is resolved automatically.
const
Properties
- countryIso2 → String
-
ISO 3166-1 alpha-2 country code to search within (e.g.
'US').final - emptyPlaceholder → String?
-
Text shown inside the overlay when no results match. Defaults to the
overlay's built-in "No results" label.
final
- enabled → bool
-
Whether the field accepts input.
final
- focusNode → FocusNode?
-
Optional external focus node.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- initialCityId → int?
-
Initially selected city id. On hydration the field resolves the city and
its parent state, then updates the display text.
final
- initialCityName → String?
-
Initial city name to pre-fill the text field without needing a city ID.
Useful in edit flows where the backend provides a name string.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
onChanged
→ ValueChanged<
CitySearchResult?> ? -
Called when the user picks a city. Receives
nullwhen the field is cleared.final - pickerConfig → GeoPickerConfig?
-
Config for search behaviour (debounce, max height, etc.).
final
- pickerTheme → GeoPickerTheme?
-
Theme applied to the dropdown overlay.
final
- placeholder → String?
-
Placeholder shown when no city is selected. Defaults to
"Search city".final - repository → GeoRepository?
-
Repository override (primarily for tests).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- style → CountrifyFieldStyle?
-
Field decoration.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< CitySearchField> -
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