dart_countries_states 0.0.5

  • Readme
  • Changelog
  • Example
  • Installing
  • 60

dart_countries_states #

A Dart project that contains all the countries and states. The content is based on apilayer/restcountries repository.

Getting Started #

The format of the models can be found here

Utility functions #


Country getCountryByName(String name, ...)
Country getCountryByCode2(String code2, ...)
Country getCountryByCode3(String code3, ...)
Country getCountryByCapital(String capital, ...)

List<Country> getCountriesByCapital(String capital, ...)
List<Country> getCountriesByRegion(String region, ...)
List<Country> getCountriesBySubregion(String subregion, ...)

Full list of available functions can be found here

Internationalization #

The supported languages are ['de', 'es', 'fr', 'ja', 'it', 'br', 'pt', 'nl', 'hr', 'fa'].

getCountryByName(name: 'Koweït', lang: 'fr')

Example #

The examples can be found in example and test.

{
  "name": "Bahrain",
  "topLevelDomain": [
    ".bh"
  ],
  "alpha2Code": "BH",
  "alpha3Code": "BHR",
  "callingCodes": [
    "973"
  ],
  "capital": "Manama",
  "altSpellings": [
    "BH",
    "Kingdom of Bahrain",
    "Mamlakat al-Baḥrayn"
  ],
  "region": "Asia",
  "subregion": "Western Asia",
  "population": 1404900,
  "latlng": [
    26,
    50.55
  ],
  "demonym": "Bahraini",
  "area": 765,
  "gini": null,
  "timezones": [
    "UTC+03:00"
  ],
  "borders": [],
  "nativeName": "‏البحرين",
  "numericCode": "048",
  "currencies": [
    {
      "code": "BHD",
      "name": "Bahraini dinar",
      "symbol": ".د.ب"
    }
  ],
  "languages": [
    {
      "iso639_1": "ar",
      "iso639_2": "ara",
      "name": "Arabic",
      "nativeName": "العربية"
    }
  ],
  "translations": {
    "de": "Bahrain",
    "es": "Bahrein",
    "fr": "Bahreïn",
    "ja": "バーレーン",
    "it": "Bahrein",
    "br": "Bahrein",
    "pt": "Barém",
    "nl": "Bahrein",
    "hr": "Bahrein",
    "fa": "بحرین"
  },
  "flag": "https://restcountries.eu/data/bhr.svg",
  "regionalBlocs": [
    {
      "acronym": "AL",
      "name": "Arab League",
      "otherAcronyms": [],
      "otherNames": [
        "جامعة الدول العربية",
        "Jāmiʻat ad-Duwal al-ʻArabīyah",
        "League of Arab States"
      ]
    }
  ],
  "cioc": "BRN"
}

#Changelog

[0.0.5] - 2019/09/05

  • Add alpha2Code, alpha3Code and LanguageCode enums.

[0.0.4] - 2019/09/05

  • Remove unnecessary lang in functions that don't use it

[0.0.3] - 2019/09/05

  • Update functions to be case insensitive.

[0.0.2] - 2019/09/04

[0.0.1] - 2019/09/03

  • Created first version

example/lib/example.dart

import 'package:dart_countries_states/src/country_provider.dart';

final countryProvider = CountryProvider();
var countries = countryProvider.getCountries();

// When looking for an specific country
var country = countryProvider.getCountryByName(name: "United States");

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  dart_countries_states: ^0.0.5

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

Popularity:
Describes how popular the package is relative to other packages. [more]
25
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
60
Learn more about scoring.

We analyzed this package on Oct 16, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
built_collection >=2.0.0 <5.0.0 4.2.2
built_value >=5.5.5 <7.0.0 6.7.1
flutter 0.0.0
http ^0.12.0+2 0.12.0+2
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.11 1.14.12
fixnum 0.10.9
http_parser 3.1.3
matcher 0.12.5
meta 1.1.7
path 1.6.4
pedantic 1.8.0+1
quiver 2.0.5
sky_engine 0.0.99
source_span 1.5.5
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
build_runner ^1.0.0
built_value_generator ^6.7.1
flutter_test