diff --git a/lib/dropdown_search.dart b/lib/dropdown_search.dart index 3abe4754..00d46645 100644 --- a/lib/dropdown_search.dart +++ b/lib/dropdown_search.dart @@ -361,12 +361,17 @@ class DropdownSearchState extends State> { } Widget selectedItemWidget() { + Widget selectedItem = Text( + _itemAsString(getSelectedItem), + ); + if (widget.dropdownBuilder != null) { - return widget.dropdownBuilder!(context, getSelectedItem); + selectedItem = widget.dropdownBuilder!(context, getSelectedItem); } else if (widget.dropdownBuilderMultiSelection != null) { - return widget.dropdownBuilderMultiSelection!(context, getSelectedItems); + selectedItem = + widget.dropdownBuilderMultiSelection!(context, getSelectedItems); } else if (isMultiSelectionMode) { - return CustomSingleScrollView( + selectedItem = CustomSingleScrollView( scrollProps: widget.selectedItemsScrollProps ?? ScrollProps(), child: Wrap( crossAxisAlignment: WrapCrossAlignment.center, @@ -376,10 +381,16 @@ class DropdownSearchState extends State> { ), ); } - return Text( - _itemAsString(getSelectedItem), - style: _getBaseTextStyle(), + + return DefaultTextStyle( + style: _getBaseTextStyle() ?? DefaultTextStyle.of(context).style, textAlign: widget.decoratorProps.textAlign, + softWrap: widget.decoratorProps.softWrap, + overflow: widget.decoratorProps.overflow, + maxLines: widget.decoratorProps.maxLines, + textWidthBasis: widget.decoratorProps.textWidthBasis, + textHeightBehavior: widget.decoratorProps.textHeightBehavior, + child: selectedItem, ); } diff --git a/lib/src/properties/dropdown_props.dart b/lib/src/properties/dropdown_props.dart index 77cde907..6b38801a 100644 --- a/lib/src/properties/dropdown_props.dart +++ b/lib/src/properties/dropdown_props.dart @@ -1,5 +1,6 @@ import 'package:dropdown_search/dropdown_search.dart'; import 'package:flutter/material.dart'; +import 'dart:ui' as ui show TextHeightBehavior; class DropdownButtonProps extends IconButtonProps { final Widget iconOpened; @@ -351,6 +352,11 @@ class DropDownDecoratorProps { final InputDecoration decoration; final TextStyle? baseStyle; final TextAlign? textAlign; + final bool softWrap; + final TextOverflow overflow; + final int? maxLines; + final TextWidthBasis textWidthBasis; + final ui.TextHeightBehavior? textHeightBehavior; final TextAlignVertical? textAlignVertical; final bool expands; final bool isHovering; @@ -362,6 +368,11 @@ class DropDownDecoratorProps { ), this.baseStyle, this.textAlign, + this.softWrap = true, + this.overflow = TextOverflow.clip, + this.maxLines, + this.textWidthBasis = TextWidthBasis.parent, + this.textHeightBehavior, this.textAlignVertical, this.expands = false, this.isHovering = false,