主题
BoxShadow
Configuration for a box's shadow.
属性
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
spread_radius | Number | 0.0 | The amount the box should be inflated prior to applying the blur. |
blur_radius | Number | 0.0 | The standard deviation of the Gaussian to convolve with the shadow's shape. |
color | ColorValue | Colors.BLACK | Color used to draw the shadow. |
offset | OffsetValue | Offset(() | The displacement of the shadow from the casting element. Positive x/y offsets will shift the shadow to the right and down, while negative offsets shift the shadow to the left and up. The offsets are relative to the position of the element that is casting it. |
blur_style | BlurStyle | BlurStyle.NORMAL | The blur style to apply to this shadow. |
方法
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
copy | 'BoxShadow' | — | 返回此对象的副本,可覆盖指定属性。 |
示例
Example 1
python
import flet as ft
def main(page: ft.Page):
page.add(
ft.SafeArea(
content=ft.Column(
controls=[
ft.Container(
bgcolor=ft.Colors.YELLOW,
width=100,
height=100,
border_radius=50,
shadow=[
ft.BoxShadow(
spread_radius=1,
blur_radius=15,
color=ft.Colors.WHITE,
offset=ft.Offset(-5, -5),
),
ft.BoxShadow(
spread_radius=1,
blur_radius=15,
color=ft.Colors.GREY_600,
offset=ft.Offset(5, 5),
),
],
),
ft.Container(
# bgcolor=ft.Colors.WHITE,
border_radius=10,
width=100,
height=100,
shadow=ft.BoxShadow(
spread_radius=1,
blur_radius=15,
color=ft.Colors.BLUE_GREY_300,
offset=ft.Offset(0, 0),
blur_style=ft.BlurStyle.OUTER,
),
),
]
)
)
)
if __name__ == "__main__":
ft.run(main)