Skip to content

A simple country.io data parser, written with ❤️ using Dart :)

License

Notifications You must be signed in to change notification settings

itzmeanjan/countryIO

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

countryIO

A simple country.io data parser, written with ❤️ using Dart :)

Show some ❤️ by putting ⭐ :)

This plugin is readily available for use. ... 🏃 ...

what does it do ?

This Dart package can be used to fetch country data from country.io, which includes country iso2 code, country name, capital name, continent code, currency code & phone code, which will be eventually stored in a json encoded file, whose path needs to be provided to Generator class constructor.

how to use ?

Well using this package for generating json encoded file, holding country data, is pretty much easy.

Simply invoke Generator constructor with a valid path to target data.json file. Calling Generator( ... ).generate(), will start fetching data from country.io, then parsing data and json encoding data for storing in target file.

This function will return a Future<Map<String, Map<String, String>>>, an empty Map denotes failure, otherwise full parsed data set will be returned in form of Map.

Every key of this map will be an iso2 country code, helping to identify a certain country uniquely.

{
     .
     .
     .
     iso2:
     {
        'continent': continent ?? '',
        'name': name ?? '',
        'iso3': iso3 ?? '',
        'capital': capital ?? '',
        'phone': phone ?? '',
        'currency': currency ?? '',
      }
     .
     .
     .
   }

And value for a certain iso2 country code will be another Map<String, String>, holding detailed country info.

Generator('./data.json')
    .generate()
    .then((result) => print(result.isNotEmpty ? 'Success' : 'Failed !!!'));

Yes, it's that simple 😉

courtesy

Country data is fetched from country.io, so they do deserve courtesy.

For T&C of data utilization, you may be interested in taking a look at country.io

Hoping, it helped you a bit (o_o)

About

A simple country.io data parser, written with ❤️ using Dart :)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages