From a0b48919dfe2b461fc0baf2c9cf3568d322920d0 Mon Sep 17 00:00:00 2001 From: cybex-dev Date: Wed, 30 Mar 2022 21:21:25 +0200 Subject: [PATCH 1/2] Use global countryList and make it available globally --- lib/country_picker.dart | 3 +++ lib/src/country_list_view.dart | 5 +---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/country_picker.dart b/lib/country_picker.dart index 19321c2..f69ee0c 100644 --- a/lib/country_picker.dart +++ b/lib/country_picker.dart @@ -5,12 +5,15 @@ import 'package:flutter/material.dart'; import 'src/country.dart'; import 'src/country_list_bottom_sheet.dart'; import 'src/country_list_theme_data.dart'; +import 'src/res/country_codes.dart'; export 'src/country.dart'; export 'src/country_list_theme_data.dart'; export 'src/country_localizations.dart'; export 'src/country_parser.dart'; +List countryList = countryCodes.map((country) => Country.from(json: country)).toList(); + /// Shows a bottom sheet containing a list of countries to select one. /// /// The callback function [onSelect] call when the user select a country. diff --git a/lib/src/country_list_view.dart b/lib/src/country_list_view.dart index 62c32c2..ddded3d 100644 --- a/lib/src/country_list_view.dart +++ b/lib/src/country_list_view.dart @@ -1,8 +1,6 @@ import 'package:country_picker/country_picker.dart'; import 'package:country_picker/src/extensions.dart'; import 'package:flutter/material.dart'; - -import 'res/country_codes.dart'; import 'utils.dart'; class CountryListView extends StatefulWidget { @@ -64,8 +62,7 @@ class _CountryListViewState extends State { super.initState(); _searchController = TextEditingController(); - _countryList = - countryCodes.map((country) => Country.from(json: country)).toList(); + _countryList = countryList; //Remove duplicates country if not use phone code if (!widget.showPhoneCode) { From 5a7f3ed40dacbb89db195a24ec82c6dc53dead80 Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Sat, 14 May 2022 06:58:12 +0200 Subject: [PATCH 2/2] Fixed imports --- example/test/widget_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index 747db1d..6db856c 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -8,7 +8,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:example/main.dart'; +import '../lib/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async {