Skip to content

Commit

Permalink
Header prefix icon support add
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdullahChauhan committed May 29, 2024
1 parent 88958d4 commit 98dd624
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/custom_dropdown.dart
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ class _CustomDropdownState<T> extends State<CustomDropdown<T>> {
hintBuilder: widget.hintBuilder,
headerBuilder: widget.headerBuilder,
headerListBuilder: widget.headerListBuilder,
prefixIcon: decoration?.prefixIcon,
suffixIcon: decoration?.closedSuffixIcon,
fillColor: decoration?.closedFillColor,
maxLines: widget.maxlines,
Expand Down
4 changes: 4 additions & 0 deletions lib/models/custom_dropdown_decoration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class CustomDropdownDecoration {
/// Suffix icon for opened/expanded state of [CustomDropdown].
final Widget? expandedSuffixIcon;

/// [CustomDropdown] header prefix icon.
final Widget? prefixIcon;

/// Border for closed state of [CustomDropdown].
final BoxBorder? closedBorder;

Expand Down Expand Up @@ -72,6 +75,7 @@ class CustomDropdownDecoration {
this.expandedShadow,
this.closedSuffixIcon,
this.expandedSuffixIcon,
this.prefixIcon,
this.closedBorder,
this.closedBorderRadius,
this.closedErrorBorder,
Expand Down
7 changes: 6 additions & 1 deletion lib/widgets/dropdown_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class _DropDownField<T> extends StatefulWidget {
final String? errorText;
final TextStyle? errorStyle, headerStyle, hintStyle;
final BorderSide? errorBorderSide;
final Widget? suffixIcon;
final Widget? prefixIcon, suffixIcon;
final List<BoxShadow>? shadow;
final EdgeInsets? headerPadding;
final int maxLines;
Expand Down Expand Up @@ -46,6 +46,7 @@ class _DropDownField<T> extends StatefulWidget {
this.shadow,
this.headerListBuilder,
this.hintBuilder,
this.prefixIcon,
this.suffixIcon,
this.headerPadding,
});
Expand Down Expand Up @@ -134,6 +135,10 @@ class _DropDownFieldState<T> extends State<_DropDownField<T>> {
),
child: Row(
children: [
if (widget.prefixIcon != null) ...[
widget.prefixIcon!,
const SizedBox(width: 12),
],
Expanded(
child: switch (widget.dropdownType) {
_DropdownType.singleSelect => selectedItem != null
Expand Down
15 changes: 15 additions & 0 deletions lib/widgets/dropdown_overlay/dropdown_overlay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,11 @@ class _DropdownOverlayState<T> extends State<_DropdownOverlay<T>> {
_defaultHeaderPadding,
child: Row(
children: [
if (widget.decoration?.prefixIcon !=
null) ...[
widget.decoration!.prefixIcon!,
const SizedBox(width: 12),
],
Expanded(
child: switch (
widget.dropdownType) {
Expand Down Expand Up @@ -406,6 +411,11 @@ class _DropdownOverlayState<T> extends State<_DropdownOverlay<T>> {
),
child: Row(
children: [
if (widget.decoration?.prefixIcon !=
null) ...[
widget.decoration!.prefixIcon!,
const SizedBox(width: 12),
],
Expanded(
child:
_SearchField<T>.forListData(
Expand Down Expand Up @@ -463,6 +473,11 @@ class _DropdownOverlayState<T> extends State<_DropdownOverlay<T>> {
),
child: Row(
children: [
if (widget.decoration?.prefixIcon !=
null) ...[
widget.decoration!.prefixIcon!,
const SizedBox(width: 12),
],
Expanded(
child: _SearchField<
T>.forRequestData(
Expand Down

0 comments on commit 98dd624

Please sign in to comment.