restcountries 0.0.1 copy "restcountries: ^0.0.1" to clipboard
restcountries: ^0.0.1 copied to clipboard

outdated

A library to load countries, states/regions, and cities.

example/restcountries_example.dart

import 'package:restcountries/restcountries.dart';

main() async {
  var api = RestCountries.setup("YOUR_API_KEY");
  List<Country> countries;
  List<Region> regions;
  List<City> cities;
  // get all countries
  countries = await api.getCountries();
  // or you could do this as long as you have called setup for initialization
  countries = await RestCountries.instance.getCountries();
  // search country functionality
  // you could also put city and/or region to narrow down the search of the country
  countries = await api.searchCountry(keyword: "Indo", city: "", region: "");

  // get all regions of a country. You need to pass the countryCode as it is required from the API
  regions = await api.getRegions(countryCode: "id");

  // search region
  regions =
      await api.searchRegion(countryCode: "id", city: "", keyword: "Jawa");

  // you could get all cities by just filling the countryCode and region name.
  // if you want to narrow it down to search of some city, put the keyword as parameter
  cities = await api.getCities(
      countryCode: "id", region: "Jawa Timur", keyword: "mal");
}
9
likes
0
points
15
downloads

Publisher

verified publishermgufron.com

Weekly Downloads

A library to load countries, states/regions, and cities.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

dio

More

Packages that depend on restcountries