Skip to content

Commit 5257897

Browse files
authored
update style setting (#2435)
1 parent 0c45658 commit 5257897

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

sdk/python/packages/flet-core/src/flet_core/elevated_button.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,21 @@ def _before_build_command(self):
149149
if self.__style is None:
150150
self.__style = ButtonStyle()
151151
if self.__style.color != self.__color or self.disabled:
152-
self.__style.color = self.__color if not self.disabled else None
152+
# if the color is set through the style, use it
153+
if not (
154+
self.__class__.__name__ in ["FilledButton", "FilledTonalButton"]
155+
and self.__style.color
156+
and not self.disabled
157+
):
158+
self.__style.color = self.__color if not self.disabled else None
153159
if self.__style.bgcolor != self.__bgcolor or self.disabled:
154-
self.__style.bgcolor = self.__bgcolor if not self.disabled else None
160+
# if the bgcolor is set through the style, use it
161+
if not (
162+
self.__class__.__name__ in ["FilledButton", "FilledTonalButton"]
163+
and self.__style.bgcolor
164+
and not self.disabled
165+
):
166+
self.__style.bgcolor = self.__bgcolor if not self.disabled else None
155167
if self.__style.elevation != self.__elevation:
156168
self.__style.elevation = self.__elevation
157169
if self.__style is not None:

0 commit comments

Comments
 (0)