nullalbe with support 70 languages

This commit is contained in:
kechankrisna
2021-03-09 02:44:04 +07:00
parent 0fe203e8ff
commit 057bb77d34
77 changed files with 17718 additions and 2116 deletions

View File

@@ -1,3 +1,4 @@
import 'package:collection/collection.dart' show IterableExtension;
import 'package:country_code_picker/country_codes.dart';
import 'package:country_code_picker/country_localizations.dart';
import 'package:flutter/cupertino.dart';
@@ -10,16 +11,16 @@ class CElement = CountryCode with ToAlias;
/// Country element. This is the element that contains all the information
class CountryCode {
/// the name of the country
String name;
String? name;
/// the flag of the country
final String flagUri;
final String? flagUri;
/// the country code (IT,AF..)
final String code;
final String? code;
/// the dial code (+39,+93..)
final String dialCode;
final String? dialCode;
CountryCode({
this.name,
@@ -29,16 +30,10 @@ class CountryCode {
});
factory CountryCode.fromCode(String isoCode) {
final Map<String, String> jsonCode = codes.firstWhere(
final Map<String, String>? jsonCode = codes.firstWhereOrNull(
(code) => code['code'] == isoCode,
orElse: () => null,
);
if (jsonCode == null) {
return null;
}
return CountryCode.fromJson(jsonCode);
return CountryCode.fromJson(jsonCode!);
}
CountryCode localize(BuildContext context) {