PaintLinearGradient
Inherits: PaintGradient
More information on Linear gradient https://api.flutter.dev/flutter/dart-ui/Gradient/Gradient.linear.html
Properties
-
begin(OffsetValue | None) –The offset at which
-
color_stops(list[Number] | None) –A list of values from
0.0to1.0that denote fractions along the gradient. -
colors(list[str]) –The https://flet.dev/docs/reference/colors the gradient should obtain at each of
-
end(OffsetValue | None) –The offset at which
-
tile_mode(GradientTileMode) –How this gradient should tile the plane beyond in the region before
beginand
Methods
-
copy–Returns a copy of this object with the specified properties overridden.
Properties#
color_stops
#
A list of values from 0.0 to 1.0 that denote fractions along the gradient.
Note
If non-none, this list must have the same length as
colors.
If the first value is not 0.0, then a stop with position 0.0 and a color
equal to the first color in colors is implied. If the last value is not
1.0, then a stop with position 1.0 and a color equal to the last color
in colors is implied.
colors
#
The https://flet.dev/docs/reference/colors the gradient should obtain at each of the stops. This list must contain at least two colors.
Note
If color_stops is not None,
this list must have the same length as color_stops.
tile_mode
#
tile_mode: GradientTileMode = CLAMP
How this gradient should tile the plane beyond in the region before begin and
after end.
Methods#
copy
#
copy(
*,
begin: OffsetValue | None = None,
end: OffsetValue | None = None,
colors: list[str] | None = None,
color_stops: list[Number] | None = None,
tile_mode: GradientTileMode | None = None,
) -> PaintLinearGradient
Returns a copy of this object with the specified properties overridden.
Examples#
Canvas paint#
import flet as ft
import flet.canvas as cv
def main(page: ft.Page):
page.add(
cv.Canvas(
width=float("inf"),
expand=True,
shapes=[
cv.Rect(
x=10,
y=10,
width=100,
height=100,
border_radius=5,
paint=ft.Paint(
style=ft.PaintingStyle.FILL,
gradient=ft.PaintLinearGradient(
begin=(0, 10),
end=(100, 50),
colors=[ft.Colors.BLUE, ft.Colors.YELLOW],
),
),
),
],
)
)
ft.run(main)
