From 698bcc48304abf5b178cd881806dc331961dc3b7 Mon Sep 17 00:00:00 2001 From: Abdo-Nabil <93052392+Abdo-Nabil@users.noreply.github.com> Date: Thu, 31 Jul 2025 23:29:12 +0300 Subject: [PATCH] Add optional parameter spaceAfterDropdownIcon --- lib/country_code_picker.dart | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index c4b5260..f01d793 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -115,6 +115,9 @@ class CountryCodePicker extends StatefulWidget { ///Header Text Alignment final MainAxisAlignment headerAlignment; + /// space after dropdown icon if shown + final double? spaceAfterDropdownIcon; + const CountryCodePicker({ this.onChanged, this.onInit, @@ -159,6 +162,7 @@ class CountryCodePicker extends StatefulWidget { this.headerTextStyle = const TextStyle(fontSize: 18, fontWeight: FontWeight.bold), this.hideHeaderText = false, this.topBarPadding = const EdgeInsets.symmetric(vertical: 5.0, horizontal: 20), + this.spaceAfterDropdownIcon, Key? key, }) : super(key: key); @@ -177,9 +181,9 @@ class CountryCodePicker extends StatefulWidget { final uppercaseCustomList = countryFilter!.map((criteria) => criteria.toUpperCase()).toList(); elements = elements .where((criteria) => - uppercaseCustomList.contains(criteria.code) || - uppercaseCustomList.contains(criteria.name) || - uppercaseCustomList.contains(criteria.dialCode)) + uppercaseCustomList.contains(criteria.code) || + uppercaseCustomList.contains(criteria.name) || + uppercaseCustomList.contains(criteria.dialCode)) .toList(); } @@ -207,8 +211,8 @@ class CountryCodePickerState extends State { internalWidget = TextButton( onPressed: widget.enabled ? pickerStyle == PickerStyle.dialog - ? showCountryCodePickerDialog - : showCountryCodePickerBottomSheet + ? showCountryCodePickerDialog + : showCountryCodePickerBottomSheet : null, child: Padding( padding: widget.padding, @@ -249,8 +253,8 @@ class CountryCodePickerState extends State { fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose, child: Padding( padding: (widget.alignLeft - ? const EdgeInsets.only(right: 16.0, left: 8.0) - : const EdgeInsets.only(right: 16.0)), + ? EdgeInsets.only(right: widget.spaceAfterDropdownIcon?? 16.0, left: 8.0) + : EdgeInsets.only(right: widget.spaceAfterDropdownIcon?? 16.0)), child: Icon( Icons.arrow_drop_down, color: Colors.grey, @@ -280,8 +284,8 @@ class CountryCodePickerState extends State { if (oldWidget.initialSelection != widget.initialSelection) { if (widget.initialSelection != null) { selectedItem = elements.firstWhere( - (criteria) => - (criteria.code!.toUpperCase() == widget.initialSelection!.toUpperCase()) || + (criteria) => + (criteria.code!.toUpperCase() == widget.initialSelection!.toUpperCase()) || (criteria.dialCode == widget.initialSelection) || (criteria.name!.toUpperCase() == widget.initialSelection!.toUpperCase()), orElse: () => elements[0]); @@ -298,8 +302,8 @@ class CountryCodePickerState extends State { if (widget.initialSelection != null) { selectedItem = elements.firstWhere( - (item) => - (item.code!.toUpperCase() == widget.initialSelection!.toUpperCase()) || + (item) => + (item.code!.toUpperCase() == widget.initialSelection!.toUpperCase()) || (item.dialCode == widget.initialSelection) || (item.name!.toUpperCase() == widget.initialSelection!.toUpperCase()), orElse: () => elements[0]); @@ -309,11 +313,11 @@ class CountryCodePickerState extends State { favoriteElements = elements .where((item) => - widget.favorite.firstWhereOrNull((criteria) => - item.code!.toUpperCase() == criteria.toUpperCase() || - item.dialCode == criteria || - item.name!.toUpperCase() == criteria.toUpperCase()) != - null) + widget.favorite.firstWhereOrNull((criteria) => + item.code!.toUpperCase() == criteria.toUpperCase() || + item.dialCode == criteria || + item.name!.toUpperCase() == criteria.toUpperCase()) != + null) .toList(); }