flutter format

This commit is contained in:
Salvatore Giordano
2020-12-11 23:27:23 +01:00
parent 1eafff660c
commit bc3e7ea568

View File

@@ -114,7 +114,7 @@ class CountryCodePicker extends StatefulWidget {
List<Map> jsonList = codes; List<Map> jsonList = codes;
List<CountryCode> elements = List<CountryCode> elements =
jsonList.map((json) => CountryCode.fromJson(json)).toList(); jsonList.map((json) => CountryCode.fromJson(json)).toList();
if (comparator != null) { if (comparator != null) {
elements.sort(comparator); elements.sort(comparator);
@@ -122,12 +122,12 @@ class CountryCodePicker extends StatefulWidget {
if (countryFilter != null && countryFilter.isNotEmpty) { if (countryFilter != null && countryFilter.isNotEmpty) {
final uppercaseCustomList = final uppercaseCustomList =
countryFilter.map((c) => c.toUpperCase()).toList(); countryFilter.map((c) => c.toUpperCase()).toList();
elements = elements elements = elements
.where((c) => .where((c) =>
uppercaseCustomList.contains(c.code) || uppercaseCustomList.contains(c.code) ||
uppercaseCustomList.contains(c.name) || uppercaseCustomList.contains(c.name) ||
uppercaseCustomList.contains(c.dialCode)) uppercaseCustomList.contains(c.dialCode))
.toList(); .toList();
} }
@@ -158,7 +158,6 @@ 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 if (widget.showFlagMain != null
? widget.showFlagMain ? widget.showFlagMain
: widget.showFlag) : widget.showFlag)
@@ -176,7 +175,6 @@ class CountryCodePickerState extends State<CountryCodePicker> {
), ),
), ),
), ),
if (!widget.hideMainText) if (!widget.hideMainText)
Flexible( Flexible(
fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose, fit: widget.alignLeft ? FlexFit.tight : FlexFit.loose,
@@ -184,14 +182,11 @@ class CountryCodePickerState extends State<CountryCodePicker> {
widget.showOnlyCountryWhenClosed widget.showOnlyCountryWhenClosed
? selectedItem.toCountryStringOnly() ? selectedItem.toCountryStringOnly()
: selectedItem.toString(), : selectedItem.toString(),
style: widget.textStyle ?? Theme style: widget.textStyle ?? Theme.of(context).textTheme.button,
.of(context)
.textTheme
.button,
overflow: widget.textOverflow, overflow: widget.textOverflow,
), ),
), ),
if(widget.showDropDownButton) if (widget.showDropDownButton)
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,
@@ -199,9 +194,11 @@ class CountryCodePickerState extends State<CountryCodePicker> {
padding: widget.alignLeft padding: widget.alignLeft
? const EdgeInsets.only(right: 16.0, left: 8.0) ? const EdgeInsets.only(right: 16.0, left: 8.0)
: const EdgeInsets.only(right: 16.0), : const EdgeInsets.only(right: 16.0),
child: Icon(Icons.arrow_drop_down, color: Colors.grey, child: Icon(
size: widget.flagWidth,) Icons.arrow_drop_down,
), color: Colors.grey,
size: widget.flagWidth,
)),
), ),
], ],
), ),
@@ -225,9 +222,9 @@ class CountryCodePickerState extends State<CountryCodePicker> {
if (oldWidget.initialSelection != widget.initialSelection) { if (oldWidget.initialSelection != widget.initialSelection) {
if (widget.initialSelection != null) { if (widget.initialSelection != null) {
selectedItem = elements.firstWhere( selectedItem = elements.firstWhere(
(e) => (e) =>
(e.code.toUpperCase() == (e.code.toUpperCase() ==
widget.initialSelection.toUpperCase()) || widget.initialSelection.toUpperCase()) ||
(e.dialCode == widget.initialSelection) || (e.dialCode == widget.initialSelection) ||
(e.name.toUpperCase() == widget.initialSelection.toUpperCase()), (e.name.toUpperCase() == widget.initialSelection.toUpperCase()),
orElse: () => elements[0]); orElse: () => elements[0]);
@@ -244,8 +241,8 @@ class CountryCodePickerState extends State<CountryCodePicker> {
if (widget.initialSelection != null) { if (widget.initialSelection != null) {
selectedItem = elements.firstWhere( selectedItem = elements.firstWhere(
(e) => (e) =>
(e.code.toUpperCase() == widget.initialSelection.toUpperCase()) || (e.code.toUpperCase() == widget.initialSelection.toUpperCase()) ||
(e.dialCode == widget.initialSelection) || (e.dialCode == widget.initialSelection) ||
(e.name.toUpperCase() == widget.initialSelection.toUpperCase()), (e.name.toUpperCase() == widget.initialSelection.toUpperCase()),
orElse: () => elements[0]); orElse: () => elements[0]);
@@ -255,13 +252,13 @@ class CountryCodePickerState extends State<CountryCodePicker> {
favoriteElements = elements favoriteElements = elements
.where((e) => .where((e) =>
widget.favorite.firstWhere( widget.favorite.firstWhere(
(f) => (f) =>
e.code.toUpperCase() == f.toUpperCase() || e.code.toUpperCase() == f.toUpperCase() ||
e.dialCode == f || e.dialCode == f ||
e.name.toUpperCase() == f.toUpperCase(), e.name.toUpperCase() == f.toUpperCase(),
orElse: () => null) != orElse: () => null) !=
null) null)
.toList(); .toList();
} }