From 803d41cf6da0f20707c21e63b3d3b0ee64a400b0 Mon Sep 17 00:00:00 2001 From: alfredo-handcash Date: Thu, 13 May 2021 10:05:26 +0200 Subject: [PATCH 1/2] make const list to use in constructor --- lib/country_codes.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/country_codes.dart b/lib/country_codes.dart index 993be09..ab11e3e 100644 --- a/lib/country_codes.dart +++ b/lib/country_codes.dart @@ -1,4 +1,4 @@ -List> codes = [ +const List> codes = [ { "name": "افغانستان", "code": "AF", From e1098ee6c7e70e91815d1259fef97234b58c1c52 Mon Sep 17 00:00:00 2001 From: alfredo-handcash Date: Thu, 13 May 2021 10:05:46 +0200 Subject: [PATCH 2/2] pass codes in constructor --- lib/country_code_picker.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index 1ba6ded..1d56969 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -80,6 +80,10 @@ class CountryCodePicker extends StatefulWidget { /// [BoxDecoration] for the flag image final Decoration? flagDecoration; + /// An optional argument for inject list of countries + /// with customized codes. + final List> countryList; + CountryCodePicker({ this.onChanged, this.onInit, @@ -113,12 +117,13 @@ class CountryCodePicker extends StatefulWidget { this.dialogSize, this.dialogBackgroundColor, this.closeIcon = const Icon(Icons.close), + this.countryList = codes, Key? key, }) : super(key: key); @override State createState() { - List jsonList = codes; + List jsonList = countryList; List elements = jsonList .map((json) => CountryCode.fromJson(json as Map))