Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion packages/flet/lib/src/controls/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import '../utils/box.dart';
import '../utils/buttons.dart';
import '../utils/colors.dart';
import '../utils/edge_insets.dart';
import '../utils/gradient.dart';
import '../utils/images.dart';
import '../utils/numbers.dart';
import '../utils/theme.dart';
import '../widgets/loading_page.dart';
Expand Down Expand Up @@ -272,9 +274,21 @@ class _ViewControlState extends State<ViewControl> {
var foregroundDecoration =
control.getBoxDecoration("foreground_decoration", context);
if (backgroundDecoration != null || foregroundDecoration != null) {
result = Container(
var bgContainer = Container(
decoration: backgroundDecoration,
foregroundDecoration: foregroundDecoration,
);
result = Stack(
fit: StackFit.expand,
children: [bgContainer, result],
);
}

var shaderGradient = control.getGradient("shader", Theme.of(context));
if (shaderGradient != null) {
result = ShaderMask(
shaderCallback: (bounds) => shaderGradient.createShader(bounds),
blendMode: control.getBlendMode("blend_mode", BlendMode.modulate)!,
child: result,
);
}
Expand Down
12 changes: 12 additions & 0 deletions sdk/python/packages/flet/src/flet/controls/core/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from flet.controls.control_event import ControlEventHandler
from flet.controls.cupertino.cupertino_app_bar import CupertinoAppBar
from flet.controls.cupertino.cupertino_navigation_bar import CupertinoNavigationBar
from flet.controls.gradients import Gradient
from flet.controls.layout_control import LayoutControl
from flet.controls.material.app_bar import AppBar
from flet.controls.material.bottom_app_bar import BottomAppBar
Expand All @@ -18,6 +19,7 @@
from flet.controls.services.service import Service
from flet.controls.transform import OffsetValue
from flet.controls.types import (
BlendMode,
ColorValue,
CrossAxisAlignment,
FloatingActionButtonLocation,
Expand Down Expand Up @@ -156,6 +158,16 @@ class View(ScrollableControl, LayoutControl):
The foreground decoration.
"""

shader: Optional[Gradient] = None
"""
Use gradient as a shader.
"""

blend_mode: BlendMode = BlendMode.MODULATE
"""
The blend mode to use when applying the shader
"""

fullscreen_dialog: bool = False
"""
If `True`, the view is a fullscreen modal dialog.
Expand Down
Loading