CitySearchField constructor

const CitySearchField({
  1. required String countryIso2,
  2. Key? key,
  3. int? initialCityId,
  4. String? initialCityName,
  5. ValueChanged<CitySearchResult?>? onChanged,
  6. CountrifyFieldStyle? style,
  7. GeoPickerTheme? pickerTheme,
  8. GeoPickerConfig? pickerConfig,
  9. String? placeholder,
  10. String? emptyPlaceholder,
  11. bool enabled = true,
  12. FocusNode? focusNode,
  13. 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.

CitySearchField(
  countryIso2: 'US',
  onChanged: (result) {
    if (result != null) {
      print('${result.city.name}, ${result.state.name}');
    }
  },
)

Implementation

const CitySearchField({
  required this.countryIso2,
  super.key,
  this.initialCityId,
  this.initialCityName,
  this.onChanged,
  this.style,
  this.pickerTheme,
  this.pickerConfig,
  this.placeholder,
  this.emptyPlaceholder,
  this.enabled = true,
  this.focusNode,
  this.repository,
});