-
Notifications
You must be signed in to change notification settings - Fork 601
Closed
Labels
Description
Support gradient borders for all controles with a border like a container.
its insane waht you have to do to create a gradient border.
Here is a "short" example of a gradient border.
With this example its not possible to add a border radius thats the next problem.
import flet as ft
class GradientBorder(ft.Container):
def __init__(self, text: ft.Text, height: float | int = 160, width: float | int = 200, border_width: float | int = 1, border_height: float | int = 1, on_click = None) -> None:
super().__init__(
ft.Row(
[
# INFO Left border.
ft.Container(
width=border_width,
height=height,
padding=0,
gradient=ft.LinearGradient(
begin=ft.Alignment(-1, -0.7),
end=ft.Alignment(-1, 1),
colors=["#000000", "#13aacf"]
)
),
ft.Container(
ft.Column(
[
# INFO Top border.
ft.Container(
height=border_height,
width=width,
padding=0,
bgcolor=ft.colors.with_opacity(0.3, "#000000")
),
# INFO Main Content.
ft.Container(
text,
width=width,
height=height-border_height-border_height,
padding=0,
bgcolor=ft.colors.with_opacity(0.3, "#000000"),
alignment=ft.alignment.center
),
# INFO Bottom border.
ft.Container(
height=border_height,
width=width,
padding=0,
bgcolor="#13aacf"
)
],
spacing=0
),
width=width,
height=height,
padding=0
),
# INFO Right border.
ft.Container(
width=border_width,
height=height,
padding=0,
gradient=ft.LinearGradient(
begin=ft.Alignment(-1, -0.7),
end=ft.Alignment(-1, 1),
colors=["#000000", "#13aacf"]
)
)
],
spacing=0
),
width=width,
height=height,
padding=0,
on_click=on_click
)