Skip to content

Commit 17f4906

Browse files
Flet 0.20.2 fixes (#2668)
* `FletApp` control takes control create factories from a parent app * Buttons turn to CupertinoDialogActionControl inside adaptive dialogs * Page.adaptive should be passed to overlays * Check minimal Flutter SDK version * Flet version bumped to 0.20.2
1 parent 8aa0f1b commit 17f4906

File tree

19 files changed

+218
-98
lines changed

19 files changed

+218
-98
lines changed

CHANGELOG.md

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

3+
# 0.20.2
4+
* Move `system_overlay_style` from `AppBar` to `Theme` ([#2667](https://github.com/flet-dev/flet/issues/2667)).
5+
* `flet build` command checks minimal Flutter SDK version.
6+
* Buttons turn to `CupertinoDialogAction` controls inside adaptive dialogs.
7+
* `FletApp` control takes control create factories from a parent app.
8+
39
# 0.20.1
410

511
* Migrated to Flutter 3.19

client/pubspec.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,35 +223,35 @@ packages:
223223
path: "../packages/flet"
224224
relative: true
225225
source: path
226-
version: "0.20.1"
226+
version: "0.20.2"
227227
flet_audio:
228228
dependency: "direct main"
229229
description:
230230
path: "../packages/flet_audio"
231231
relative: true
232232
source: path
233-
version: "0.20.1"
233+
version: "0.20.2"
234234
flet_audio_recorder:
235235
dependency: "direct main"
236236
description:
237237
path: "../packages/flet_audio_recorder"
238238
relative: true
239239
source: path
240-
version: "0.20.1"
240+
version: "0.20.2"
241241
flet_video:
242242
dependency: "direct main"
243243
description:
244244
path: "../packages/flet_video"
245245
relative: true
246246
source: path
247-
version: "0.20.1"
247+
version: "0.20.2"
248248
flet_webview:
249249
dependency: "direct main"
250250
description:
251251
path: "../packages/flet_webview"
252252
relative: true
253253
source: path
254-
version: "0.20.1"
254+
version: "0.20.2"
255255
flutter:
256256
dependency: "direct main"
257257
description: flutter

packages/flet/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 0.20.2
2+
* Move `system_overlay_style` from `AppBar` to `Theme` ([#2667](https://github.com/flet-dev/flet/issues/2667)).
3+
* `flet build` command checks minimal Flutter SDK version.
4+
* Buttons turn to `CupertinoDialogAction` controls inside adaptive dialogs.
5+
* `FletApp` control takes control create factories from a parent app.
6+
17
# 0.20.1
28

39
* Migrated to Flutter 3.19

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ Widget createWidget(
335335
control: controlView.control,
336336
children: controlView.children,
337337
parentDisabled: parentDisabled,
338+
parentAdaptive: parentAdaptive,
338339
backend: backend);
339340
case "textbutton":
340341
return TextButtonControl(

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import '../utils/icons.dart';
88
import '../utils/launch_url.dart';
99
import 'create_control.dart';
1010
import 'cupertino_button.dart';
11+
import 'cupertino_dialog_action.dart';
1112
import 'error.dart';
1213
import 'flet_store_mixin.dart';
1314

@@ -66,12 +67,21 @@ class _ElevatedButtonControlState extends State<ElevatedButtonControl>
6667
if (adaptive == true &&
6768
(platform == TargetPlatform.iOS ||
6869
platform == TargetPlatform.macOS)) {
69-
return CupertinoButtonControl(
70-
control: widget.control,
71-
parentDisabled: widget.parentDisabled,
72-
parentAdaptive: adaptive,
73-
children: widget.children,
74-
backend: widget.backend);
70+
return widget.control.name == "action" &&
71+
(widget.parent?.type == "alertdialog" ||
72+
widget.parent?.type == "cupertinoalertdialog")
73+
? CupertinoDialogActionControl(
74+
control: widget.control,
75+
parentDisabled: widget.parentDisabled,
76+
parentAdaptive: adaptive,
77+
children: widget.children,
78+
backend: widget.backend)
79+
: CupertinoButtonControl(
80+
control: widget.control,
81+
parentDisabled: widget.parentDisabled,
82+
parentAdaptive: adaptive,
83+
children: widget.children,
84+
backend: widget.backend);
7585
}
7686

7787
String text = widget.control.attrString("text", "")!;

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

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

33
import '../flet_app.dart';
44
import '../flet_app_errors_handler.dart';
5+
import '../flet_app_services.dart';
56
import '../models/control.dart';
67
import 'create_control.dart';
78

@@ -36,6 +37,8 @@ class _FletAppControlState extends State<FletAppControl> {
3637
pageUrl: url,
3738
assetsDir: "",
3839
errorsHandler: _errorsHandler,
40+
createControlFactories:
41+
FletAppServices.of(context).createControlFactories,
3942
),
4043
widget.parent,
4144
widget.control);

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

Lines changed: 88 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@ import '../utils/colors.dart';
77
import '../utils/icons.dart';
88
import '../utils/launch_url.dart';
99
import 'create_control.dart';
10+
import 'cupertino_button.dart';
11+
import 'cupertino_dialog_action.dart';
12+
import 'flet_store_mixin.dart';
1013

1114
class OutlinedButtonControl extends StatefulWidget {
1215
final Control? parent;
1316
final Control control;
1417
final List<Control> children;
1518
final bool parentDisabled;
19+
final bool? parentAdaptive;
1620
final FletControlBackend backend;
1721

1822
const OutlinedButtonControl(
@@ -21,13 +25,15 @@ class OutlinedButtonControl extends StatefulWidget {
2125
required this.control,
2226
required this.children,
2327
required this.parentDisabled,
28+
required this.parentAdaptive,
2429
required this.backend});
2530

2631
@override
2732
State<OutlinedButtonControl> createState() => _OutlinedButtonControlState();
2833
}
2934

30-
class _OutlinedButtonControlState extends State<OutlinedButtonControl> {
35+
class _OutlinedButtonControlState extends State<OutlinedButtonControl>
36+
with FletStoreMixin {
3137
late final FocusNode _focusNode;
3238
String? _lastFocusValue;
3339

@@ -92,62 +98,86 @@ class _OutlinedButtonControlState extends State<OutlinedButtonControl> {
9298
}
9399
: null;
94100

95-
OutlinedButton? button;
96-
97-
var theme = Theme.of(context);
98-
99-
var style = parseButtonStyle(Theme.of(context), widget.control, "style",
100-
defaultForegroundColor: theme.colorScheme.primary,
101-
defaultBackgroundColor: Colors.transparent,
102-
defaultOverlayColor: Colors.transparent,
103-
defaultShadowColor: Colors.transparent,
104-
defaultSurfaceTintColor: Colors.transparent,
105-
defaultElevation: 0,
106-
defaultPadding: const EdgeInsets.all(8),
107-
defaultBorderSide: BorderSide(color: theme.colorScheme.outline),
108-
defaultShape: theme.useMaterial3
109-
? const StadiumBorder()
110-
: RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)));
111-
112-
if (icon != null) {
113-
button = OutlinedButton.icon(
114-
autofocus: autofocus,
115-
focusNode: _focusNode,
116-
onPressed: onPressed,
117-
onLongPress: onLongPressHandler,
118-
style: style,
119-
icon: Icon(
120-
icon,
121-
color: iconColor,
122-
),
123-
label: Text(text));
124-
} else if (contentCtrls.isNotEmpty) {
125-
button = OutlinedButton(
126-
autofocus: autofocus,
127-
focusNode: _focusNode,
128-
onPressed: onPressed,
129-
onLongPress: onLongPressHandler,
130-
onHover: onHoverHandler,
131-
style: style,
132-
child:
133-
createControl(widget.control, contentCtrls.first.id, disabled));
134-
} else {
135-
button = OutlinedButton(
136-
autofocus: autofocus,
137-
focusNode: _focusNode,
138-
style: style,
139-
onPressed: onPressed,
140-
onLongPress: onLongPressHandler,
141-
onHover: onHoverHandler,
142-
child: Text(text));
143-
}
144-
145-
var focusValue = widget.control.attrString("focus");
146-
if (focusValue != null && focusValue != _lastFocusValue) {
147-
_lastFocusValue = focusValue;
148-
_focusNode.requestFocus();
149-
}
150-
151-
return constrainedControl(context, button, widget.parent, widget.control);
101+
return withPagePlatform((context, platform) {
102+
bool? adaptive =
103+
widget.control.attrBool("adaptive") ?? widget.parentAdaptive;
104+
if (adaptive == true &&
105+
(platform == TargetPlatform.iOS ||
106+
platform == TargetPlatform.macOS)) {
107+
return widget.control.name == "action" &&
108+
(widget.parent?.type == "alertdialog" ||
109+
widget.parent?.type == "cupertinoalertdialog")
110+
? CupertinoDialogActionControl(
111+
control: widget.control,
112+
parentDisabled: widget.parentDisabled,
113+
parentAdaptive: adaptive,
114+
children: widget.children,
115+
backend: widget.backend)
116+
: CupertinoButtonControl(
117+
control: widget.control,
118+
parentDisabled: widget.parentDisabled,
119+
parentAdaptive: adaptive,
120+
children: widget.children,
121+
backend: widget.backend);
122+
}
123+
124+
OutlinedButton? button;
125+
126+
var theme = Theme.of(context);
127+
128+
var style = parseButtonStyle(Theme.of(context), widget.control, "style",
129+
defaultForegroundColor: theme.colorScheme.primary,
130+
defaultBackgroundColor: Colors.transparent,
131+
defaultOverlayColor: Colors.transparent,
132+
defaultShadowColor: Colors.transparent,
133+
defaultSurfaceTintColor: Colors.transparent,
134+
defaultElevation: 0,
135+
defaultPadding: const EdgeInsets.all(8),
136+
defaultBorderSide: BorderSide(color: theme.colorScheme.outline),
137+
defaultShape: theme.useMaterial3
138+
? const StadiumBorder()
139+
: RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)));
140+
141+
if (icon != null) {
142+
button = OutlinedButton.icon(
143+
autofocus: autofocus,
144+
focusNode: _focusNode,
145+
onPressed: onPressed,
146+
onLongPress: onLongPressHandler,
147+
style: style,
148+
icon: Icon(
149+
icon,
150+
color: iconColor,
151+
),
152+
label: Text(text));
153+
} else if (contentCtrls.isNotEmpty) {
154+
button = OutlinedButton(
155+
autofocus: autofocus,
156+
focusNode: _focusNode,
157+
onPressed: onPressed,
158+
onLongPress: onLongPressHandler,
159+
onHover: onHoverHandler,
160+
style: style,
161+
child:
162+
createControl(widget.control, contentCtrls.first.id, disabled));
163+
} else {
164+
button = OutlinedButton(
165+
autofocus: autofocus,
166+
focusNode: _focusNode,
167+
style: style,
168+
onPressed: onPressed,
169+
onLongPress: onLongPressHandler,
170+
onHover: onHoverHandler,
171+
child: Text(text));
172+
}
173+
174+
var focusValue = widget.control.attrString("focus");
175+
if (focusValue != null && focusValue != _lastFocusValue) {
176+
_lastFocusValue = focusValue;
177+
_focusNode.requestFocus();
178+
}
179+
180+
return constrainedControl(context, button, widget.parent, widget.control);
181+
});
152182
}
153183
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,9 @@ class _PageControlState extends State<PageControl> with FletStoreMixin {
548548
"darkTheme", Brightness.dark)
549549
: parseCupertinoTheme(
550550
widget.control, "theme", Brightness.dark),
551+
localizationsDelegates: const [
552+
DefaultMaterialLocalizations.delegate
553+
],
551554
)
552555
: MaterialApp.router(
553556
debugShowCheckedModeBanner: false,
@@ -612,7 +615,8 @@ class _PageControlState extends State<PageControl> with FletStoreMixin {
612615
overlayWidgets.addAll(routesView.offstageControls
613616
.where((c) => !c.isNonVisual)
614617
.map((c) => createControl(
615-
routesView.page, c.id, routesView.page.isDisabled)));
618+
routesView.page, c.id, routesView.page.isDisabled,
619+
parentAdaptive: _adaptive)));
616620
overlayWidgets.add(const PageMedia());
617621
}
618622

@@ -682,7 +686,7 @@ class _PageControlState extends State<PageControl> with FletStoreMixin {
682686
in routesView.offstageControls.where((c) => c.isNonVisual)) {
683687
nextChild = createControl(
684688
routesView.page, c.id, routesView.page.isDisabled,
685-
nextChild: nextChild);
689+
parentAdaptive: _adaptive, nextChild: nextChild);
686690
}
687691

688692
return nextChild;

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import '../utils/icons.dart';
88
import '../utils/launch_url.dart';
99
import 'create_control.dart';
1010
import 'cupertino_button.dart';
11+
import 'cupertino_dialog_action.dart';
1112
import 'flet_store_mixin.dart';
1213

1314
class TextButtonControl extends StatefulWidget {
@@ -65,12 +66,21 @@ class _TextButtonControlState extends State<TextButtonControl>
6566
if (adaptive == true &&
6667
(platform == TargetPlatform.iOS ||
6768
platform == TargetPlatform.macOS)) {
68-
return CupertinoButtonControl(
69-
control: widget.control,
70-
parentDisabled: widget.parentDisabled,
71-
parentAdaptive: adaptive,
72-
children: widget.children,
73-
backend: widget.backend);
69+
return widget.control.name == "action" &&
70+
(widget.parent?.type == "alertdialog" ||
71+
widget.parent?.type == "cupertinoalertdialog")
72+
? CupertinoDialogActionControl(
73+
control: widget.control,
74+
parentDisabled: widget.parentDisabled,
75+
parentAdaptive: adaptive,
76+
children: widget.children,
77+
backend: widget.backend)
78+
: CupertinoButtonControl(
79+
control: widget.control,
80+
parentDisabled: widget.parentDisabled,
81+
parentAdaptive: adaptive,
82+
children: widget.children,
83+
backend: widget.backend);
7484
}
7585

7686
String text = widget.control.attrString("text", "")!;

packages/flet/pubspec.yaml

Lines changed: 1 addition & 1 deletion
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.20.1
5+
version: 0.20.2
66

77
# This package supports all platforms listed below.
88
platforms:

0 commit comments

Comments
 (0)