Skip to content
This repository was archived by the owner on Jul 20, 2022. It is now read-only.

Commit 3c33192

Browse files
authored
Merge pull request #105 from vlfr1997/master
Added option to change close icon and search icon
2 parents cb84307 + 912d121 commit 3c33192

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/country_code_picker.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class CountryCodePicker extends StatefulWidget {
2323
final Function(CountryCode) builder;
2424
final bool enabled;
2525
final TextOverflow textOverflow;
26+
final Icon closeIcon;
2627

2728
/// Barrier color of ModalBottomSheet
2829
final Color barrierColor;
@@ -96,6 +97,7 @@ class CountryCodePicker extends StatefulWidget {
9697
this.countryFilter,
9798
this.hideSearch = false,
9899
this.dialogSize,
100+
this.closeIcon = const Icon(Icons.close),
99101
Key key,
100102
}) : super(key: key);
101103

@@ -258,6 +260,7 @@ class CountryCodePickerState extends State<CountryCodePicker> {
258260
flagWidth: widget.flagWidth,
259261
size: widget.dialogSize,
260262
hideSearch: widget.hideSearch,
263+
closeIcon: widget.closeIcon,
261264
),
262265
).then((e) {
263266
if (e != null) {

lib/selection_dialog.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class SelectionDialog extends StatefulWidget {
1414
final double flagWidth;
1515
final Size size;
1616
final bool hideSearch;
17+
final Icon closeIcon;
1718

1819
/// elements passed as favorite
1920
final List<CountryCode> favoriteElements;
@@ -32,9 +33,11 @@ class SelectionDialog extends StatefulWidget {
3233
this.flagWidth = 32,
3334
this.size,
3435
this.hideSearch = false,
36+
this.closeIcon,
3537
}) : assert(searchDecoration != null, 'searchDecoration must not be null!'),
36-
this.searchDecoration =
37-
searchDecoration.copyWith(prefixIcon: Icon(Icons.search)),
38+
this.searchDecoration = searchDecoration.prefixIcon == null
39+
? searchDecoration.copyWith(prefixIcon: Icon(Icons.search))
40+
: searchDecoration,
3841
super(key: key);
3942

4043
@override
@@ -75,7 +78,7 @@ class _SelectionDialogState extends State<SelectionDialog> {
7578
IconButton(
7679
padding: const EdgeInsets.all(0),
7780
iconSize: 20,
78-
icon: const Icon(Icons.close),
81+
icon: widget.closeIcon,
7982
onPressed: () => Navigator.pop(context),
8083
),
8184
if (!widget.hideSearch)

0 commit comments

Comments
 (0)