country_state_city
A flutter package to display list of world wide Countries, States and Cities. It also allows to get a list of States and Cities depends on given country (by ISO CODE).
How to Use
To use this Package, add country_state_city
as a dependency in your pubspec.yaml.
// import country_state_city package
import 'package:country_state_city/country_state_city.dart';
// Get all countries
final countries = await getAllCountries();
// Get all states that belongs to a country by country ISO CODE
final states = await getStatesOfCountry('AF'); // Afghanistan
APIs
Function | Description |
---|---|
Future<List | Get world wide countries list. |
Future<Country?> getCountryFromCode(String countryCode) | Get country from its ISO CODE |
Future<List | Get world wide states list. |
Future<List | Get the list of states that belongs to a country by the country ISO CODE |
Future<State?> getStateByCode(String countryCode, String stateCode,)` | Get a state from its code and its belonging country code |
Future<List | Get world wide cities list. |
Future<List | Get the list of states that belongs to a state by the state ISO CODE and the country ISO CODE |
Future<List | Get the list of cities that belongs to a country by the country ISO CODE |
Classes
Class | Description |
---|---|
Country | Handle country data such as: (name, isoCode, phoneCode, flag, currency, latitude, longitude, timezones) |
State | Handle state data such as: (name, countryCode, isoCode, latitude, longitude) |
City | Handle city data such as: (name, countryCode, stateCode, latitude, longitude) |
Timezone | Handle timezone data such as: (name, gmtOffset, gmtOffsetName, abbreviation, tzName) |
Special Thanks to
Libraries
- country_state_city
- This library provides functions and models to help you fetch world countries states, cities. You can get all the states that belongs to a country, as well as all cities
- models/city
- models/country
- models/models
- models/state
- models/timezone
- utils/city_utils
- utils/country_utils
- utils/state_utils
- utils/utils