add custom list prop
This commit is contained in:
@@ -43,6 +43,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
initialSelection: 'IT',
|
initialSelection: 'IT',
|
||||||
favorite: ['+39', 'FR'],
|
favorite: ['+39', 'FR'],
|
||||||
showFlag: false,
|
showFlag: false,
|
||||||
|
customList: ['IT', 'FR'],
|
||||||
showFlagDialog: true,
|
showFlagDialog: true,
|
||||||
comparator: (a, b) => b.name.compareTo(a.name),
|
comparator: (a, b) => b.name.compareTo(a.name),
|
||||||
//Get the country information relevant to the initial selection
|
//Get the country information relevant to the initial selection
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ class CountryCodePicker extends StatefulWidget {
|
|||||||
final Function(CountryCode) builder;
|
final Function(CountryCode) builder;
|
||||||
final bool enabled;
|
final bool enabled;
|
||||||
final TextOverflow textOverflow;
|
final TextOverflow textOverflow;
|
||||||
|
final List<String> customList;
|
||||||
|
|
||||||
/// shows the name of the country instead of the dialcode
|
/// shows the name of the country instead of the dialcode
|
||||||
final bool showOnlyCountryWhenClosed;
|
final bool showOnlyCountryWhenClosed;
|
||||||
@@ -70,6 +71,7 @@ class CountryCodePicker extends StatefulWidget {
|
|||||||
this.enabled = true,
|
this.enabled = true,
|
||||||
this.textOverflow = TextOverflow.ellipsis,
|
this.textOverflow = TextOverflow.ellipsis,
|
||||||
this.comparator,
|
this.comparator,
|
||||||
|
this.customList,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -83,6 +85,15 @@ class CountryCodePicker extends StatefulWidget {
|
|||||||
elements.sort(comparator);
|
elements.sort(comparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (customList != null) {
|
||||||
|
elements = elements
|
||||||
|
.where((c) =>
|
||||||
|
customList.contains(c.code) ||
|
||||||
|
customList.contains(c.name) ||
|
||||||
|
customList.contains(c.dialCode))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
if (countryFilter.length > 0) {
|
if (countryFilter.length > 0) {
|
||||||
elements = elements.where((c) => countryFilter.contains(c.code)).toList();
|
elements = elements.where((c) => countryFilter.contains(c.code)).toList();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user