@@ -14,7 +14,17 @@ class CountryProvider {
14
14
static Client _client = Client ();
15
15
static String _baseUrl = Constants .restCounteriesBaseUri;
16
16
17
- /// Get all countries.
17
+ /// Get information about countries
18
+ /// ```dart
19
+ /// Future<List<Country>> getCountry(String name){
20
+ /// try{
21
+ /// List<Country> countries = await CountryProvider.getAllCountries();
22
+ /// return result;
23
+ /// } catch(error) {
24
+ /// print(error);
25
+ /// }
26
+ /// }
27
+ /// ``
18
28
static Future <List <Country >> getAllCountries ({CountryFilter filter}) async {
19
29
var uri =
20
30
"$_baseUrl " + Constants .allCountrySiffixUri + filter.toFormattedUri;
@@ -31,6 +41,21 @@ class CountryProvider {
31
41
"No country found. Please check if https://restcountries.eu is avialable." );
32
42
}
33
43
44
+ /// Search by country name
45
+ ///
46
+ /// You can pass incomplete country name
47
+ /// ```dart
48
+ /// Future<List<Country>> getCountry(String name){
49
+ /// try{
50
+ /// List<Country> result = await CountryProvider.getCountriesByName("Ameri")
51
+ /// return result;
52
+ /// } catch(error) {
53
+ /// print(error);
54
+ /// return null;
55
+ /// }
56
+ /// }
57
+ /// ```
58
+
34
59
static Future <List <Country >> getCountriesByName (String name,
35
60
{CountryFilter filter}) async {
36
61
if (name != null && name.isNotEmpty) {
@@ -54,6 +79,18 @@ class CountryProvider {
54
79
}
55
80
}
56
81
82
+ /// Search by country full name: `India` , `Cambodia` , `Canada`
83
+ /// ```dart
84
+ /// Future<Country> getCountry(String name){
85
+ /// try{
86
+ /// Country result = await CountryProvider.getCountryByFullname("India")?.first;
87
+ /// return result;
88
+ /// } catch(error) {
89
+ /// print(error);
90
+ /// return null;
91
+ /// }
92
+ /// }
93
+ /// ```
57
94
static Future <Country > getCountryByFullname (String name,
58
95
{CountryFilter filter}) async {
59
96
if (name != null && name.isNotEmpty) {
@@ -80,6 +117,18 @@ class CountryProvider {
80
117
}
81
118
}
82
119
120
+ /// Search by list of ISO 3166-1 2-letter or 3-letter country codes: `Ind` , `Col` , `ru`
121
+ /// ```dart
122
+ /// Future<Country> getCountry(String name){
123
+ /// try{
124
+ /// Country result = await CountryProvider.getCountryByCode("Ind")?.first;
125
+ /// return result;
126
+ /// } catch(error) {
127
+ /// print(error);
128
+ /// return null;
129
+ /// }
130
+ /// }
131
+ /// ```
83
132
static Future <Country > getCountryByCode (String code,
84
133
{CountryFilter filter}) async {
85
134
if (code != null && code.isNotEmpty) {
@@ -99,6 +148,18 @@ class CountryProvider {
99
148
}
100
149
}
101
150
151
+ /// Search by list of ISO 3166-1 2-letter or 3-letter country codes: `["Ind", "col", "ru"]`
152
+ /// ```dart
153
+ /// Future<List<Country>> getCountry(String name){
154
+ /// try{
155
+ /// List<Country> result = CountryProvider.getCountriesByListOfCodes(["Ind", "col", "ru"]);
156
+ /// return result;
157
+ /// } catch(error) {
158
+ /// print(error);
159
+ /// return null;
160
+ /// }
161
+ /// }
162
+ /// ```
102
163
static Future <List <Country >> getCountriesByListOfCodes (List <String > codes,
103
164
{CountryFilter filter}) async {
104
165
if (codes != null && codes.isNotEmpty) {
@@ -124,6 +185,18 @@ class CountryProvider {
124
185
}
125
186
}
126
187
188
+ /// Search by ISO 4217 currency code: `Inr` , `Aud` , `Bmd` , `Usd` , `Eur` , `Gbp`
189
+ /// ```dart
190
+ /// Future<List<Country>> getCountry(String name){
191
+ /// try{
192
+ /// List<Country> result = await CountryProvider.getCountryByCurrencyCode("Inr")
193
+ /// return result;
194
+ /// } catch(error) {
195
+ /// print(error);
196
+ /// return null;
197
+ /// }
198
+ /// }
199
+ /// ```
127
200
static Future <List <Country >> getCountryByCurrencyCode (String currencyCode,
128
201
{CountryFilter filter}) async {
129
202
if (currencyCode != null && currencyCode.isNotEmpty) {
@@ -146,6 +219,18 @@ class CountryProvider {
146
219
}
147
220
}
148
221
222
+ /// Search by ISO 639-1 language code: `jpn` , `en` , `hin` , `ru` ,
223
+ /// ```dart
224
+ /// Future<List<Country>> getCountry(String name){
225
+ /// try{
226
+ /// List<Country> result = await CountryProvider.getCountriesByLanguageCode(["Hin","en",]);
227
+ /// return result;
228
+ /// } catch(error) {
229
+ /// print(error);
230
+ /// return null;
231
+ /// }
232
+ /// }
233
+ /// ```
149
234
static Future <List <Country >> getCountriesByLanguageCode (
150
235
List <String > languageCode,
151
236
{CountryFilter filter}) async {
@@ -169,14 +254,26 @@ class CountryProvider {
169
254
}
170
255
}
171
256
257
+ /// Search by capital city: `Tokyo` , `Rome` , `Bankok` , `London` , `Kampla`
258
+ /// ```dart
259
+ /// Future<List<Country>> getCountry(String name){
260
+ /// try{
261
+ /// List<Country> result = await CountryProvider.getCountryByCapitalCity("Delhi");
262
+ /// return result;
263
+ /// } catch(error) {
264
+ /// print(error);
265
+ /// return null;
266
+ /// }
267
+ /// }
268
+ /// ```
172
269
static Future <List <Country >> getCountryByCapitalCity (String capitalName,
173
270
{CountryFilter filter}) async {
174
271
if (capitalName != null && capitalName.isNotEmpty) {
175
272
final uri = "$_baseUrl " +
176
273
Constants .countriesByCapitalCity +
177
274
capitalName +
178
275
filter.toFormattedUri;
179
-
276
+
180
277
print (uri);
181
278
var response = await _client.get (uri);
182
279
@@ -192,6 +289,18 @@ class CountryProvider {
192
289
}
193
290
}
194
291
292
+ /// Search by calling code: `91` , `61` , `55` , `855` , `81`
293
+ /// ```dart
294
+ /// Future<List<Country>> getCountry(String name){
295
+ /// try{
296
+ /// List<Country> result = await CountryProvider.getCountryByCallingCode(91);
297
+ /// return result;
298
+ /// } catch(error) {
299
+ /// print(error);
300
+ /// return null;
301
+ /// }
302
+ /// }
303
+ /// ```
195
304
static Future <List <Country >> getCountryByCallingCode (int callingCode,
196
305
{CountryFilter filter}) async {
197
306
if (callingCode != null && callingCode > 0 ) {
@@ -214,6 +323,18 @@ class CountryProvider {
214
323
}
215
324
}
216
325
326
+ /// Search by continent: `Africa` , `Americas` , `Asia` , `Europe` , `Oceania` .
327
+ /// ```dart
328
+ /// Future<List<Country>> getCountry(String name){
329
+ /// try{
330
+ /// List<Country> result = await CountryProvider.getcountryByRegionalBloc("Asia");
331
+ /// return result;
332
+ /// } catch(error) {
333
+ /// print(error);
334
+ /// return null;
335
+ /// }
336
+ /// }
337
+ /// ```
217
338
static Future <List <Country >> getCountriesByContinent (String continentName,
218
339
{CountryFilter filter}) async {
219
340
if (continentName != null && continentName.isNotEmpty) {
@@ -236,6 +357,19 @@ class CountryProvider {
236
357
}
237
358
}
238
359
360
+
361
+ /// Search by regional bloc: `EU` , `EFTA` , `CARICOM` , `AU` , `USAN` , `EEU` , `AL` , `ASEAN` , `CAIS` , `CEFTA` , `NAFTA` , `SAARC` .
362
+ /// ```dart
363
+ /// Future<List<Country>> getCountry(String name){
364
+ /// try{
365
+ /// List<Country> result = await CountryProvider.getCountriesByContinent("ASEAN");
366
+ /// return result;
367
+ /// } catch(error) {
368
+ /// print(error);
369
+ /// return null;
370
+ /// }
371
+ /// }
372
+ /// ```
239
373
static Future <List <Country >> getcountryByRegionalBloc (String regiaonBlocName,
240
374
{CountryFilter filter}) async {
241
375
if (regiaonBlocName != null && regiaonBlocName.isNotEmpty) {
0 commit comments