From 9f69fcbb37e7de57e524080e69265dc97cbee28b Mon Sep 17 00:00:00 2001 From: OmarBakry-eg Date: Mon, 4 Apr 2022 14:42:35 +0200 Subject: [PATCH] adding fixed id to every country --- lib/country_code.dart | 7 +++++-- lib/country_code_picker.dart | 2 -- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/country_code.dart b/lib/country_code.dart index 3d1a6b47..1f9d8844 100644 --- a/lib/country_code.dart +++ b/lib/country_code.dart @@ -22,11 +22,14 @@ class CountryCode { /// the dial code (+39,+93..) final String? dialCode; + /// fixed id for countries you might be add it from the server + final String? id; CountryCode({ this.name, this.flagUri, this.code, this.dialCode, + this.id, }); @Deprecated('Use `fromCountryCode` instead.') @@ -50,14 +53,14 @@ class CountryCode { CountryCode localize(BuildContext context) { return this - ..name = - CountryLocalizations.of(context)?.translate(this.code) ?? this.name; + ..name = CountryLocalizations.of(context)?.translate(this.code) ?? this.name; } factory CountryCode.fromJson(Map json) { return CountryCode( name: json['name'], code: json['code'], + id: json['id'], dialCode: json['dial_code'], flagUri: 'flags/${json['code'].toLowerCase()}.png', ); diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index c979e12b..ae23d99e 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -4,11 +4,9 @@ import 'package:collection/collection.dart' show IterableExtension; import 'package:country_code_picker/country_code.dart'; import 'package:country_code_picker/country_codes.dart'; import 'package:country_code_picker/selection_dialog.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:modal_bottom_sheet/modal_bottom_sheet.dart'; import 'package:universal_platform/universal_platform.dart'; - export 'country_code.dart'; class CountryCodePicker extends StatefulWidget {