Skip to content

Commit

Permalink
Propagate base style and other pros through the DefaultTextStyle
Browse files Browse the repository at this point in the history
  • Loading branch information
vasilich6107 committed Dec 5, 2024
1 parent 13c5135 commit 1e66fe1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
23 changes: 17 additions & 6 deletions lib/dropdown_search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -361,12 +361,17 @@ class DropdownSearchState<T> extends State<DropdownSearch<T>> {
}

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,
Expand All @@ -376,10 +381,16 @@ class DropdownSearchState<T> extends State<DropdownSearch<T>> {
),
);
}
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,
);
}

Expand Down
11 changes: 11 additions & 0 deletions lib/src/properties/dropdown_props.dart
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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,
Expand Down

0 comments on commit 1e66fe1

Please sign in to comment.