Compare commits
2 Commits
3.4.0
...
fix/versio
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2ce3306e1f | ||
|
|
13e437d81b |
27
.github/workflows/dart.yml
vendored
27
.github/workflows/dart.yml
vendored
@@ -1,19 +1,20 @@
|
|||||||
# This workflow uses actions that are not certified by GitHub.
|
name: Publish plugin
|
||||||
# They are provided by a third-party and are governed by
|
|
||||||
# separate terms of service, privacy policy, and support
|
|
||||||
# documentation.
|
|
||||||
|
|
||||||
name: Publish to pub.dev
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- '[0-9]+.[0-9]+.[0-9]+*'
|
- v*
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish:
|
publish:
|
||||||
permissions:
|
|
||||||
id-token: write # Required for authentication using OIDC
|
runs-on: ubuntu-latest
|
||||||
uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1
|
|
||||||
# with:
|
steps:
|
||||||
# working-directory: path/to/package/within/repository
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v1
|
||||||
|
- name: Publish
|
||||||
|
uses: sakebook/actions-flutter-pub-publisher@v1.2.1
|
||||||
|
with:
|
||||||
|
credential: ${{ secrets.CREDENTIALS }}
|
||||||
|
skip_test: true
|
||||||
|
|||||||
10
CHANGELOG.md
10
CHANGELOG.md
@@ -1,13 +1,3 @@
|
|||||||
## 3.4.0 - August 19 2025
|
|
||||||
- Fix China translation
|
|
||||||
- Adding flag autofocus
|
|
||||||
|
|
||||||
## 3.3.1 - August 19 2025
|
|
||||||
- Fix French translation accent display issue
|
|
||||||
- Correct French country name translations (Biélorussie, Koweït, Grenade, etc.)
|
|
||||||
- Preserve accents in displayed names while maintaining search functionality
|
|
||||||
- Update search logic to handle both accented and non-accented input
|
|
||||||
|
|
||||||
## 3.3.0 - March 26 2025
|
## 3.3.0 - March 26 2025
|
||||||
- Fix localization, typo, and flag issue #51 thanks to @MrRoy121
|
- Fix localization, typo, and flag issue #51 thanks to @MrRoy121
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ class CountryCodePicker extends StatefulWidget {
|
|||||||
final bool showCountryOnly;
|
final bool showCountryOnly;
|
||||||
final InputDecoration searchDecoration;
|
final InputDecoration searchDecoration;
|
||||||
final TextStyle? searchStyle;
|
final TextStyle? searchStyle;
|
||||||
final bool? isFocused;
|
|
||||||
final TextStyle? dialogTextStyle;
|
final TextStyle? dialogTextStyle;
|
||||||
final WidgetBuilder? emptySearchBuilder;
|
final WidgetBuilder? emptySearchBuilder;
|
||||||
final Function(CountryCode?)? builder;
|
final Function(CountryCode?)? builder;
|
||||||
@@ -126,7 +125,6 @@ class CountryCodePicker extends StatefulWidget {
|
|||||||
this.margin,
|
this.margin,
|
||||||
this.showCountryOnly = false,
|
this.showCountryOnly = false,
|
||||||
this.searchDecoration = const InputDecoration(),
|
this.searchDecoration = const InputDecoration(),
|
||||||
this.isFocused = false,
|
|
||||||
this.searchStyle,
|
this.searchStyle,
|
||||||
this.dialogTextStyle,
|
this.dialogTextStyle,
|
||||||
this.emptySearchBuilder,
|
this.emptySearchBuilder,
|
||||||
@@ -332,7 +330,6 @@ class CountryCodePickerState extends State<CountryCodePicker> {
|
|||||||
emptySearchBuilder: widget.emptySearchBuilder,
|
emptySearchBuilder: widget.emptySearchBuilder,
|
||||||
searchDecoration: widget.searchDecoration,
|
searchDecoration: widget.searchDecoration,
|
||||||
searchStyle: widget.searchStyle,
|
searchStyle: widget.searchStyle,
|
||||||
isFocused: widget.isFocused,
|
|
||||||
textStyle: widget.dialogTextStyle,
|
textStyle: widget.dialogTextStyle,
|
||||||
boxDecoration: widget.boxDecoration,
|
boxDecoration: widget.boxDecoration,
|
||||||
showFlag: widget.showFlagDialog ?? widget.showFlag,
|
showFlag: widget.showFlagDialog ?? widget.showFlag,
|
||||||
@@ -389,6 +386,7 @@ class CountryCodePickerState extends State<CountryCodePicker> {
|
|||||||
hideSearch: widget.hideSearch,
|
hideSearch: widget.hideSearch,
|
||||||
closeIcon: widget.closeIcon,
|
closeIcon: widget.closeIcon,
|
||||||
flagDecoration: widget.flagDecoration,
|
flagDecoration: widget.flagDecoration,
|
||||||
|
searchPadding: widget.searchPadding,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ class SelectionBottomSheet extends StatefulWidget {
|
|||||||
/// elements passed as favorite
|
/// elements passed as favorite
|
||||||
final List<CountryCode> favoriteElements;
|
final List<CountryCode> favoriteElements;
|
||||||
|
|
||||||
|
final EdgeInsetsGeometry searchPadding;
|
||||||
|
|
||||||
SelectionBottomSheet(
|
SelectionBottomSheet(
|
||||||
this.elements,
|
this.elements,
|
||||||
this.favoriteElements, {
|
this.favoriteElements, {
|
||||||
@@ -46,6 +48,7 @@ class SelectionBottomSheet extends StatefulWidget {
|
|||||||
this.barrierColor,
|
this.barrierColor,
|
||||||
this.hideSearch = false,
|
this.hideSearch = false,
|
||||||
this.closeIcon,
|
this.closeIcon,
|
||||||
|
this.searchPadding = const EdgeInsets.symmetric(horizontal: 24),
|
||||||
}) : searchDecoration = searchDecoration.prefixIcon == null
|
}) : searchDecoration = searchDecoration.prefixIcon == null
|
||||||
? searchDecoration.copyWith(prefixIcon: const Icon(Icons.search))
|
? searchDecoration.copyWith(prefixIcon: const Icon(Icons.search))
|
||||||
: searchDecoration,
|
: searchDecoration,
|
||||||
@@ -93,7 +96,7 @@ class _SelectionBottomSheetState extends State<SelectionBottomSheet> {
|
|||||||
),
|
),
|
||||||
if (!widget.hideSearch)
|
if (!widget.hideSearch)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
padding: widget.searchPadding,
|
||||||
child: TextField(
|
child: TextField(
|
||||||
style: widget.searchStyle,
|
style: widget.searchStyle,
|
||||||
decoration: widget.searchDecoration,
|
decoration: widget.searchDecoration,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:collection/collection.dart' show IterableExtension;
|
import 'package:collection/collection.dart' show IterableExtension;
|
||||||
|
import 'package:diacritic/diacritic.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/foundation.dart' show kDebugMode;
|
import 'package:flutter/foundation.dart' show kDebugMode;
|
||||||
|
|
||||||
@@ -44,9 +45,7 @@ class CountryCode {
|
|||||||
try {
|
try {
|
||||||
return CountryCode.fromCountryCode(countryCode);
|
return CountryCode.fromCountryCode(countryCode);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (kDebugMode) {
|
if (kDebugMode) print('Failed to recognize country from countryCode: $countryCode');
|
||||||
print('Failed to recognize country from countryCode: $countryCode');
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,21 +61,20 @@ class CountryCode {
|
|||||||
try {
|
try {
|
||||||
return CountryCode.fromDialCode(dialCode);
|
return CountryCode.fromDialCode(dialCode);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (kDebugMode) {
|
if (kDebugMode) print('Failed to recognize country from dialCode: $dialCode');
|
||||||
print('Failed to recognize country from dialCode: $dialCode');
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CountryCode localize(BuildContext context) {
|
CountryCode localize(BuildContext context) {
|
||||||
final nam = CountryLocalizations.of(context)?.translate(code) ?? name;
|
final nam = CountryLocalizations.of(context)?.translate(code) ?? name;
|
||||||
return this..name = nam ?? name;
|
return this
|
||||||
|
..name = nam == null? name : removeDiacritics(nam);
|
||||||
}
|
}
|
||||||
|
|
||||||
factory CountryCode.fromJson(Map<String, dynamic> json) {
|
factory CountryCode.fromJson(Map<String, dynamic> json) {
|
||||||
return CountryCode(
|
return CountryCode(
|
||||||
name: json['name'],
|
name: removeDiacritics(json['name']),
|
||||||
code: json['code'],
|
code: json['code'],
|
||||||
dialCode: json['dial_code'],
|
dialCode: json['dial_code'],
|
||||||
flagUri: 'flags/${json['code'].toLowerCase()}.png',
|
flagUri: 'flags/${json['code'].toLowerCase()}.png',
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ const List<Map<String, String>> codes = [
|
|||||||
},
|
},
|
||||||
{"name": "Tchad", "code": "TD", "iso3Code": "TCD", "dial_code": "+235"},
|
{"name": "Tchad", "code": "TD", "iso3Code": "TCD", "dial_code": "+235"},
|
||||||
{"name": "Chile", "code": "CL", "iso3Code": "CHL", "dial_code": "+56"},
|
{"name": "Chile", "code": "CL", "iso3Code": "CHL", "dial_code": "+56"},
|
||||||
{"name": "中国大陆", "code": "CN", "iso3Code": "CHN", "dial_code": "+86"},
|
{"name": "中国", "code": "CN", "iso3Code": "CHN", "dial_code": "+86"},
|
||||||
{
|
{
|
||||||
"name": "Christmas Island",
|
"name": "Christmas Island",
|
||||||
"code": "CX",
|
"code": "CX",
|
||||||
@@ -216,7 +216,7 @@ const List<Map<String, String>> codes = [
|
|||||||
},
|
},
|
||||||
{"name": "Vaticano", "code": "VA", "iso3Code": "VAT", "dial_code": "+379"},
|
{"name": "Vaticano", "code": "VA", "iso3Code": "VAT", "dial_code": "+379"},
|
||||||
{"name": "Honduras", "code": "HN", "iso3Code": "HND", "dial_code": "+504"},
|
{"name": "Honduras", "code": "HN", "iso3Code": "HND", "dial_code": "+504"},
|
||||||
{"name": "中國香港", "code": "HK", "iso3Code": "HKG", "dial_code": "+852"},
|
{"name": "香港", "code": "HK", "iso3Code": "HKG", "dial_code": "+852"},
|
||||||
{"name": "Magyarország", "code": "HU", "iso3Code": "HUN", "dial_code": "+36"},
|
{"name": "Magyarország", "code": "HU", "iso3Code": "HUN", "dial_code": "+36"},
|
||||||
{"name": "Ísland", "code": "IS", "iso3Code": "ISL", "dial_code": "+354"},
|
{"name": "Ísland", "code": "IS", "iso3Code": "ISL", "dial_code": "+354"},
|
||||||
{"name": "भारत", "code": "IN", "iso3Code": "IND", "dial_code": "+91"},
|
{"name": "भारत", "code": "IN", "iso3Code": "IND", "dial_code": "+91"},
|
||||||
@@ -258,7 +258,7 @@ const List<Map<String, String>> codes = [
|
|||||||
},
|
},
|
||||||
{"name": "Lietuva", "code": "LT", "iso3Code": "LTU", "dial_code": "+370"},
|
{"name": "Lietuva", "code": "LT", "iso3Code": "LTU", "dial_code": "+370"},
|
||||||
{"name": "Luxembourg", "code": "LU", "iso3Code": "LUX", "dial_code": "+352"},
|
{"name": "Luxembourg", "code": "LU", "iso3Code": "LUX", "dial_code": "+352"},
|
||||||
{"name": "中國澳門", "code": "MO", "iso3Code": "MAC", "dial_code": "+853"},
|
{"name": "澳門", "code": "MO", "iso3Code": "MAC", "dial_code": "+853"},
|
||||||
{"name": "Македонија", "code": "MK", "iso3Code": "MKD", "dial_code": "+389"},
|
{"name": "Македонија", "code": "MK", "iso3Code": "MKD", "dial_code": "+389"},
|
||||||
{
|
{
|
||||||
"name": "Madagasikara",
|
"name": "Madagasikara",
|
||||||
@@ -456,7 +456,7 @@ const List<Map<String, String>> codes = [
|
|||||||
{"name": "Sverige", "code": "SE", "iso3Code": "SWE", "dial_code": "+46"},
|
{"name": "Sverige", "code": "SE", "iso3Code": "SWE", "dial_code": "+46"},
|
||||||
{"name": "Schweiz", "code": "CH", "iso3Code": "CHE", "dial_code": "+41"},
|
{"name": "Schweiz", "code": "CH", "iso3Code": "CHE", "dial_code": "+41"},
|
||||||
{"name": "سوريا", "code": "SY", "iso3Code": "SYR", "dial_code": "+963"},
|
{"name": "سوريا", "code": "SY", "iso3Code": "SYR", "dial_code": "+963"},
|
||||||
{"name": "中國臺灣", "code": "TW", "iso3Code": "TWN", "dial_code": "+886"},
|
{"name": "臺灣", "code": "TW", "iso3Code": "TWN", "dial_code": "+886"},
|
||||||
{"name": "Тоҷикистон", "code": "TJ", "iso3Code": "TJK", "dial_code": "+992"},
|
{"name": "Тоҷикистон", "code": "TJ", "iso3Code": "TJK", "dial_code": "+992"},
|
||||||
{"name": "Tanzania", "code": "TZ", "iso3Code": "TZA", "dial_code": "+255"},
|
{"name": "Tanzania", "code": "TZ", "iso3Code": "TZA", "dial_code": "+255"},
|
||||||
{"name": "ประเทศไทย", "code": "TH", "iso3Code": "THA", "dial_code": "+66"},
|
{"name": "ประเทศไทย", "code": "TH", "iso3Code": "THA", "dial_code": "+66"},
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
"CF": "Central African Republic",
|
"CF": "Central African Republic",
|
||||||
"TD": "Chad",
|
"TD": "Chad",
|
||||||
"CL": "Chile",
|
"CL": "Chile",
|
||||||
"CN": "China's Mainland",
|
"CN": "China",
|
||||||
"CX": "Christmas Island",
|
"CX": "Christmas Island",
|
||||||
"CC": "Cocos (Keeling) Islands",
|
"CC": "Cocos (Keeling) Islands",
|
||||||
"CO": "Colombia",
|
"CO": "Colombia",
|
||||||
@@ -94,7 +94,7 @@
|
|||||||
"HM": "Heard Island and McDonald Islands",
|
"HM": "Heard Island and McDonald Islands",
|
||||||
"VA": "Holy See (Vatican City State)",
|
"VA": "Holy See (Vatican City State)",
|
||||||
"HN": "Honduras",
|
"HN": "Honduras",
|
||||||
"HK": "Hong Kong China",
|
"HK": "Hong Kong",
|
||||||
"HU": "Hungary",
|
"HU": "Hungary",
|
||||||
"IS": "Iceland",
|
"IS": "Iceland",
|
||||||
"IN": "India",
|
"IN": "India",
|
||||||
@@ -123,7 +123,7 @@
|
|||||||
"LI": "Liechtenstein",
|
"LI": "Liechtenstein",
|
||||||
"LT": "Lithuania",
|
"LT": "Lithuania",
|
||||||
"LU": "Luxembourg",
|
"LU": "Luxembourg",
|
||||||
"MO": "Macao China",
|
"MO": "Macao",
|
||||||
"MG": "Madagascar",
|
"MG": "Madagascar",
|
||||||
"MW": "Malawi",
|
"MW": "Malawi",
|
||||||
"MY": "Malaysia",
|
"MY": "Malaysia",
|
||||||
@@ -210,7 +210,10 @@
|
|||||||
"SE": "Sweden",
|
"SE": "Sweden",
|
||||||
"CH": "Switzerland",
|
"CH": "Switzerland",
|
||||||
"SY": "Syrian Arab Republic",
|
"SY": "Syrian Arab Republic",
|
||||||
"TW": "Taiwan China",
|
"TW": [
|
||||||
|
"Taiwan, Province of China",
|
||||||
|
"Taiwan"
|
||||||
|
],
|
||||||
"TJ": "Tajikistan",
|
"TJ": "Tajikistan",
|
||||||
"TZ": "Tanzania, United Republic of",
|
"TZ": "Tanzania, United Republic of",
|
||||||
"TH": "Thailand",
|
"TH": "Thailand",
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
"BH": "Bahrein",
|
"BH": "Bahrein",
|
||||||
"BD": "Bangladesh",
|
"BD": "Bangladesh",
|
||||||
"BB": "Barbade",
|
"BB": "Barbade",
|
||||||
"BY": "Biélorussie",
|
"BY": "Bielorussie",
|
||||||
"BE": "Belgique",
|
"BE": "Belgique",
|
||||||
"BZ": "Belize",
|
"BZ": "Belize",
|
||||||
"BJ": "Bénin",
|
"BJ": "Bénin",
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
"CM": "Cameroun",
|
"CM": "Cameroun",
|
||||||
"CA": "Canada",
|
"CA": "Canada",
|
||||||
"CV": "Cap-Vert",
|
"CV": "Cap-Vert",
|
||||||
"KY": "Îles Caïmans",
|
"KY": "Caïmanes",
|
||||||
"CF": "Centrafricaine, République",
|
"CF": "Centrafricaine, République",
|
||||||
"TD": "Tchad",
|
"TD": "Tchad",
|
||||||
"CL": "Chili",
|
"CL": "Chili",
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
"GI": "Gibraltar",
|
"GI": "Gibraltar",
|
||||||
"GR": "Grèce",
|
"GR": "Grèce",
|
||||||
"GL": "Groenland",
|
"GL": "Groenland",
|
||||||
"GD": "Grenade",
|
"GD": "Grenada",
|
||||||
"GP": "Guadeloupe",
|
"GP": "Guadeloupe",
|
||||||
"GU": "Guam",
|
"GU": "Guam",
|
||||||
"GT": "Guatemala",
|
"GT": "Guatemala",
|
||||||
@@ -110,9 +110,9 @@
|
|||||||
"KZ": "Kazakhstan",
|
"KZ": "Kazakhstan",
|
||||||
"KE": "Kenya",
|
"KE": "Kenya",
|
||||||
"KI": "Kiribati",
|
"KI": "Kiribati",
|
||||||
"KP": "Corée du Nord",
|
"KP": "Corée du Nord, République populaire démocratique",
|
||||||
"KR": "Corée du Sud",
|
"KR": "Corée du Sud, République",
|
||||||
"KW": "Koweït",
|
"KW": "Koweit",
|
||||||
"KG": "Kirghistan",
|
"KG": "Kirghistan",
|
||||||
"LA": "Laos",
|
"LA": "Laos",
|
||||||
"LV": "Lettonie",
|
"LV": "Lettonie",
|
||||||
@@ -179,7 +179,7 @@
|
|||||||
"SH": "Sainte-Hélène",
|
"SH": "Sainte-Hélène",
|
||||||
"KN": "Saint-Christophe-et-Niévès",
|
"KN": "Saint-Christophe-et-Niévès",
|
||||||
"LC": "Sainte-Lucie",
|
"LC": "Sainte-Lucie",
|
||||||
"PM": "Saint-Pierre-et-Miquelon",
|
"PM": "Saint Pierre and Miquelon",
|
||||||
"VC": "Saint-Vincent et les Grenadines",
|
"VC": "Saint-Vincent et les Grenadines",
|
||||||
"WS": "Samoa",
|
"WS": "Samoa",
|
||||||
"SM": "Saint-Marin",
|
"SM": "Saint-Marin",
|
||||||
@@ -200,15 +200,15 @@
|
|||||||
"SD": "Soudan",
|
"SD": "Soudan",
|
||||||
"SR": "Suriname",
|
"SR": "Suriname",
|
||||||
"SJ": "Svalbard et Île Jan Mayen",
|
"SJ": "Svalbard et Île Jan Mayen",
|
||||||
"SZ": "Eswatini",
|
"SZ": "Ngwane, Royaume d'Eswatini",
|
||||||
"SE": "Suède",
|
"SE": "Suède",
|
||||||
"CH": "Suisse",
|
"CH": "Suisse",
|
||||||
"SY": "Syrie",
|
"SY": "Syrie",
|
||||||
"TW": "Taïwan",
|
"TW": "Taïwan",
|
||||||
"TJ": "Tadjikistan",
|
"TJ": "Tadjikistan",
|
||||||
"TZ": "Tanzanie",
|
"TZ": "Tanzanie, République unie",
|
||||||
"TH": "Thaïlande",
|
"TH": "Thaïlande",
|
||||||
"TL": "Timor-Leste",
|
"TL": "Timor Leste",
|
||||||
"TG": "Togo",
|
"TG": "Togo",
|
||||||
"TK": "Tokelau",
|
"TK": "Tokelau",
|
||||||
"TO": "Tonga",
|
"TO": "Tonga",
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
"CK": "库克群岛",
|
"CK": "库克群岛",
|
||||||
"CL": "智利",
|
"CL": "智利",
|
||||||
"CM": "喀麦隆",
|
"CM": "喀麦隆",
|
||||||
"CN": "中国大陆",
|
"CN": "中国",
|
||||||
"CO": "哥伦比亚",
|
"CO": "哥伦比亚",
|
||||||
"CR": "哥斯达黎加",
|
"CR": "哥斯达黎加",
|
||||||
"CU": "古巴",
|
"CU": "古巴",
|
||||||
@@ -226,7 +226,7 @@
|
|||||||
"TR": "土耳其",
|
"TR": "土耳其",
|
||||||
"TT": "特立尼达和多巴哥",
|
"TT": "特立尼达和多巴哥",
|
||||||
"TV": "图瓦卢",
|
"TV": "图瓦卢",
|
||||||
"TW": "中国台湾",
|
"TW": "中国台湾省",
|
||||||
"TZ": "坦桑尼亚",
|
"TZ": "坦桑尼亚",
|
||||||
"UA": "乌克兰",
|
"UA": "乌克兰",
|
||||||
"UG": "乌干达",
|
"UG": "乌干达",
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:diacritic/diacritic.dart';
|
|
||||||
|
|
||||||
import 'country_code.dart';
|
import 'country_code.dart';
|
||||||
import 'country_localizations.dart';
|
import 'country_localizations.dart';
|
||||||
@@ -10,7 +9,6 @@ class SelectionDialog extends StatefulWidget {
|
|||||||
final bool? showCountryOnly;
|
final bool? showCountryOnly;
|
||||||
final InputDecoration searchDecoration;
|
final InputDecoration searchDecoration;
|
||||||
final TextStyle? searchStyle;
|
final TextStyle? searchStyle;
|
||||||
final bool? isFocused;
|
|
||||||
final TextStyle? textStyle;
|
final TextStyle? textStyle;
|
||||||
final TextStyle headerTextStyle;
|
final TextStyle headerTextStyle;
|
||||||
final BoxDecoration? boxDecoration;
|
final BoxDecoration? boxDecoration;
|
||||||
@@ -51,9 +49,8 @@ class SelectionDialog extends StatefulWidget {
|
|||||||
required this.headerTextStyle,
|
required this.headerTextStyle,
|
||||||
InputDecoration searchDecoration = const InputDecoration(),
|
InputDecoration searchDecoration = const InputDecoration(),
|
||||||
this.searchStyle,
|
this.searchStyle,
|
||||||
this.isFocused,
|
|
||||||
this.textStyle,
|
this.textStyle,
|
||||||
required this.topBarPadding,
|
required this.topBarPadding,
|
||||||
this.headerText,
|
this.headerText,
|
||||||
this.boxDecoration,
|
this.boxDecoration,
|
||||||
this.showFlag,
|
this.showFlag,
|
||||||
@@ -65,12 +62,9 @@ class SelectionDialog extends StatefulWidget {
|
|||||||
this.hideSearch = false,
|
this.hideSearch = false,
|
||||||
this.hideCloseIcon = false,
|
this.hideCloseIcon = false,
|
||||||
this.closeIcon,
|
this.closeIcon,
|
||||||
this.dialogItemPadding =
|
this.dialogItemPadding = const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
|
||||||
const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
|
|
||||||
this.searchPadding = const EdgeInsets.symmetric(horizontal: 24),
|
this.searchPadding = const EdgeInsets.symmetric(horizontal: 24),
|
||||||
}) : searchDecoration = searchDecoration.prefixIcon == null
|
}) : searchDecoration = searchDecoration.prefixIcon == null ? searchDecoration.copyWith(prefixIcon: const Icon(Icons.search)) : searchDecoration,
|
||||||
? searchDecoration.copyWith(prefixIcon: const Icon(Icons.search))
|
|
||||||
: searchDecoration,
|
|
||||||
super(key: key);
|
super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -87,8 +81,7 @@ class _SelectionDialogState extends State<SelectionDialog> {
|
|||||||
child: Container(
|
child: Container(
|
||||||
clipBehavior: Clip.hardEdge,
|
clipBehavior: Clip.hardEdge,
|
||||||
width: widget.size?.width ?? MediaQuery.of(context).size.width,
|
width: widget.size?.width ?? MediaQuery.of(context).size.width,
|
||||||
height:
|
height: widget.size?.height ?? MediaQuery.of(context).size.height * 0.85,
|
||||||
widget.size?.height ?? MediaQuery.of(context).size.height * 0.85,
|
|
||||||
decoration: widget.boxDecoration ??
|
decoration: widget.boxDecoration ??
|
||||||
BoxDecoration(
|
BoxDecoration(
|
||||||
color: widget.backgroundColor ?? Colors.white,
|
color: widget.backgroundColor ?? Colors.white,
|
||||||
@@ -107,9 +100,7 @@ class _SelectionDialogState extends State<SelectionDialog> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: !widget.hideHeaderText
|
padding:!widget.hideHeaderText? widget.topBarPadding: EdgeInsets.zero,
|
||||||
? widget.topBarPadding
|
|
||||||
: EdgeInsets.zero,
|
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: widget.headerAlignment,
|
mainAxisAlignment: widget.headerAlignment,
|
||||||
children: [
|
children: [
|
||||||
@@ -134,7 +125,6 @@ class _SelectionDialogState extends State<SelectionDialog> {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: widget.searchPadding,
|
padding: widget.searchPadding,
|
||||||
child: TextField(
|
child: TextField(
|
||||||
autofocus: widget.isFocused ?? false,
|
|
||||||
style: widget.searchStyle,
|
style: widget.searchStyle,
|
||||||
decoration: widget.searchDecoration,
|
decoration: widget.searchDecoration,
|
||||||
onChanged: _filterElements,
|
onChanged: _filterElements,
|
||||||
@@ -187,14 +177,11 @@ class _SelectionDialogState extends State<SelectionDialog> {
|
|||||||
if (widget.showFlag!)
|
if (widget.showFlag!)
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Container(
|
child: Container(
|
||||||
margin: Directionality.of(context) ==
|
margin: Directionality.of(context) == TextDirection.ltr // Here Adding padding depending on the locale language direction
|
||||||
TextDirection
|
|
||||||
.ltr // Here Adding padding depending on the locale language direction
|
|
||||||
? const EdgeInsets.only(right: 16.0)
|
? const EdgeInsets.only(right: 16.0)
|
||||||
: const EdgeInsets.only(left: 16.0),
|
: const EdgeInsets.only(left: 16.0),
|
||||||
decoration: widget.flagDecoration,
|
decoration: widget.flagDecoration,
|
||||||
clipBehavior:
|
clipBehavior: widget.flagDecoration == null ? Clip.none : Clip.hardEdge,
|
||||||
widget.flagDecoration == null ? Clip.none : Clip.hardEdge,
|
|
||||||
child: Image.asset(
|
child: Image.asset(
|
||||||
e.flagUri!,
|
e.flagUri!,
|
||||||
package: 'country_code_picker',
|
package: 'country_code_picker',
|
||||||
@@ -205,9 +192,7 @@ class _SelectionDialogState extends State<SelectionDialog> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
flex: 4,
|
flex: 4,
|
||||||
child: Text(
|
child: Text(
|
||||||
widget.showCountryOnly!
|
widget.showCountryOnly! ? e.toCountryStringOnly() : e.toLongString(),
|
||||||
? e.toCountryStringOnly()
|
|
||||||
: e.toLongString(),
|
|
||||||
overflow: TextOverflow.fade,
|
overflow: TextOverflow.fade,
|
||||||
style: widget.textStyle,
|
style: widget.textStyle,
|
||||||
),
|
),
|
||||||
@@ -223,8 +208,7 @@ class _SelectionDialogState extends State<SelectionDialog> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Center(
|
return Center(
|
||||||
child: Text(CountryLocalizations.of(context)?.translate('no_country') ??
|
child: Text(CountryLocalizations.of(context)?.translate('no_country') ?? 'No country found'),
|
||||||
'No country found'),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,15 +219,9 @@ class _SelectionDialogState extends State<SelectionDialog> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _filterElements(String s) {
|
void _filterElements(String s) {
|
||||||
final normalizedSearch = removeDiacritics(s.toUpperCase());
|
s = s.toUpperCase();
|
||||||
setState(() {
|
setState(() {
|
||||||
filteredElements = widget.elements
|
filteredElements = widget.elements.where((e) => e.code!.contains(s) || e.dialCode!.contains(s) || e.name!.toUpperCase().contains(s)).toList();
|
||||||
.where((e) =>
|
|
||||||
e.code!.contains(normalizedSearch) ||
|
|
||||||
e.dialCode!.contains(normalizedSearch) ||
|
|
||||||
removeDiacritics(e.name!.toUpperCase())
|
|
||||||
.contains(normalizedSearch))
|
|
||||||
.toList();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name: country_code_picker
|
name: country_code_picker
|
||||||
description: A flutter package for showing a country code selector. In addition it gives the possibility to select a list of favorites countries, as well as to search using a simple searchbox
|
description: A flutter package for showing a country code selector. In addition it gives the possibility to select a list of favorites countries, as well as to search using a simple searchbox
|
||||||
version: 3.4.0
|
version: 3.3.0
|
||||||
homepage: https://github.com/chandrabezzo/CountryCodePicker
|
homepage: https://github.com/chandrabezzo/CountryCodePicker
|
||||||
repository: https://github.com/chandrabezzo/CountryCodePicker
|
repository: https://github.com/chandrabezzo/CountryCodePicker
|
||||||
issue_tracker: https://github.com/imtoori/CountryCodePicker/issues
|
issue_tracker: https://github.com/imtoori/CountryCodePicker/issues
|
||||||
|
|||||||
Reference in New Issue
Block a user