Gradient class
A builder for creating CSS background gradients.
Supports linear, radial, conic, and repeating gradient types.
Color Stop Specifications:
- Linear & Radial gradients: Color stops accept only length and percentage units
(e.g.,
Dim.percent(50),Dim.px(20),Dim.rem(1.5)). Unitless numbers are not valid in CSS. - Conic gradients: Color stops accept only angle and percentage units
(e.g.,
Dim.deg(90),Dim.percent(50)). Length units (px,rem) are not valid for conic gradients.
Example
final gradient = Gradient()
..applyLinear(
colors: [Colors.blue, Colors.purple],
direction: LinearGradientDirection.toRight,
);
Constructors
- Gradient()
Properties
- cssText → String
-
Generates a CSS string by concatenating all gradients.
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
-
props
→ Map<
String, String> -
Generates a CSS map entry for the gradient.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
applyConic(
{required List< Color> colors, double? angle, ConicGradientPosition? position, List<Dim> ? stops}) → Gradient - Adds a conic gradient.
-
applyLinear(
{required List< Color> colors, double? angle, LinearGradientDirection? direction, List<Dim> ? stops}) → Gradient - Adds a linear gradient.
-
applyRadial(
{required List< Color> colors, Shape? shape, RadialGradientPosition? position, List<Dim> ? stops}) → Gradient - Adds a radial gradient.
-
applyRaw(
String gradient) → Gradient - Adds a raw CSS gradient string.
-
applyRepeatingConic(
{required List< Color> colors, double? angle, ConicGradientPosition? position, List<Dim> ? stops}) → Gradient - Adds a repeating conic gradient.
-
applyRepeatingLinear(
{required List< Color> colors, double? angle, LinearGradientDirection? direction, List<Dim> ? stops}) → Gradient - Adds a repeating linear gradient.
-
applyRepeatingRadial(
{required List< Color> colors, Shape? shape, RadialGradientPosition? position, List<Dim> ? stops}) → Gradient - Adds a repeating radial gradient.
-
clear(
) → Gradient - Removes all gradients.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
Static Properties
- lush → Gradient
-
Lush gradient preset.
final
- oceanBreeze → Gradient
-
Ocean breeze gradient preset.
final
- purpleHaze → Gradient
-
Purple haze gradient preset.
final
- sunset → Gradient
-
Sunset gradient preset.
final