Skip to content

Commit 1c040ef

Browse files
Preparing Flet v0.28.3 release (#5306)
* Fix images displaying in web mode with non-empty page name Fix #5198 * Fix page.on_view_pop event handling Fix #5302 * Fix FilePicker.save_file() for Android and iOS Fix #5301 * PubSub: allow multiple subscribers per session, per topic Close #5303 * Bump version to 0.28.3, updated changelog
1 parent 69e4e10 commit 1c040ef

File tree

9 files changed

+63
-37
lines changed

9 files changed

+63
-37
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Flet changelog
22

3+
## 0.28.3
4+
5+
* New: Multiple subscribers can subscribe to a published topic by `send_all_on_topic` ([#5303](https://github.com/flet-dev/flet/issues/5303))
6+
* Fixed: Local Images Not Rendering in Android App using Flet 0.27.6 ([#5198](https://github.com/flet-dev/flet/issues/5198))
7+
* Fixed: FilePicker.save_file() opens blank gray screen in APK build (works fine in VS) ([#5301](https://github.com/flet-dev/flet/issues/5301))
8+
* Fixed: Routing / Navigation broken since flet 0.28.2 ([#5302](https://github.com/flet-dev/flet/issues/5302))
9+
310
## 0.28.2
411

512
* Fixed missing imports in `__init__.py` ([#5292](https://github.com/flet-dev/flet/pull/5292)).

ci/whats-new.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$milestone = 15
1+
$milestone = 17
22

33
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
44

packages/flet/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 0.28.3
2+
3+
* Fixed: Local Images Not Rendering in Android App using Flet 0.27.6 ([#5198](https://github.com/flet-dev/flet/issues/5198))
4+
* Fixed: FilePicker.save_file() opens blank gray screen in APK build (works fine in VS) ([#5301](https://github.com/flet-dev/flet/issues/5301))
5+
16
# 0.28.2
27

38
* Fixed missing imports in `__init__.py` ([#5292](https://github.com/flet-dev/flet/pull/5292)).

packages/flet/lib/src/controls/file_picker.dart

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,17 @@ class _FilePickerControlState extends State<FilePickerControl>
180180
else if (state?.toLowerCase() == "savefile" && !kIsWeb) {
181181
FilePicker.platform
182182
.saveFile(
183-
dialogTitle: dialogTitle,
184-
fileName: fileName,
185-
initialDirectory: initialDirectory,
186-
lockParentWindow: true,
187-
type: fileType,
188-
allowedExtensions: allowedExtensions,
189-
)
183+
dialogTitle: dialogTitle,
184+
fileName: fileName != null || !isiOSPlatform()
185+
? fileName
186+
: "new-file",
187+
initialDirectory: initialDirectory,
188+
lockParentWindow: true,
189+
type: fileType,
190+
allowedExtensions: allowedExtensions,
191+
bytes: isAndroidPlatform() || isiOSPlatform()
192+
? Uint8List(0)
193+
: null)
190194
.then((result) {
191195
debugPrint("saveFile() completed");
192196
_path = result;

packages/flet/lib/src/utils/uri.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ Uri getAssetUri(Uri pageUri, String assetPath) {
1616
scheme: pageUri.scheme,
1717
host: pageUri.host,
1818
port: pageUri.port,
19-
path: pageUri.path +
20-
(assetPath.startsWith("/") ? assetPath.substring(1) : assetPath));
19+
pathSegments: [...pageUri.pathSegments, ...assetPath.split("/")]);
2120
}
2221

2322
Uri getBaseUri(Uri pageUri) {

packages/flet/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: flet
22
description: Write entire Flutter app in Python or add server-driven UI experience into existing Flutter app.
33
homepage: https://flet.dev
44
repository: https://github.com/flet-dev/flet/packages/flet
5-
version: 0.28.2
5+
version: 0.28.3
66

77
# This package supports all platforms listed below.
88
platforms:
@@ -34,7 +34,7 @@ dependencies:
3434
flutter_highlight: ^0.7.0
3535
highlight: ^0.7.0
3636
markdown: ^7.2.2
37-
file_picker: ^8.1.3
37+
file_picker: ^10.1.9
3838
shared_preferences: ^2.3.2
3939
flutter_svg: ^2.0.13
4040
window_to_front: ^0.0.3

sdk/python/packages/flet/src/flet/core/file_picker.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
from flet.core.ref import Ref
1010
from flet.core.types import OptionalEventCallable
1111

12-
try:
13-
from typing import Literal
14-
except ImportError:
15-
from typing_extensions import Literal
16-
1712

1813
class FilePickerState(Enum):
1914
PICK_FILES = "pickFiles"

sdk/python/packages/flet/src/flet/core/page.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,9 @@ def page(cls) -> "Page":
107107
try:
108108
from flet.auth.authorization import Authorization
109109
from flet.auth.oauth_provider import OAuthProvider
110-
except ImportError as e:
110+
except ImportError:
111111

112-
class OAuthProvider:
113-
...
112+
class OAuthProvider: ...
114113

115114
class Authorization:
116115
def __init__(
@@ -119,8 +118,7 @@ def __init__(
119118
fetch_user: bool,
120119
fetch_groups: bool,
121120
scope: Optional[List[str]] = None,
122-
):
123-
...
121+
): ...
124122

125123

126124
AT = TypeVar("AT", bound=Authorization)
@@ -624,7 +622,9 @@ def convert_route_change_event(e):
624622
self._add_event_handler("route_change", self.__on_route_change.get_handler())
625623

626624
def convert_view_pop_event(e):
627-
return ViewPopEvent(view=cast(View, self.get_control(e.data)))
625+
# e.data contains route name
626+
view = next((v for v in self.views if v.route == e.data), None)
627+
return ViewPopEvent(view=view) if view in self.views else None
628628

629629
self.__on_view_pop = EventHandler(convert_view_pop_event)
630630
self._add_event_handler("view_pop", self.__on_view_pop.get_handler())

sdk/python/packages/flet/src/flet/core/pubsub/pubsub_hub.py

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,49 +22,57 @@ def __init__(
2222
self.__executor = executor
2323
self.__lock = threading.Lock() if not is_pyodide() else NopeLock()
2424
self.__subscribers: Dict[
25-
str, Union[Callable, Callable[..., Awaitable[Any]]]
25+
str, set[Union[Callable, Callable[..., Awaitable[Any]]]]
2626
] = {} # key: session_id, value: handler
2727
self.__topic_subscribers: Dict[
28-
str, Dict[str, Union[Callable, Callable[..., Awaitable[Any]]]]
28+
str, Dict[str, set[Union[Callable, Callable[..., Awaitable[Any]]]]]
2929
] = {} # key: topic, value: dict[session_id, handler]
3030
self.__subscriber_topics: Dict[
31-
str, Dict[str, Union[Callable, Callable[..., Awaitable[Any]]]]
31+
str, Dict[str, set[Union[Callable, Callable[..., Awaitable[Any]]]]]
3232
] = {} # key: session_id, value: dict[topic, handler]
3333

3434
def send_all(self, message: Any):
3535
logger.debug(f"pubsub.send_all({message})")
3636
with self.__lock:
37-
for handler in self.__subscribers.values():
38-
self.__send(handler, [message])
37+
for handlers in self.__subscribers.values():
38+
for handler in handlers:
39+
self.__send(handler, [message])
3940

4041
def send_all_on_topic(self, topic: str, message: Any):
4142
logger.debug(f"pubsub.send_all_on_topic({topic}, {message})")
4243
with self.__lock:
4344
if topic in self.__topic_subscribers:
44-
for handler in self.__topic_subscribers[topic].values():
45-
self.__send(handler, [topic, message])
45+
for handlers in self.__topic_subscribers[topic].values():
46+
for handler in handlers:
47+
self.__send(handler, [topic, message])
4648

4749
def send_others(self, except_session_id: str, message: Any):
4850
logger.debug(f"pubsub.send_others({except_session_id}, {message})")
4951
with self.__lock:
50-
for session_id, handler in self.__subscribers.items():
52+
for session_id, handlers in self.__subscribers.items():
5153
if except_session_id != session_id:
52-
self.__send(handler, [message])
54+
for handler in handlers:
55+
self.__send(handler, [message])
5356

5457
def send_others_on_topic(self, except_session_id: str, topic: str, message: Any):
5558
logger.debug(
5659
f"pubsub.send_others_on_topic({except_session_id}, {topic}, {message})"
5760
)
5861
with self.__lock:
5962
if topic in self.__topic_subscribers:
60-
for session_id, handler in self.__topic_subscribers[topic].items():
63+
for session_id, handlers in self.__topic_subscribers[topic].items():
6164
if except_session_id != session_id:
62-
self.__send(handler, [topic, message])
65+
for handler in handlers:
66+
self.__send(handler, [topic, message])
6367

6468
def subscribe(self, session_id: str, handler: Callable):
6569
logger.debug(f"pubsub.subscribe({session_id})")
6670
with self.__lock:
67-
self.__subscribers[session_id] = handler
71+
handlers = self.__subscribers.get(session_id)
72+
if handlers is None:
73+
handlers = set()
74+
self.__subscribers[session_id] = handlers
75+
handlers.add(handler)
6876

6977
def subscribe_topic(
7078
self,
@@ -86,12 +94,20 @@ def __subscribe_topic(
8694
if topic_subscribers is None:
8795
topic_subscribers = {}
8896
self.__topic_subscribers[topic] = topic_subscribers
89-
topic_subscribers[session_id] = handler
97+
handlers = topic_subscribers.get(session_id)
98+
if handlers is None:
99+
handlers = set()
100+
topic_subscribers[session_id] = handlers
101+
handlers.add(handler)
90102
subscriber_topics = self.__subscriber_topics.get(session_id)
91103
if subscriber_topics is None:
92104
subscriber_topics = {}
93105
self.__subscriber_topics[session_id] = subscriber_topics
94-
subscriber_topics[topic] = handler
106+
handlers = subscriber_topics.get(topic)
107+
if handlers is None:
108+
handlers = set()
109+
subscriber_topics[topic] = handlers
110+
handlers.add(handler)
95111

96112
def unsubscribe(self, session_id: str):
97113
logger.debug(f"pubsub.unsubscribe({session_id})")

0 commit comments

Comments
 (0)