Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add arrow-down icon & decoration for selector #386

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/src/utils/selector_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ class SelectorConfig {
/// Add white space for short dial code
final bool trailingSpace;

/// Add arrow down for select box
final Widget? arrowDownIcon;

/// Customize the box-decoration for selector
final BoxDecoration? selectorDecoration;

const SelectorConfig({
this.selectorType = PhoneInputSelectorType.DROPDOWN,
this.showFlags = true,
Expand All @@ -41,5 +47,7 @@ class SelectorConfig {
this.setSelectorButtonAsPrefixIcon = false,
this.leadingPadding,
this.trailingSpace = true,
this.arrowDownIcon,
this.selectorDecoration,
});
}
13 changes: 13 additions & 0 deletions lib/src/widgets/item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class Item extends StatelessWidget {
final bool withCountryNames;
final double? leadingPadding;
final bool trailingSpace;
final Widget? arrowDownIcon;
final BoxDecoration? selectorDecoration;

const Item({
Key? key,
Expand All @@ -21,6 +23,8 @@ class Item extends StatelessWidget {
this.withCountryNames = false,
this.leadingPadding = 12,
this.trailingSpace = true,
this.arrowDownIcon,
this.selectorDecoration,
}) : super(key: key);

@override
Expand All @@ -30,6 +34,7 @@ class Item extends StatelessWidget {
dialCode = dialCode.padRight(5, " ");
}
return Container(
decoration: selectorDecoration,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
Expand All @@ -46,6 +51,14 @@ class Item extends StatelessWidget {
textDirection: TextDirection.ltr,
style: textStyle,
),
...[
arrowDownIcon ??
Icon(
Icons.arrow_drop_down,
color: Colors.black,
size: 20,
),
]
],
),
);
Expand Down
8 changes: 8 additions & 0 deletions lib/src/widgets/selector_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class SelectorButton extends StatelessWidget {
leadingPadding: selectorConfig.leadingPadding,
trailingSpace: selectorConfig.trailingSpace,
textStyle: selectorTextStyle,
arrowDownIcon: selectorConfig.arrowDownIcon,
selectorDecoration: selectorConfig.selectorDecoration,
),
value: country,
items: mapCountryToDropdownItem(countries),
Expand All @@ -61,6 +63,8 @@ class SelectorButton extends StatelessWidget {
leadingPadding: selectorConfig.leadingPadding,
trailingSpace: selectorConfig.trailingSpace,
textStyle: selectorTextStyle,
arrowDownIcon: selectorConfig.arrowDownIcon,
selectorDecoration: selectorConfig.selectorDecoration,
)
: MaterialButton(
key: Key(TestHelper.DropdownButtonKeyValue),
Expand Down Expand Up @@ -92,6 +96,8 @@ class SelectorButton extends StatelessWidget {
leadingPadding: selectorConfig.leadingPadding,
trailingSpace: selectorConfig.trailingSpace,
textStyle: selectorTextStyle,
arrowDownIcon: selectorConfig.arrowDownIcon,
selectorDecoration: selectorConfig.selectorDecoration,
),
),
);
Expand All @@ -111,6 +117,8 @@ class SelectorButton extends StatelessWidget {
textStyle: selectorTextStyle,
withCountryNames: false,
trailingSpace: selectorConfig.trailingSpace,
arrowDownIcon: selectorConfig.arrowDownIcon,
selectorDecoration: selectorConfig.selectorDecoration,
),
);
}).toList();
Expand Down