@@ -2,6 +2,7 @@ import 'dart:convert';
22import 'dart:typed_data' ;
33
44import 'package:collection/collection.dart' ;
5+ import 'package:flet/src/utils/shadows.dart' ;
56import 'package:flutter/material.dart' ;
67import 'package:flutter_redux/flutter_redux.dart' ;
78
@@ -64,6 +65,7 @@ class ContainerControl extends StatelessWidget {
6465 : null ;
6566
6667 var animation = parseAnimation (control, "animate" );
68+ var blur = parseBlur (control, "blur" );
6769
6870 final server = FletAppServices .of (context).server;
6971
@@ -107,15 +109,20 @@ class ContainerControl extends StatelessWidget {
107109 control.attrString ("shape" , "" )! .toLowerCase (),
108110 orElse: () => BoxShape .rectangle);
109111
112+ var borderRadius = parseBorderRadius (control, "borderRadius" );
113+
110114 var boxDecor = BoxDecoration (
111115 color: bgColor,
112116 gradient: gradient,
113117 image: image,
114118 backgroundBlendMode:
115119 bgColor != null || gradient != null ? blendMode : null ,
116120 border: parseBorder (Theme .of (context), control, "border" ),
117- borderRadius: parseBorderRadius (control, "borderRadius" ),
118- shape: shape);
121+ borderRadius: borderRadius,
122+ shape: shape,
123+ boxShadow: parseBoxShadow (Theme .of (context), control, "shadow" ));
124+
125+ Widget ? result;
119126
120127 if ((onClick || onLongPress || onHover) && ink && ! disabled) {
121128 var ink = Ink (
@@ -165,36 +172,33 @@ class ContainerControl extends StatelessWidget {
165172 child: child,
166173 ),
167174 ));
168- return constrainedControl (
169- context,
170- animation == null
171- ? Container (
172- width: control.attrDouble ("width" ),
173- height: control.attrDouble ("height" ),
174- margin: parseEdgeInsets (control, "margin" ),
175- clipBehavior: clipBehavior,
176- child: ink,
177- )
178- : AnimatedContainer (
179- duration: animation.duration,
180- curve: animation.curve,
181- width: control.attrDouble ("width" ),
182- height: control.attrDouble ("height" ),
183- margin: parseEdgeInsets (control, "margin" ),
184- clipBehavior: clipBehavior,
185- onEnd: control.attrBool ("onAnimationEnd" , false )!
186- ? () {
187- server.sendPageEvent (
188- eventTarget: control.id,
189- eventName: "animation_end" ,
190- eventData: "container" );
191- }
192- : null ,
193- child: ink),
194- parent,
195- control);
175+
176+ result = animation == null
177+ ? Container (
178+ width: control.attrDouble ("width" ),
179+ height: control.attrDouble ("height" ),
180+ margin: parseEdgeInsets (control, "margin" ),
181+ clipBehavior: clipBehavior,
182+ child: ink,
183+ )
184+ : AnimatedContainer (
185+ duration: animation.duration,
186+ curve: animation.curve,
187+ width: control.attrDouble ("width" ),
188+ height: control.attrDouble ("height" ),
189+ margin: parseEdgeInsets (control, "margin" ),
190+ clipBehavior: clipBehavior,
191+ onEnd: control.attrBool ("onAnimationEnd" , false )!
192+ ? () {
193+ server.sendPageEvent (
194+ eventTarget: control.id,
195+ eventName: "animation_end" ,
196+ eventData: "container" );
197+ }
198+ : null ,
199+ child: ink);
196200 } else {
197- Widget container = animation == null
201+ result = animation == null
198202 ? Container (
199203 width: control.attrDouble ("width" ),
200204 height: control.attrDouble ("height" ),
@@ -225,7 +229,7 @@ class ContainerControl extends StatelessWidget {
225229 child: child);
226230
227231 if ((onClick || onLongPress || onHover) && ! disabled) {
228- container = MouseRegion (
232+ result = MouseRegion (
229233 cursor: SystemMouseCursors .click,
230234 onEnter: onHover
231235 ? (value) {
@@ -271,12 +275,21 @@ class ContainerControl extends StatelessWidget {
271275 eventData: "" );
272276 }
273277 : null ,
274- child: container ,
278+ child: result ,
275279 ),
276280 );
277281 }
278- return constrainedControl (context, container, parent, control);
279282 }
283+
284+ if (blur != null ) {
285+ result = borderRadius != null
286+ ? ClipRRect (
287+ borderRadius: borderRadius,
288+ child: BackdropFilter (filter: blur, child: result))
289+ : ClipRect (child: BackdropFilter (filter: blur, child: result));
290+ }
291+
292+ return constrainedControl (context, result, parent, control);
280293 });
281294 }
282295}
0 commit comments