Allow to filter countries by locale in the dialog
This commit is contained in:
committed by
Salvatore Giordano
parent
ce9c3a0a5c
commit
16f09e5ecf
@@ -51,6 +51,9 @@ class CountryCodePicker extends StatefulWidget {
|
|||||||
/// Use this property to change the order of the options
|
/// Use this property to change the order of the options
|
||||||
final Comparator<CountryCode> comparator;
|
final Comparator<CountryCode> comparator;
|
||||||
|
|
||||||
|
// Enable filtering countries in the dialog using localizes string
|
||||||
|
final bool filterByLocale;
|
||||||
|
|
||||||
CountryCodePicker({
|
CountryCodePicker({
|
||||||
this.onChanged,
|
this.onChanged,
|
||||||
this.onInit,
|
this.onInit,
|
||||||
@@ -74,6 +77,7 @@ class CountryCodePicker extends StatefulWidget {
|
|||||||
this.textOverflow = TextOverflow.ellipsis,
|
this.textOverflow = TextOverflow.ellipsis,
|
||||||
this.comparator,
|
this.comparator,
|
||||||
this.customList,
|
this.customList,
|
||||||
|
this.filterByLocale = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -113,6 +117,9 @@ class _CountryCodePickerState extends State<CountryCodePicker> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
if (widget.filterByLocale) {
|
||||||
|
this.elements = elements.map((e) => e.localize(context)).toList();
|
||||||
|
}
|
||||||
Widget _widget;
|
Widget _widget;
|
||||||
if (widget.builder != null)
|
if (widget.builder != null)
|
||||||
_widget = InkWell(
|
_widget = InkWell(
|
||||||
|
|||||||
Reference in New Issue
Block a user