Skip to content

Commit 4230cbc

Browse files
committed
Fix button styles crashing UI
Fix #1390
1 parent 46c522c commit 4230cbc

File tree

7 files changed

+18
-7
lines changed

7 files changed

+18
-7
lines changed

client/lib/main.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ void main([List<String>? args]) async {
2020
//debugPrint("Uri.base: ${Uri.base}");
2121

2222
if (kDebugMode) {
23-
if (kIsWeb) {
24-
pageUrl = "http://localhost:8550";
25-
} else {
26-
pageUrl = "tcp://localhost:8550";
27-
}
23+
pageUrl = "http://localhost:8550";
2824
}
2925

3026
if (kIsWeb) {

package/lib/src/utils/material_state.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ import 'package:flutter/material.dart';
22

33
MaterialStateProperty<T?>? getMaterialStateProperty<T>(dynamic jsonDictValue,
44
T Function(dynamic) converterFromJson, T defaultValue) {
5-
debugPrint("jsonDictValue: $jsonDictValue");
65
if (jsonDictValue == null) {
76
return null;
87
}
98
var j = jsonDictValue;
109
if (j is! Map<String, dynamic>) {
1110
j = {"": j};
12-
debugPrint("jsonDictValue DICT: $j");
1311
}
1412
return MaterialStateFromJSON(j, converterFromJson, defaultValue);
1513
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ def _convert_attr_json(self, value):
145145
else None
146146
)
147147

148+
def _wrap_attr_dict(self, value):
149+
if value is None or isinstance(value, Dict):
150+
return value
151+
return {"": value}
152+
148153
def __str__(self):
149154
attrs = {}
150155
for k, v in self.__attrs.items():

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ def _before_build_command(self):
154154
self.__style.bgcolor = self.__bgcolor
155155
if self.__style.elevation != self.__elevation:
156156
self.__style.elevation = self.__elevation
157+
if self.__style is not None:
158+
self.__style.side = self._wrap_attr_dict(self.__style.side)
159+
self.__style.shape = self._wrap_attr_dict(self.__style.shape)
157160
self._set_attr_json("style", self.__style)
158161

159162
def _get_children(self):

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ def _get_control_name(self):
151151

152152
def _before_build_command(self):
153153
super()._before_build_command()
154+
if self.__style is not None:
155+
self.__style.side = self._wrap_attr_dict(self.__style.side)
156+
self.__style.shape = self._wrap_attr_dict(self.__style.shape)
154157
self._set_attr_json("style", self.__style)
155158

156159
def _get_children(self):

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ def _get_control_name(self):
131131

132132
def _before_build_command(self):
133133
super()._before_build_command()
134+
if self.__style is not None:
135+
self.__style.side = self._wrap_attr_dict(self.__style.side)
136+
self.__style.shape = self._wrap_attr_dict(self.__style.shape)
134137
self._set_attr_json("style", self.__style)
135138

136139
def _get_children(self):

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ def _get_control_name(self):
131131

132132
def _before_build_command(self):
133133
super()._before_build_command()
134+
if self.__style is not None:
135+
self.__style.side = self._wrap_attr_dict(self.__style.side)
136+
self.__style.shape = self._wrap_attr_dict(self.__style.shape)
134137
self._set_attr_json("style", self.__style)
135138

136139
def _get_children(self):

0 commit comments

Comments
 (0)