Skip to content

Commit

Permalink
Fixes for Flet 0.7.1 (#1393)
Browse files Browse the repository at this point in the history
* Fix button styles crashing UI

Fix #1390

* Bump Flet version to 0.7.1
  • Loading branch information
FeodorFitsner authored May 12, 2023
1 parent 46c522c commit 562dde9
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Flet changelog

## 0.7.1

* `ButtonStyle` with `shape` or `side` params failed in flet 0.7.0 ([#1390](https://github.com/flet-dev/flet/issues/1390)).

## 0.7.0

* Programmatically [control scroll position](https://flet.dev/blog/scrolling-controls-and-theming#controlling-scroll-position) and subscribe to [scrolling notifications](https://flet.dev/blog/scrolling-controls-and-theming#receiving-scroll-notifications) in Page, View, Column, Row, ListView and GridView controls.
Expand Down
6 changes: 1 addition & 5 deletions client/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ void main([List<String>? args]) async {
//debugPrint("Uri.base: ${Uri.base}");

if (kDebugMode) {
if (kIsWeb) {
pageUrl = "http://localhost:8550";
} else {
pageUrl = "tcp://localhost:8550";
}
pageUrl = "http://localhost:8550";
}

if (kIsWeb) {
Expand Down
2 changes: 1 addition & 1 deletion client/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ packages:
path: "../package"
relative: true
source: path
version: "0.7.0"
version: "0.7.1"
flutter:
dependency: "direct main"
description: flutter
Expand Down
4 changes: 4 additions & 0 deletions package/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.7.1

* `ButtonStyle` with `shape` or `side` params failed in flet 0.7.0 ([#1390](https://github.com/flet-dev/flet/issues/1390)).

## 0.7.0

* Programmatically [control scroll position](https://flet.dev/blog/scrolling-controls-and-theming#controlling-scroll-position) and subscribe to [scrolling notifications](https://flet.dev/blog/scrolling-controls-and-theming#receiving-scroll-notifications) in Page, View, Column, Row, ListView and GridView controls.
Expand Down
2 changes: 0 additions & 2 deletions package/lib/src/utils/material_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ import 'package:flutter/material.dart';

MaterialStateProperty<T?>? getMaterialStateProperty<T>(dynamic jsonDictValue,
T Function(dynamic) converterFromJson, T defaultValue) {
debugPrint("jsonDictValue: $jsonDictValue");
if (jsonDictValue == null) {
return null;
}
var j = jsonDictValue;
if (j is! Map<String, dynamic>) {
j = {"": j};
debugPrint("jsonDictValue DICT: $j");
}
return MaterialStateFromJSON(j, converterFromJson, defaultValue);
}
Expand Down
2 changes: 1 addition & 1 deletion package/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: flet
description: Write entire Flutter app in Python or add server-driven UI experience into existing Flutter app.
homepage: https://flet.dev
repository: https://github.com/flet-dev/flet
version: 0.7.0
version: 0.7.1

# This package supports all platforms listed below.
platforms:
Expand Down
5 changes: 5 additions & 0 deletions sdk/python/packages/flet-core/src/flet_core/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ def _convert_attr_json(self, value):
else None
)

def _wrap_attr_dict(self, value):
if value is None or isinstance(value, Dict):
return value
return {"": value}

def __str__(self):
attrs = {}
for k, v in self.__attrs.items():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ def _before_build_command(self):
self.__style.bgcolor = self.__bgcolor
if self.__style.elevation != self.__elevation:
self.__style.elevation = self.__elevation
if self.__style is not None:
self.__style.side = self._wrap_attr_dict(self.__style.side)
self.__style.shape = self._wrap_attr_dict(self.__style.shape)
self._set_attr_json("style", self.__style)

def _get_children(self):
Expand Down
3 changes: 3 additions & 0 deletions sdk/python/packages/flet-core/src/flet_core/icon_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ def _get_control_name(self):

def _before_build_command(self):
super()._before_build_command()
if self.__style is not None:
self.__style.side = self._wrap_attr_dict(self.__style.side)
self.__style.shape = self._wrap_attr_dict(self.__style.shape)
self._set_attr_json("style", self.__style)

def _get_children(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ def _get_control_name(self):

def _before_build_command(self):
super()._before_build_command()
if self.__style is not None:
self.__style.side = self._wrap_attr_dict(self.__style.side)
self.__style.shape = self._wrap_attr_dict(self.__style.shape)
self._set_attr_json("style", self.__style)

def _get_children(self):
Expand Down
3 changes: 3 additions & 0 deletions sdk/python/packages/flet-core/src/flet_core/text_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ def _get_control_name(self):

def _before_build_command(self):
super()._before_build_command()
if self.__style is not None:
self.__style.side = self._wrap_attr_dict(self.__style.side)
self.__style.shape = self._wrap_attr_dict(self.__style.shape)
self._set_attr_json("style", self.__style)

def _get_children(self):
Expand Down
2 changes: 1 addition & 1 deletion studio/client/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ packages:
path: "../../package"
relative: true
source: path
version: "0.7.0"
version: "0.7.1"
flutter:
dependency: "direct main"
description: flutter
Expand Down

0 comments on commit 562dde9

Please sign in to comment.