Fixed the Issue #43.
Country name attached to flag, no padding, in RTL languages SearchDialog #43 RTL language issue
This commit is contained in:
@@ -93,6 +93,21 @@ class CountryCodePicker extends StatefulWidget {
|
||||
|
||||
final EdgeInsetsGeometry searchPadding;
|
||||
|
||||
///Use This To Hide The Header Text
|
||||
final bool hideHeaderText;
|
||||
|
||||
///Change The Header Text
|
||||
final String? headerText;
|
||||
|
||||
///Header Text Style
|
||||
final TextStyle headerTextStyle;
|
||||
|
||||
///Header Text Padding
|
||||
final EdgeInsets topBarPadding;
|
||||
|
||||
///Header Text Alignment
|
||||
final MainAxisAlignment headerAlignment;
|
||||
|
||||
const CountryCodePicker({
|
||||
this.onChanged,
|
||||
this.onInit,
|
||||
@@ -129,9 +144,13 @@ class CountryCodePicker extends StatefulWidget {
|
||||
this.dialogBackgroundColor,
|
||||
this.closeIcon = const Icon(Icons.close),
|
||||
this.countryList = codes,
|
||||
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.headerAlignment = MainAxisAlignment.spaceBetween,
|
||||
this.headerText = "Select County",
|
||||
this.headerTextStyle = const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
this.hideHeaderText = false,
|
||||
this.topBarPadding = const EdgeInsets.symmetric(vertical: 5.0, horizontal: 20),
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@@ -140,22 +159,15 @@ class CountryCodePicker extends StatefulWidget {
|
||||
State<StatefulWidget> createState() {
|
||||
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) {
|
||||
elements.sort(comparator);
|
||||
}
|
||||
|
||||
if (countryFilter != null && countryFilter!.isNotEmpty) {
|
||||
final uppercaseCustomList =
|
||||
countryFilter!.map((criteria) => criteria.toUpperCase()).toList();
|
||||
elements = elements
|
||||
.where((criteria) =>
|
||||
uppercaseCustomList.contains(criteria.code) ||
|
||||
uppercaseCustomList.contains(criteria.name) ||
|
||||
uppercaseCustomList.contains(criteria.dialCode))
|
||||
.toList();
|
||||
final uppercaseCustomList = 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);
|
||||
@@ -186,21 +198,14 @@ class CountryCodePickerState extends State<CountryCodePicker> {
|
||||
direction: Axis.horizontal,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
if (widget.showFlagMain != null
|
||||
? widget.showFlagMain!
|
||||
: widget.showFlag)
|
||||
if (widget.showFlagMain != null ? widget.showFlagMain! : widget.showFlag)
|
||||
Flexible(
|
||||
flex: widget.alignLeft ? 0 : 1,
|
||||
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
|
||||
child: Container(
|
||||
clipBehavior: widget.flagDecoration == null
|
||||
? Clip.none
|
||||
: Clip.hardEdge,
|
||||
clipBehavior: widget.flagDecoration == null ? Clip.none : Clip.hardEdge,
|
||||
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(
|
||||
selectedItem!.flagUri!,
|
||||
package: 'country_code_picker',
|
||||
@@ -212,11 +217,8 @@ class CountryCodePickerState extends State<CountryCodePicker> {
|
||||
Flexible(
|
||||
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
|
||||
child: Text(
|
||||
widget.showOnlyCountryWhenClosed
|
||||
? selectedItem!.toCountryStringOnly()
|
||||
: selectedItem.toString(),
|
||||
style: widget.textStyle ??
|
||||
Theme.of(context).textTheme.labelLarge,
|
||||
widget.showOnlyCountryWhenClosed ? selectedItem!.toCountryStringOnly() : selectedItem.toString(),
|
||||
style: widget.textStyle ?? Theme.of(context).textTheme.labelLarge,
|
||||
overflow: widget.textOverflow,
|
||||
),
|
||||
),
|
||||
@@ -225,9 +227,7 @@ class CountryCodePickerState extends State<CountryCodePicker> {
|
||||
flex: widget.alignLeft ? 0 : 1,
|
||||
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)),
|
||||
padding: (widget.alignLeft ? const EdgeInsets.only(right: 16.0, left: 8.0) : const EdgeInsets.only(right: 16.0)),
|
||||
child: Icon(
|
||||
Icons.arrow_drop_down,
|
||||
color: Colors.grey,
|
||||
@@ -258,11 +258,9 @@ class CountryCodePickerState extends State<CountryCodePicker> {
|
||||
if (widget.initialSelection != null) {
|
||||
selectedItem = elements.firstWhere(
|
||||
(criteria) =>
|
||||
(criteria.code!.toUpperCase() ==
|
||||
widget.initialSelection!.toUpperCase()) ||
|
||||
(criteria.code!.toUpperCase() == widget.initialSelection!.toUpperCase()) ||
|
||||
(criteria.dialCode == widget.initialSelection) ||
|
||||
(criteria.name!.toUpperCase() ==
|
||||
widget.initialSelection!.toUpperCase()),
|
||||
(criteria.name!.toUpperCase() == widget.initialSelection!.toUpperCase()),
|
||||
orElse: () => elements[0]);
|
||||
} else {
|
||||
selectedItem = elements[0];
|
||||
@@ -278,11 +276,9 @@ class CountryCodePickerState extends State<CountryCodePicker> {
|
||||
if (widget.initialSelection != null) {
|
||||
selectedItem = elements.firstWhere(
|
||||
(item) =>
|
||||
(item.code!.toUpperCase() ==
|
||||
widget.initialSelection!.toUpperCase()) ||
|
||||
(item.code!.toUpperCase() == widget.initialSelection!.toUpperCase()) ||
|
||||
(item.dialCode == widget.initialSelection) ||
|
||||
(item.name!.toUpperCase() ==
|
||||
widget.initialSelection!.toUpperCase()),
|
||||
(item.name!.toUpperCase() == widget.initialSelection!.toUpperCase()),
|
||||
orElse: () => elements[0]);
|
||||
} else {
|
||||
selectedItem = elements[0];
|
||||
@@ -290,10 +286,7 @@ class CountryCodePickerState extends State<CountryCodePicker> {
|
||||
|
||||
favoriteElements = elements
|
||||
.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)
|
||||
.toList();
|
||||
}
|
||||
@@ -316,6 +309,11 @@ class CountryCodePickerState extends State<CountryCodePicker> {
|
||||
showFlag: widget.showFlagDialog ?? widget.showFlag,
|
||||
flagWidth: widget.flagWidth,
|
||||
size: widget.dialogSize,
|
||||
headerAlignment: widget.headerAlignment,
|
||||
headerText: widget.headerText,
|
||||
headerTextStyle: widget.headerTextStyle,
|
||||
hideHeaderText: widget.hideHeaderText,
|
||||
topBarPadding: widget.topBarPadding,
|
||||
backgroundColor: widget.dialogBackgroundColor,
|
||||
barrierColor: widget.barrierColor,
|
||||
hideSearch: widget.hideSearch,
|
||||
|
||||
Reference in New Issue
Block a user