Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/inject list countries (#1) #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/src/country_list_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,18 @@ class CountryListView extends StatefulWidget {
/// country list bottom sheet.
final CountryListThemeData? countryListTheme;

/// An optional argument for inject list of countries
/// with customized codes.
final List<Map<String, dynamic>> countryList;

const CountryListView({
Key? key,
required this.onSelect,
this.exclude,
this.countryFilter,
this.showPhoneCode = false,
this.countryListTheme,
this.countryList = countryCodes,
}) : assert(exclude == null || countryFilter == null,
'Cannot provide both exclude and countryFilter'),
super(key: key);
Expand All @@ -53,7 +58,7 @@ class _CountryListViewState extends State<CountryListView> {
_searchController = TextEditingController();

_countryList =
countryCodes.map((country) => Country.from(json: country)).toList();
widget.countryList.map((country) => Country.from(json: country)).toList();

//Remove duplicates country if not use phone code
if (!widget.showPhoneCode) {
Expand Down Expand Up @@ -178,5 +183,5 @@ class _CountryListViewState extends State<CountryListView> {
setState(() => _filteredList = _searchResult);
}

get _defaultTextStyle => const TextStyle(fontSize: 16);
TextStyle get _defaultTextStyle => const TextStyle(fontSize: 16);
}
2 changes: 1 addition & 1 deletion lib/src/res/country_codes.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
final List<Map<String, dynamic>> countryCodes = [
const List<Map<String, dynamic>> countryCodes = [
{
"e164_cc": "93",
"iso2_cc": "AF",
Expand Down