Skip to content

Commit 2b67aec

Browse files
authored
feat: New features (flet-dev#4703)
* Image`: cache_width, cache_height, anti_alias * `InteractiveViewer`: add assertion checks * reformat code * deprecate `animation.implicit` function * Banner: min_action_bar_height * TextButton: clip_behavior * parseWidgetStateMouseCursor * RangeSlider: mouse_cursor * fix dates in DatePicker * CupertinoRadio: mouse_cursor * ResponsiveRow: using built-in spacing property * SegmentedButton: padding, direction * CupertinoPicker: default_selection_overlay_bgcolor, selection_overlay * Switch: track_outline_width * Row: run_alignment * SearchBar: bar_scroll_padding * CupertinoButton, CupertinoFilledButton: on_long_press, on_focus, on_blur * CupertinoAppBar: brightness, automatic_background_visibility, enable_background_filter_blur * CupertinoAlertDialog: inset_animation * CupertinoCheckbox: shape, mouse_cursor, semantics_label, border_side, fill_color * BottomSheet: animation_style, size_constraints, clip_behavior, shape * Chip: avatar_size_constraints, delete_icon_size_constraints, enable_animation_style, select_animation_style, avatar_drawer_animation_style, delete_drawer_animation_style * Column: run_alignment * Semantics: current_value_length, heading_level, exclude_semantics, mixed, on_set_text * fix typo in parseWidgetStateMouseCursor * deprecated_property util * CupertinoSwitch: active_thumb_image, active_track_color, inactive_thumb_color, inactive_track_color, track_outline_color, track_outline_width, thumb_icon, inactive_thumb_image, on_image_error
1 parent 9cda49c commit 2b67aec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1304
-561
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class _BannerControlState extends State<BannerControl> {
7070
shadowColor: widget.control.attrColor("shadowColor", context),
7171
dividerColor: widget.control.attrColor("dividerColor", context),
7272
elevation: widget.control.attrDouble("elevation"),
73+
minActionBarHeight:
74+
widget.control.attrDouble("minActionBarHeight", 52.0)!,
7375
margin: parseEdgeInsets(widget.control, "margin"),
7476
onVisible: () {
7577
widget.backend.triggerControlEvent(widget.control.id, "visible");
@@ -85,9 +87,6 @@ class _BannerControlState extends State<BannerControl> {
8587

8688
var open = widget.control.attrBool("open", false)!;
8789

88-
debugPrint("Current open state: $_open");
89-
debugPrint("New open state: $open");
90-
9190
if (open && (open != _open)) {
9291
var banner = _createBanner();
9392
if (banner is ErrorControl) {

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

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

33
import '../flet_control_backend.dart';
44
import '../models/control.dart';
5+
import '../utils/animations.dart';
6+
import '../utils/borders.dart';
7+
import '../utils/box.dart';
8+
import '../utils/others.dart';
59
import 'create_control.dart';
610
import 'error.dart';
711

@@ -92,7 +96,15 @@ class _BottomSheetControlState extends State<BottomSheetControl> {
9296
elevation: widget.control.attrDouble("elevation"),
9397
isScrollControlled: isScrollControlled,
9498
enableDrag: enableDrag,
99+
barrierColor: widget.control.attrColor("barrierColor", context),
100+
sheetAnimationStyle:
101+
parseAnimationStyle(widget.control, "animationStyle"),
102+
constraints:
103+
parseBoxConstraints(widget.control, "sizeConstraints"),
95104
showDragHandle: showDragHandle,
105+
clipBehavior:
106+
parseClip(widget.control.attrString("clipBehavior")),
107+
shape: parseOutlinedBorder(widget.control, "shape"),
96108
useSafeArea: useSafeArea)
97109
.then((value) {
98110
lastOpen = widget.control.state["open"] ?? false;

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

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,20 @@ class CardControl extends StatelessWidget {
2929

3030
var contentCtrls =
3131
children.where((c) => c.name == "content" && c.isVisible);
32+
var content = contentCtrls.isNotEmpty
33+
? createControl(control, contentCtrls.first.id, disabled,
34+
parentAdaptive: adaptive)
35+
: null;
3236
var clipBehavior = parseClip(control.attrString("clipBehavior"));
37+
var elevation = control.attrDouble("elevation");
38+
var shape = parseOutlinedBorder(control, "shape");
39+
var margin = parseEdgeInsets(control, "margin");
40+
var isSemanticContainer = control.attrBool("isSemanticContainer", true)!;
41+
var showBorderOnForeground =
42+
control.attrBool("showBorderOnForeground", true)!;
43+
var color = control.attrColor("color", context);
44+
var shadowColor = control.attrColor("shadowColor", context);
45+
var surfaceTintColor = control.attrColor("surfaceTintColor", context);
3346

3447
Widget? card;
3548

@@ -38,49 +51,40 @@ class CardControl extends StatelessWidget {
3851

3952
if (variant == CardVariant.outlined) {
4053
card = Card.outlined(
41-
elevation: control.attrDouble("elevation"),
42-
shape: parseOutlinedBorder(control, "shape"),
43-
margin: parseEdgeInsets(control, "margin"),
44-
semanticContainer: control.attrBool("isSemanticContainer", true)!,
45-
borderOnForeground: control.attrBool("showBorderOnForeground", true)!,
54+
elevation: elevation,
55+
shape: shape,
56+
margin: margin,
57+
semanticContainer: isSemanticContainer,
58+
borderOnForeground: showBorderOnForeground,
4659
clipBehavior: clipBehavior,
47-
color: control.attrColor("color", context),
48-
shadowColor: control.attrColor("shadowColor", context),
49-
surfaceTintColor: control.attrColor("surfaceTintColor", context),
50-
child: contentCtrls.isNotEmpty
51-
? createControl(control, contentCtrls.first.id, disabled,
52-
parentAdaptive: adaptive)
53-
: null);
60+
color: color,
61+
shadowColor: shadowColor,
62+
surfaceTintColor: surfaceTintColor,
63+
child: content);
5464
} else if (variant == CardVariant.filled) {
5565
card = Card.filled(
56-
elevation: control.attrDouble("elevation"),
57-
shape: parseOutlinedBorder(control, "shape"),
58-
margin: parseEdgeInsets(control, "margin"),
59-
semanticContainer: control.attrBool("isSemanticContainer", true)!,
60-
borderOnForeground: control.attrBool("showBorderOnForeground", true)!,
66+
elevation: elevation,
67+
shape: shape,
68+
margin: margin,
69+
semanticContainer: isSemanticContainer,
70+
borderOnForeground: showBorderOnForeground,
6171
clipBehavior: clipBehavior,
62-
color: control.attrColor("color", context),
63-
shadowColor: control.attrColor("shadowColor", context),
64-
surfaceTintColor: control.attrColor("surfaceTintColor", context),
65-
child: contentCtrls.isNotEmpty
66-
? createControl(control, contentCtrls.first.id, disabled,
67-
parentAdaptive: adaptive)
68-
: null);
72+
color: color,
73+
shadowColor: shadowColor,
74+
surfaceTintColor: surfaceTintColor,
75+
child: content);
6976
} else {
7077
card = Card(
71-
elevation: control.attrDouble("elevation"),
72-
shape: parseOutlinedBorder(control, "shape"),
73-
margin: parseEdgeInsets(control, "margin"),
74-
semanticContainer: control.attrBool("isSemanticContainer", true)!,
75-
borderOnForeground: control.attrBool("showBorderOnForeground", true)!,
78+
elevation: elevation,
79+
shape: shape,
80+
margin: margin,
81+
semanticContainer: isSemanticContainer,
82+
borderOnForeground: showBorderOnForeground,
7683
clipBehavior: clipBehavior,
77-
color: control.attrColor("color", context),
78-
shadowColor: control.attrColor("shadowColor", context),
79-
surfaceTintColor: control.attrColor("surfaceTintColor", context),
80-
child: contentCtrls.isNotEmpty
81-
? createControl(control, contentCtrls.first.id, disabled,
82-
parentAdaptive: adaptive)
83-
: null);
84+
color: color,
85+
shadowColor: shadowColor,
86+
surfaceTintColor: surfaceTintColor,
87+
child: content);
8488
}
8589

8690
return constrainedControl(context, card, parent, control);

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import 'cupertino_checkbox.dart';
1313
import 'flet_store_mixin.dart';
1414
import 'list_tile.dart';
1515

16-
1716
class CheckboxControl extends StatefulWidget {
1817
final Control? parent;
1918
final Control control;
@@ -114,17 +113,15 @@ class _CheckboxControlState extends State<CheckboxControl> with FletStoreMixin {
114113
labelStyle = labelStyle.apply(color: Theme.of(context).disabledColor);
115114
}
116115

117-
WidgetStateBorderSide? side = parseWidgetStateBorderSide(
118-
Theme.of(context), widget.control, "borderSide");
119-
120116
var checkbox = Checkbox(
121117
autofocus: autofocus,
122118
focusNode: _focusNode,
123119
value: _value,
124120
isError: widget.control.attrBool("isError", false)!,
125121
semanticLabel: widget.control.attrString("semanticsLabel"),
126122
shape: parseOutlinedBorder(widget.control, "shape"),
127-
side: side,
123+
side: parseWidgetStateBorderSide(
124+
Theme.of(context), widget.control, "borderSide"),
128125
splashRadius: widget.control.attrDouble("splashRadius"),
129126
activeColor: widget.control.attrColor("activeColor", context),
130127
focusColor: widget.control.attrColor("focusColor", context),

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

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

33
import '../flet_control_backend.dart';
44
import '../models/control.dart';
5+
import '../utils/animations.dart';
56
import '../utils/borders.dart';
7+
import '../utils/box.dart';
68
import '../utils/colors.dart';
79
import '../utils/edge_insets.dart';
810
import '../utils/others.dart';
@@ -73,115 +75,105 @@ class _ChipControlState extends State<ChipControl> {
7375

7476
var labelCtrls =
7577
widget.children.where((c) => c.name == "label" && c.isVisible);
78+
if (labelCtrls.isEmpty) {
79+
return const ErrorControl("Chip.label must be provided and visible");
80+
}
7681
var leadingCtrls =
7782
widget.children.where((c) => c.name == "leading" && c.isVisible);
7883
var deleteIconCtrls =
7984
widget.children.where((c) => c.name == "deleteIcon" && c.isVisible);
8085

81-
if (labelCtrls.isEmpty) {
82-
return const ErrorControl("Chip.label must be provided and visible");
83-
}
84-
85-
double? clickElevation = widget.control.attrDouble("clickElevation");
86-
Color? bgcolor = widget.control.attrColor("bgcolor", context);
87-
Color? deleteIconColor =
88-
widget.control.attrColor("deleteIconColor", context);
89-
Color? disabledColor = widget.control.attrColor("disabledColor", context);
90-
Color? surfaceTintColor =
91-
widget.control.attrColor("surfaceTintColor", context);
92-
Color? selectedShadowColor =
93-
widget.control.attrColor("selectedShadowColor", context);
94-
Color? shadowColor = widget.control.attrColor("shadowColor", context);
95-
var color =
96-
parseWidgetStateColor(Theme.of(context), widget.control, "color");
97-
98-
BorderSide? borderSide =
99-
parseBorderSide(Theme.of(context), widget.control, "borderSide");
100-
VisualDensity? visualDensity =
101-
parseVisualDensity(widget.control.attrString("visualDensity"));
102-
Clip clipBehavior =
103-
parseClip(widget.control.attrString("clipBehavior"), Clip.none)!;
104-
105-
bool onClick = widget.control.attrBool("onclick", false)!;
106-
bool onDelete = widget.control.attrBool("onDelete", false)!;
107-
bool onSelect = widget.control.attrBool("onSelect", false)!;
86+
var onClick = widget.control.attrBool("onclick", false)!;
87+
var onDelete = widget.control.attrBool("onDelete", false)!;
88+
var onSelect = widget.control.attrBool("onSelect", false)!;
10889

10990
if (onSelect && onClick) {
11091
return const ErrorControl(
11192
"Chip cannot have both on_select and on_click events specified");
11293
}
11394

114-
bool autofocus = widget.control.attrBool("autofocus", false)!;
11595
bool selected = widget.control.attrBool("selected", false)!;
11696
if (_selected != selected) {
11797
_selected = selected;
11898
}
119-
bool showCheckmark = widget.control.attrBool("showCheckmark", true)!;
120-
String? deleteButtonTooltip =
121-
widget.control.attrString("deleteButtonTooltip");
122-
123-
var elevation = widget.control.attrDouble("elevation");
124-
125-
Function()? onClickHandler = onClick && !disabled
126-
? () {
127-
debugPrint("Chip ${widget.control.id} clicked!");
128-
widget.backend.triggerControlEvent(widget.control.id, "click");
129-
}
130-
: null;
131-
132-
Function()? onDeleteHandler = onDelete && !disabled
133-
? () {
134-
debugPrint("Chip ${widget.control.id} deleted!");
135-
widget.backend.triggerControlEvent(widget.control.id, "delete");
136-
}
137-
: null;
13899

139100
return constrainedControl(
140101
context,
141102
InputChip(
142-
autofocus: autofocus,
103+
autofocus: widget.control.attrBool("autofocus", false)!,
143104
focusNode: _focusNode,
144105
label: createControl(widget.control, labelCtrls.first.id, disabled,
145106
parentAdaptive: widget.parentAdaptive),
146107
avatar: leadingCtrls.isNotEmpty
147108
? createControl(widget.control, leadingCtrls.first.id, disabled,
148109
parentAdaptive: widget.parentAdaptive)
149110
: null,
150-
backgroundColor: bgcolor,
111+
backgroundColor: widget.control.attrColor("bgcolor", context),
151112
checkmarkColor: widget.control.attrColor("checkColor", context),
152113
selected: _selected,
153-
showCheckmark: showCheckmark,
154-
deleteButtonTooltipMessage: deleteButtonTooltip,
155-
onPressed: onClickHandler,
156-
onDeleted: onDeleteHandler,
157-
onSelected: onSelect && !disabled
158-
? (bool selected) {
159-
_onSelect(selected);
160-
}
161-
: null,
114+
showCheckmark: widget.control.attrBool("showCheckmark", true)!,
115+
deleteButtonTooltipMessage:
116+
widget.control.attrString("deleteButtonTooltip"),
162117
deleteIcon: deleteIconCtrls.isNotEmpty
163118
? createControl(
164119
widget.control, deleteIconCtrls.first.id, disabled,
165120
parentAdaptive: widget.parentAdaptive)
166121
: null,
167-
deleteIconColor: deleteIconColor,
168-
disabledColor: disabledColor,
169-
elevation: elevation,
122+
deleteIconColor: widget.control.attrColor("deleteIconColor", context),
123+
disabledColor: widget.control.attrColor("disabledColor", context),
124+
elevation: widget.control.attrDouble("elevation"),
170125
isEnabled: !disabled,
171126
padding: parseEdgeInsets(widget.control, "padding"),
172127
labelPadding: parseEdgeInsets(widget.control, "labelPadding"),
173128
labelStyle:
174129
parseTextStyle(Theme.of(context), widget.control, "labelStyle"),
175130
selectedColor: widget.control.attrColor("selectedColor", context),
176-
selectedShadowColor: selectedShadowColor,
177-
shadowColor: shadowColor,
131+
selectedShadowColor:
132+
widget.control.attrColor("selectedShadowColor", context),
133+
shadowColor: widget.control.attrColor("shadowColor", context),
178134
shape: parseOutlinedBorder(widget.control, "shape"),
179-
color: color,
180-
surfaceTintColor: surfaceTintColor,
181-
pressElevation: clickElevation,
182-
side: borderSide,
183-
clipBehavior: clipBehavior,
184-
visualDensity: visualDensity,
135+
color:
136+
parseWidgetStateColor(Theme.of(context), widget.control, "color"),
137+
surfaceTintColor:
138+
widget.control.attrColor("surfaceTintColor", context),
139+
pressElevation: widget.control.attrDouble("clickElevation"),
140+
side:
141+
parseBorderSide(Theme.of(context), widget.control, "borderSide"),
142+
clipBehavior:
143+
parseClip(widget.control.attrString("clipBehavior"), Clip.none)!,
144+
visualDensity:
145+
parseVisualDensity(widget.control.attrString("visualDensity")),
146+
avatarBoxConstraints:
147+
parseBoxConstraints(widget.control, "avatarSizeConstraints"),
148+
deleteIconBoxConstraints:
149+
parseBoxConstraints(widget.control, "deleteIconSizeConstraints"),
150+
chipAnimationStyle: ChipAnimationStyle(
151+
enableAnimation:
152+
parseAnimationStyle(widget.control, "enableAnimationStyle"),
153+
selectAnimation:
154+
parseAnimationStyle(widget.control, "selectAnimationStyle"),
155+
avatarDrawerAnimation: parseAnimationStyle(
156+
widget.control, "avatarDrawerAnimationStyle"),
157+
deleteDrawerAnimation: parseAnimationStyle(
158+
widget.control, "deleteDrawerAnimationStyle"),
159+
),
160+
onPressed: onClick && !disabled
161+
? () {
162+
widget.backend
163+
.triggerControlEvent(widget.control.id, "click");
164+
}
165+
: null,
166+
onDeleted: onDelete && !disabled
167+
? () {
168+
widget.backend
169+
.triggerControlEvent(widget.control.id, "delete");
170+
}
171+
: null,
172+
onSelected: onSelect && !disabled
173+
? (bool selected) {
174+
_onSelect(selected);
175+
}
176+
: null,
185177
),
186178
widget.parent,
187179
widget.control);

0 commit comments

Comments
 (0)