diff --git a/packages/flet/lib/src/controls/dropdown.dart b/packages/flet/lib/src/controls/dropdown.dart index 3153701f9..34d10c59c 100644 --- a/packages/flet/lib/src/controls/dropdown.dart +++ b/packages/flet/lib/src/controls/dropdown.dart @@ -97,15 +97,22 @@ class _DropdownControlState extends State with FletStoreMixin { .map((v) => v.control) .where((c) => c.name == null && c.isVisible) .map>((Control itemCtrl) { + bool itemDisabled = disabled || itemCtrl.isDisabled; + TextStyle? textStyle = + parseTextStyle(Theme.of(context), itemCtrl, "textStyle"); + if (itemDisabled && textStyle != null) { + textStyle = textStyle.apply(color: Theme.of(context).disabledColor); + } Widget itemChild = Text( itemCtrl.attrs["text"] ?? itemCtrl.attrs["key"] ?? itemCtrl.id, + style: textStyle, ); var align = parseAlignment(itemCtrl, "alignment"); if (align != null) { itemChild = Container(alignment: align, child: itemChild); } return DropdownMenuItem( - enabled: !(disabled || itemCtrl.isDisabled), + enabled: !itemDisabled, value: itemCtrl.attrs["key"] ?? itemCtrl.attrs["text"] ?? itemCtrl.id, alignment: align ?? AlignmentDirectional.centerStart, onTap: !(disabled || itemCtrl.isDisabled) diff --git a/sdk/python/packages/flet-core/src/flet_core/dropdown.py b/sdk/python/packages/flet-core/src/flet_core/dropdown.py index 3e0f810f8..77322ac78 100644 --- a/sdk/python/packages/flet-core/src/flet_core/dropdown.py +++ b/sdk/python/packages/flet-core/src/flet_core/dropdown.py @@ -24,6 +24,7 @@ def __init__( key: Optional[str] = None, text: Optional[str] = None, alignment: Optional[Alignment] = None, + text_style: Optional[TextStyle] = None, on_click=None, # # Control @@ -39,6 +40,7 @@ def __init__( self.text = text self.on_click = on_click self.alignment = alignment + self.text_style = text_style def _get_control_name(self): return "dropdownoption" @@ -46,6 +48,8 @@ def _get_control_name(self): def before_update(self): super().before_update() self._set_attr_json("alignment", self.__alignment) + if isinstance(self.__text_style, TextStyle): + self._set_attr_json("textStyle", self.__text_style) # key @property @@ -74,6 +78,15 @@ def alignment(self) -> Optional[Alignment]: def alignment(self, value: Optional[Alignment]): self.__alignment = value + # text_style + @property + def text_style(self) -> Optional[TextStyle]: + return self.__text_style + + @text_style.setter + def text_style(self, value: Optional[TextStyle]): + self.__text_style = value + # on_click @property def on_click(self):