From c4d981f78e79ceb5555e33059d4fb0ab42fafde0 Mon Sep 17 00:00:00 2001 From: Mohammed Naser Abu Shuqair <121582109+MohammedShuqair@users.noreply.github.com> Date: Sun, 8 Dec 2024 10:37:36 +0200 Subject: [PATCH] add fitted box option --- lib/src/base_dropdown_search.dart | 8 +++++++- lib/src/properties/dropdown_props.dart | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/src/base_dropdown_search.dart b/lib/src/base_dropdown_search.dart index 24cdd926..cbd5ef1b 100644 --- a/lib/src/base_dropdown_search.dart +++ b/lib/src/base_dropdown_search.dart @@ -470,8 +470,14 @@ class DropdownSearchState extends State> { } else if (isMultiSelectionMode) { return defaultSelectedItems(getSelectedItems); } + Widget? buildSelectedItemWidget() { + if (widget.decoratorProps.isFittedBox) { + return FittedBox(child: defaultSelectedItemWidget(getSelectedItem)); + } + return defaultSelectedItemWidget(getSelectedItem); + } - return defaultSelectedItemWidget(getSelectedItem); + return buildSelectedItemWidget(); } TextStyle? _getBaseTextStyle() { diff --git a/lib/src/properties/dropdown_props.dart b/lib/src/properties/dropdown_props.dart index 26f8e4fb..f5869611 100644 --- a/lib/src/properties/dropdown_props.dart +++ b/lib/src/properties/dropdown_props.dart @@ -43,6 +43,7 @@ class DropDownDecoratorProps { final TextAlignVertical? textAlignVertical; final bool expands; final bool isHovering; + final bool isFittedBox; const DropDownDecoratorProps({ this.decoration, @@ -51,5 +52,6 @@ class DropDownDecoratorProps { this.textAlignVertical, this.expands = false, this.isHovering = false, + this.isFittedBox = false, }); }