From 16f09e5ecf9f8d18d50da7b1941d3408915e6b10 Mon Sep 17 00:00:00 2001 From: Rafael Delos Santos Date: Thu, 2 Apr 2020 20:27:29 +1100 Subject: [PATCH] Allow to filter countries by locale in the dialog --- lib/country_code_picker.dart | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index 7e491da..f3fb1a1 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -51,6 +51,9 @@ class CountryCodePicker extends StatefulWidget { /// Use this property to change the order of the options final Comparator comparator; + // Enable filtering countries in the dialog using localizes string + final bool filterByLocale; + CountryCodePicker({ this.onChanged, this.onInit, @@ -74,6 +77,7 @@ class CountryCodePicker extends StatefulWidget { this.textOverflow = TextOverflow.ellipsis, this.comparator, this.customList, + this.filterByLocale = false, }); @override @@ -113,6 +117,9 @@ class _CountryCodePickerState extends State { @override Widget build(BuildContext context) { + if (widget.filterByLocale) { + this.elements = elements.map((e) => e.localize(context)).toList(); + } Widget _widget; if (widget.builder != null) _widget = InkWell(