Merge pull request #38 from git-yoan/master

Add onlyCountries property
This commit is contained in:
Salvatore Giordano
2019-12-09 23:01:44 +01:00
committed by GitHub

View File

@@ -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<String> 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);
}
}