Skip to content

Commit 308f7b2

Browse files
authored
Merge pull request #47 from chandrabezzo/update-3.2.0
Update 3.2.0
2 parents 24580fa + 7f36d14 commit 308f7b2

File tree

5 files changed

+60
-25
lines changed

5 files changed

+60
-25
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 3.2.0 - January 31 2025
2+
- Add country code picker style #6
3+
- Remove Special Character #37
4+
- Fixes for Flutter and Dart SDK Updates and Enhancements #44
5+
16
## 3.1.0 - October 24 2024
27
- Add some improvement
38

lib/country_code_picker.dart

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,16 @@ class CountryCodePicker extends StatefulWidget {
152152
this.closeIcon = const Icon(Icons.close),
153153
this.countryList = codes,
154154
this.pickerStyle = PickerStyle.dialog,
155-
this.dialogItemPadding = const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
155+
this.dialogItemPadding =
156+
const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
156157
this.searchPadding = const EdgeInsets.symmetric(horizontal: 24),
157158
this.headerAlignment = MainAxisAlignment.spaceBetween,
158159
this.headerText = "Select County",
159-
this.headerTextStyle = const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
160+
this.headerTextStyle =
161+
const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
160162
this.hideHeaderText = false,
161-
this.topBarPadding = const EdgeInsets.symmetric(vertical: 5.0, horizontal: 20),
163+
this.topBarPadding =
164+
const EdgeInsets.symmetric(vertical: 5.0, horizontal: 20),
162165
Key? key,
163166
}) : super(key: key);
164167

@@ -167,15 +170,22 @@ class CountryCodePicker extends StatefulWidget {
167170
State<StatefulWidget> createState() {
168171
List<Map<String, String>> jsonList = countryList;
169172

170-
List<CountryCode> elements = jsonList.map((json) => CountryCode.fromJson(json)).toList();
173+
List<CountryCode> elements =
174+
jsonList.map((json) => CountryCode.fromJson(json)).toList();
171175

172176
if (comparator != null) {
173177
elements.sort(comparator);
174178
}
175179

176180
if (countryFilter != null && countryFilter!.isNotEmpty) {
177-
final uppercaseCustomList = countryFilter!.map((criteria) => criteria.toUpperCase()).toList();
178-
elements = elements.where((criteria) => uppercaseCustomList.contains(criteria.code) || uppercaseCustomList.contains(criteria.name) || uppercaseCustomList.contains(criteria.dialCode)).toList();
181+
final uppercaseCustomList =
182+
countryFilter!.map((criteria) => criteria.toUpperCase()).toList();
183+
elements = elements
184+
.where((criteria) =>
185+
uppercaseCustomList.contains(criteria.code) ||
186+
uppercaseCustomList.contains(criteria.name) ||
187+
uppercaseCustomList.contains(criteria.dialCode))
188+
.toList();
179189
}
180190

181191
return CountryCodePickerState(elements, pickerStyle);
@@ -197,7 +207,7 @@ class CountryCodePickerState extends State<CountryCodePicker> {
197207
internalWidget = InkWell(
198208
onTap: pickerStyle == PickerStyle.dialog
199209
? showCountryCodePickerDialog
200-
: showCountryCodePickerBottomSheet
210+
: showCountryCodePickerBottomSheet,
201211
child: widget.builder!(selectedItem),
202212
);
203213
} else {
@@ -213,14 +223,21 @@ class CountryCodePickerState extends State<CountryCodePicker> {
213223
direction: Axis.horizontal,
214224
mainAxisSize: MainAxisSize.min,
215225
children: <Widget>[
216-
if (widget.showFlagMain != null ? widget.showFlagMain! : widget.showFlag)
226+
if (widget.showFlagMain != null
227+
? widget.showFlagMain!
228+
: widget.showFlag)
217229
Flexible(
218230
flex: widget.alignLeft ? 0 : 1,
219231
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
220232
child: Container(
221-
clipBehavior: widget.flagDecoration == null ? Clip.none : Clip.hardEdge,
233+
clipBehavior: widget.flagDecoration == null
234+
? Clip.none
235+
: Clip.hardEdge,
222236
decoration: widget.flagDecoration,
223-
margin: widget.margin ?? (widget.alignLeft ? const EdgeInsets.only(right: 16.0, left: 8.0) : const EdgeInsets.only(right: 16.0)),
237+
margin: widget.margin ??
238+
(widget.alignLeft
239+
? const EdgeInsets.only(right: 16.0, left: 8.0)
240+
: const EdgeInsets.only(right: 16.0)),
224241
child: Image.asset(
225242
selectedItem!.flagUri!,
226243
package: 'country_code_picker',
@@ -232,8 +249,11 @@ class CountryCodePickerState extends State<CountryCodePicker> {
232249
Flexible(
233250
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
234251
child: Text(
235-
widget.showOnlyCountryWhenClosed ? selectedItem!.toCountryStringOnly() : selectedItem.toString(),
236-
style: widget.textStyle ?? Theme.of(context).textTheme.labelLarge,
252+
widget.showOnlyCountryWhenClosed
253+
? selectedItem!.toCountryStringOnly()
254+
: selectedItem.toString(),
255+
style: widget.textStyle ??
256+
Theme.of(context).textTheme.labelLarge,
237257
overflow: widget.textOverflow,
238258
),
239259
),
@@ -242,7 +262,9 @@ class CountryCodePickerState extends State<CountryCodePicker> {
242262
flex: widget.alignLeft ? 0 : 1,
243263
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
244264
child: Padding(
245-
padding: (widget.alignLeft ? const EdgeInsets.only(right: 16.0, left: 8.0) : const EdgeInsets.only(right: 16.0)),
265+
padding: (widget.alignLeft
266+
? const EdgeInsets.only(right: 16.0, left: 8.0)
267+
: const EdgeInsets.only(right: 16.0)),
246268
child: Icon(
247269
Icons.arrow_drop_down,
248270
color: Colors.grey,
@@ -273,9 +295,11 @@ class CountryCodePickerState extends State<CountryCodePicker> {
273295
if (widget.initialSelection != null) {
274296
selectedItem = elements.firstWhere(
275297
(criteria) =>
276-
(criteria.code!.toUpperCase() == widget.initialSelection!.toUpperCase()) ||
298+
(criteria.code!.toUpperCase() ==
299+
widget.initialSelection!.toUpperCase()) ||
277300
(criteria.dialCode == widget.initialSelection) ||
278-
(criteria.name!.toUpperCase() == widget.initialSelection!.toUpperCase()),
301+
(criteria.name!.toUpperCase() ==
302+
widget.initialSelection!.toUpperCase()),
279303
orElse: () => elements[0]);
280304
} else {
281305
selectedItem = elements[0];
@@ -291,24 +315,29 @@ class CountryCodePickerState extends State<CountryCodePicker> {
291315
if (widget.initialSelection != null) {
292316
selectedItem = elements.firstWhere(
293317
(item) =>
294-
(item.code!.toUpperCase() == widget.initialSelection!.toUpperCase()) ||
318+
(item.code!.toUpperCase() ==
319+
widget.initialSelection!.toUpperCase()) ||
295320
(item.dialCode == widget.initialSelection) ||
296-
(item.name!.toUpperCase() == widget.initialSelection!.toUpperCase()),
321+
(item.name!.toUpperCase() ==
322+
widget.initialSelection!.toUpperCase()),
297323
orElse: () => elements[0]);
298324
} else {
299325
selectedItem = elements[0];
300326
}
301327

302328
favoriteElements = elements
303329
.where((item) =>
304-
widget.favorite.firstWhereOrNull((criteria) => item.code!.toUpperCase() == criteria.toUpperCase() || item.dialCode == criteria || item.name!.toUpperCase() == criteria.toUpperCase()) !=
330+
widget.favorite.firstWhereOrNull((criteria) =>
331+
item.code!.toUpperCase() == criteria.toUpperCase() ||
332+
item.dialCode == criteria ||
333+
item.name!.toUpperCase() == criteria.toUpperCase()) !=
305334
null)
306335
.toList();
307336
}
308337

309338
void showCountryCodePickerDialog() async {
310339
final item = await showDialog(
311-
barrierColor: widget.barrierColor ?? Colors.grey.withOpacity(0.5),
340+
barrierColor: widget.barrierColor ?? Colors.grey.withAlpha(128),
312341
context: context,
313342
builder: (context) => Center(
314343
child: Dialog(

lib/src/bottom_sheet.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ class _SelectionBottomSheetState extends State<SelectionBottomSheet> {
7373
borderRadius: const BorderRadius.all(Radius.circular(8.0)),
7474
boxShadow: [
7575
BoxShadow(
76-
color: widget.barrierColor ?? Colors.grey.withOpacity(1),
76+
color: widget.barrierColor ?? Colors.grey
77+
..withAlpha(255),
7778
spreadRadius: 5,
7879
blurRadius: 7,
7980
offset: const Offset(0, 3), // changes position of shadow

lib/src/selection_dialog.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class _SelectionDialogState extends State<SelectionDialog> {
8888
borderRadius: const BorderRadius.all(Radius.circular(8.0)),
8989
boxShadow: [
9090
BoxShadow(
91-
color: widget.barrierColor ?? Colors.grey.withOpacity(1),
91+
color: widget.barrierColor ?? Colors.grey.withAlpha(255),
9292
spreadRadius: 5,
9393
blurRadius: 7,
9494
offset: const Offset(0, 3), // changes position of shadow

pubspec.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
name: country_code_picker
2-
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
3-
version: 3.1.0
2+
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
3+
version: 3.2.0
44
homepage: https://github.com/chandrabezzo/CountryCodePicker
55
repository: https://github.com/chandrabezzo/CountryCodePicker
66
issue_tracker: https://github.com/imtoori/CountryCodePicker/issues
77

88
environment:
9-
sdk: '>=2.17.0 <4.0.0'
9+
sdk: ">=2.17.0 <4.0.0"
1010

1111
dependencies:
1212
flutter:
@@ -87,6 +87,6 @@ flutter:
8787
- packages/country_code_picker/src/i18n/uk.json
8888
- packages/country_code_picker/src/i18n/uz.json
8989
- packages/country_code_picker/src/i18n/zh.json
90-
90+
9191
dev_dependencies:
9292
flutter_lints: ^2.0.1

0 commit comments

Comments
 (0)