@@ -1,3 +1,8 @@
|
|||||||
|
## 3.2.0 - January 31 2025
|
||||||
|
- Add country code picker style #6
|
||||||
|
- Remove Special Character #37
|
||||||
|
- Fixes for Flutter and Dart SDK Updates and Enhancements #44
|
||||||
|
|
||||||
## 3.1.0 - October 24 2024
|
## 3.1.0 - October 24 2024
|
||||||
- Add some improvement
|
- Add some improvement
|
||||||
|
|
||||||
|
|||||||
@@ -152,13 +152,16 @@ class CountryCodePicker extends StatefulWidget {
|
|||||||
this.closeIcon = const Icon(Icons.close),
|
this.closeIcon = const Icon(Icons.close),
|
||||||
this.countryList = codes,
|
this.countryList = codes,
|
||||||
this.pickerStyle = PickerStyle.dialog,
|
this.pickerStyle = PickerStyle.dialog,
|
||||||
this.dialogItemPadding = const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
|
this.dialogItemPadding =
|
||||||
|
const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
|
||||||
this.searchPadding = const EdgeInsets.symmetric(horizontal: 24),
|
this.searchPadding = const EdgeInsets.symmetric(horizontal: 24),
|
||||||
this.headerAlignment = MainAxisAlignment.spaceBetween,
|
this.headerAlignment = MainAxisAlignment.spaceBetween,
|
||||||
this.headerText = "Select County",
|
this.headerText = "Select County",
|
||||||
this.headerTextStyle = const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
this.headerTextStyle =
|
||||||
|
const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||||
this.hideHeaderText = false,
|
this.hideHeaderText = false,
|
||||||
this.topBarPadding = const EdgeInsets.symmetric(vertical: 5.0, horizontal: 20),
|
this.topBarPadding =
|
||||||
|
const EdgeInsets.symmetric(vertical: 5.0, horizontal: 20),
|
||||||
Key? key,
|
Key? key,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@@ -167,15 +170,22 @@ class CountryCodePicker extends StatefulWidget {
|
|||||||
State<StatefulWidget> createState() {
|
State<StatefulWidget> createState() {
|
||||||
List<Map<String, String>> jsonList = countryList;
|
List<Map<String, String>> jsonList = countryList;
|
||||||
|
|
||||||
List<CountryCode> elements = jsonList.map((json) => CountryCode.fromJson(json)).toList();
|
List<CountryCode> elements =
|
||||||
|
jsonList.map((json) => CountryCode.fromJson(json)).toList();
|
||||||
|
|
||||||
if (comparator != null) {
|
if (comparator != null) {
|
||||||
elements.sort(comparator);
|
elements.sort(comparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (countryFilter != null && countryFilter!.isNotEmpty) {
|
if (countryFilter != null && countryFilter!.isNotEmpty) {
|
||||||
final uppercaseCustomList = countryFilter!.map((criteria) => criteria.toUpperCase()).toList();
|
final uppercaseCustomList =
|
||||||
elements = elements.where((criteria) => uppercaseCustomList.contains(criteria.code) || uppercaseCustomList.contains(criteria.name) || uppercaseCustomList.contains(criteria.dialCode)).toList();
|
countryFilter!.map((criteria) => criteria.toUpperCase()).toList();
|
||||||
|
elements = elements
|
||||||
|
.where((criteria) =>
|
||||||
|
uppercaseCustomList.contains(criteria.code) ||
|
||||||
|
uppercaseCustomList.contains(criteria.name) ||
|
||||||
|
uppercaseCustomList.contains(criteria.dialCode))
|
||||||
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
return CountryCodePickerState(elements, pickerStyle);
|
return CountryCodePickerState(elements, pickerStyle);
|
||||||
@@ -197,7 +207,7 @@ class CountryCodePickerState extends State<CountryCodePicker> {
|
|||||||
internalWidget = InkWell(
|
internalWidget = InkWell(
|
||||||
onTap: pickerStyle == PickerStyle.dialog
|
onTap: pickerStyle == PickerStyle.dialog
|
||||||
? showCountryCodePickerDialog
|
? showCountryCodePickerDialog
|
||||||
: showCountryCodePickerBottomSheet
|
: showCountryCodePickerBottomSheet,
|
||||||
child: widget.builder!(selectedItem),
|
child: widget.builder!(selectedItem),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -213,14 +223,21 @@ class CountryCodePickerState extends State<CountryCodePicker> {
|
|||||||
direction: Axis.horizontal,
|
direction: Axis.horizontal,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
if (widget.showFlagMain != null ? widget.showFlagMain! : widget.showFlag)
|
if (widget.showFlagMain != null
|
||||||
|
? widget.showFlagMain!
|
||||||
|
: widget.showFlag)
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: widget.alignLeft ? 0 : 1,
|
flex: widget.alignLeft ? 0 : 1,
|
||||||
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
|
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
|
||||||
child: Container(
|
child: Container(
|
||||||
clipBehavior: widget.flagDecoration == null ? Clip.none : Clip.hardEdge,
|
clipBehavior: widget.flagDecoration == null
|
||||||
|
? Clip.none
|
||||||
|
: Clip.hardEdge,
|
||||||
decoration: widget.flagDecoration,
|
decoration: widget.flagDecoration,
|
||||||
margin: widget.margin ?? (widget.alignLeft ? const EdgeInsets.only(right: 16.0, left: 8.0) : const EdgeInsets.only(right: 16.0)),
|
margin: widget.margin ??
|
||||||
|
(widget.alignLeft
|
||||||
|
? const EdgeInsets.only(right: 16.0, left: 8.0)
|
||||||
|
: const EdgeInsets.only(right: 16.0)),
|
||||||
child: Image.asset(
|
child: Image.asset(
|
||||||
selectedItem!.flagUri!,
|
selectedItem!.flagUri!,
|
||||||
package: 'country_code_picker',
|
package: 'country_code_picker',
|
||||||
@@ -232,8 +249,11 @@ class CountryCodePickerState extends State<CountryCodePicker> {
|
|||||||
Flexible(
|
Flexible(
|
||||||
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
|
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
|
||||||
child: Text(
|
child: Text(
|
||||||
widget.showOnlyCountryWhenClosed ? selectedItem!.toCountryStringOnly() : selectedItem.toString(),
|
widget.showOnlyCountryWhenClosed
|
||||||
style: widget.textStyle ?? Theme.of(context).textTheme.labelLarge,
|
? selectedItem!.toCountryStringOnly()
|
||||||
|
: selectedItem.toString(),
|
||||||
|
style: widget.textStyle ??
|
||||||
|
Theme.of(context).textTheme.labelLarge,
|
||||||
overflow: widget.textOverflow,
|
overflow: widget.textOverflow,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -242,7 +262,9 @@ class CountryCodePickerState extends State<CountryCodePicker> {
|
|||||||
flex: widget.alignLeft ? 0 : 1,
|
flex: widget.alignLeft ? 0 : 1,
|
||||||
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
|
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: (widget.alignLeft ? const EdgeInsets.only(right: 16.0, left: 8.0) : const EdgeInsets.only(right: 16.0)),
|
padding: (widget.alignLeft
|
||||||
|
? const EdgeInsets.only(right: 16.0, left: 8.0)
|
||||||
|
: const EdgeInsets.only(right: 16.0)),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.arrow_drop_down,
|
Icons.arrow_drop_down,
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
@@ -273,9 +295,11 @@ class CountryCodePickerState extends State<CountryCodePicker> {
|
|||||||
if (widget.initialSelection != null) {
|
if (widget.initialSelection != null) {
|
||||||
selectedItem = elements.firstWhere(
|
selectedItem = elements.firstWhere(
|
||||||
(criteria) =>
|
(criteria) =>
|
||||||
(criteria.code!.toUpperCase() == widget.initialSelection!.toUpperCase()) ||
|
(criteria.code!.toUpperCase() ==
|
||||||
|
widget.initialSelection!.toUpperCase()) ||
|
||||||
(criteria.dialCode == widget.initialSelection) ||
|
(criteria.dialCode == widget.initialSelection) ||
|
||||||
(criteria.name!.toUpperCase() == widget.initialSelection!.toUpperCase()),
|
(criteria.name!.toUpperCase() ==
|
||||||
|
widget.initialSelection!.toUpperCase()),
|
||||||
orElse: () => elements[0]);
|
orElse: () => elements[0]);
|
||||||
} else {
|
} else {
|
||||||
selectedItem = elements[0];
|
selectedItem = elements[0];
|
||||||
@@ -291,9 +315,11 @@ class CountryCodePickerState extends State<CountryCodePicker> {
|
|||||||
if (widget.initialSelection != null) {
|
if (widget.initialSelection != null) {
|
||||||
selectedItem = elements.firstWhere(
|
selectedItem = elements.firstWhere(
|
||||||
(item) =>
|
(item) =>
|
||||||
(item.code!.toUpperCase() == widget.initialSelection!.toUpperCase()) ||
|
(item.code!.toUpperCase() ==
|
||||||
|
widget.initialSelection!.toUpperCase()) ||
|
||||||
(item.dialCode == widget.initialSelection) ||
|
(item.dialCode == widget.initialSelection) ||
|
||||||
(item.name!.toUpperCase() == widget.initialSelection!.toUpperCase()),
|
(item.name!.toUpperCase() ==
|
||||||
|
widget.initialSelection!.toUpperCase()),
|
||||||
orElse: () => elements[0]);
|
orElse: () => elements[0]);
|
||||||
} else {
|
} else {
|
||||||
selectedItem = elements[0];
|
selectedItem = elements[0];
|
||||||
@@ -301,14 +327,17 @@ class CountryCodePickerState extends State<CountryCodePicker> {
|
|||||||
|
|
||||||
favoriteElements = elements
|
favoriteElements = elements
|
||||||
.where((item) =>
|
.where((item) =>
|
||||||
widget.favorite.firstWhereOrNull((criteria) => item.code!.toUpperCase() == criteria.toUpperCase() || item.dialCode == criteria || item.name!.toUpperCase() == criteria.toUpperCase()) !=
|
widget.favorite.firstWhereOrNull((criteria) =>
|
||||||
|
item.code!.toUpperCase() == criteria.toUpperCase() ||
|
||||||
|
item.dialCode == criteria ||
|
||||||
|
item.name!.toUpperCase() == criteria.toUpperCase()) !=
|
||||||
null)
|
null)
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void showCountryCodePickerDialog() async {
|
void showCountryCodePickerDialog() async {
|
||||||
final item = await showDialog(
|
final item = await showDialog(
|
||||||
barrierColor: widget.barrierColor ?? Colors.grey.withOpacity(0.5),
|
barrierColor: widget.barrierColor ?? Colors.grey.withAlpha(128),
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => Center(
|
builder: (context) => Center(
|
||||||
child: Dialog(
|
child: Dialog(
|
||||||
|
|||||||
@@ -73,7 +73,8 @@ class _SelectionBottomSheetState extends State<SelectionBottomSheet> {
|
|||||||
borderRadius: const BorderRadius.all(Radius.circular(8.0)),
|
borderRadius: const BorderRadius.all(Radius.circular(8.0)),
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
color: widget.barrierColor ?? Colors.grey.withOpacity(1),
|
color: widget.barrierColor ?? Colors.grey
|
||||||
|
..withAlpha(255),
|
||||||
spreadRadius: 5,
|
spreadRadius: 5,
|
||||||
blurRadius: 7,
|
blurRadius: 7,
|
||||||
offset: const Offset(0, 3), // changes position of shadow
|
offset: const Offset(0, 3), // changes position of shadow
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ class _SelectionDialogState extends State<SelectionDialog> {
|
|||||||
borderRadius: const BorderRadius.all(Radius.circular(8.0)),
|
borderRadius: const BorderRadius.all(Radius.circular(8.0)),
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
color: widget.barrierColor ?? Colors.grey.withOpacity(1),
|
color: widget.barrierColor ?? Colors.grey.withAlpha(255),
|
||||||
spreadRadius: 5,
|
spreadRadius: 5,
|
||||||
blurRadius: 7,
|
blurRadius: 7,
|
||||||
offset: const Offset(0, 3), // changes position of shadow
|
offset: const Offset(0, 3), // changes position of shadow
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
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.1.0
|
version: 3.2.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
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=2.17.0 <4.0.0'
|
sdk: ">=2.17.0 <4.0.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
@@ -87,6 +87,6 @@ flutter:
|
|||||||
- packages/country_code_picker/src/i18n/uk.json
|
- packages/country_code_picker/src/i18n/uk.json
|
||||||
- packages/country_code_picker/src/i18n/uz.json
|
- packages/country_code_picker/src/i18n/uz.json
|
||||||
- packages/country_code_picker/src/i18n/zh.json
|
- packages/country_code_picker/src/i18n/zh.json
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_lints: ^2.0.1
|
flutter_lints: ^2.0.1
|
||||||
|
|||||||
Reference in New Issue
Block a user