From a576443eda9763486e6e8206dd77bd2012e35ad6 Mon Sep 17 00:00:00 2001 From: Yoan Carlos Machado Espinosa Date: Thu, 22 Aug 2019 08:45:52 -0400 Subject: [PATCH] Add onlyCountries property - to define a list with specific country codes to show only such countries --- lib/country_code_picker.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index b342ae1..d29bb17 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -31,10 +31,14 @@ class CountryCodePicker extends StatefulWidget { /// shows the flag final bool showFlag; + /// contains the country codes to load only the specified countries. + final List onlyCountries; + CountryCodePicker({ this.onChanged, this.initialSelection, this.favorite = const [], + this.onlyCountries = const [], this.textStyle, this.padding = const EdgeInsets.all(0.0), this.showCountryOnly = false, @@ -59,6 +63,12 @@ class CountryCodePicker extends StatefulWidget { )) .toList(); + if(onlyCountries.length > 0) { + elements = elements + .where((c) => onlyCountries.contains(c.code)) + .toList(); + } + return new _CountryCodePickerState(elements); } }