LinearColorGradient class

A linear gradient implementation of ColorGradient.

LinearColorGradient represents a gradient that transitions linearly between colors along a specified angle. It supports multiple color stops and different tile modes for how the gradient repeats beyond its bounds.

Example:

final gradient = LinearColorGradient(
  colors: [
    ColorStop(color: ColorDerivative.fromColor(Colors.red), position: 0.0),
    ColorStop(color: ColorDerivative.fromColor(Colors.blue), position: 1.0),
  ],
  angle: const GradientAngle(0.0),
);
Inheritance

Constructors

LinearColorGradient({required List<ColorStop> colors, GradientAngleGeometry angle = const DirectionalGradientAngle(0), TileMode tileMode = TileMode.clamp})
Creates a LinearColorGradient with the specified parameters.
const

Properties

angle → GradientAngleGeometry
The angle of the gradient.
final
colors → List<ColorStop>
The list of color stops in the gradient.
final
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
tileMode → TileMode
How the gradient repeats beyond its bounds.
final

Methods

changeColorAndPositionAt(int index, ColorDerivative color, double position) → LinearColorGradient
Changes both the color and position at the specified index.
override
changeColorAt(int index, ColorDerivative color) → LinearColorGradient
Changes the color at the specified index.
override
changePositionAt(int index, double position) → LinearColorGradient
Changes the position of the color stop at the specified index.
override
copyWith({List<ColorStop>? colors, GradientAngleGeometry? angle, TileMode? tileMode}) → LinearColorGradient
Creates a copy of this gradient with optional modifications.
override
insertColorAt(ColorDerivative color, Offset position, Size size, TextDirection textDirection) → ({LinearColorGradient gradient, int index})
Inserts a new color stop at a specific position in the gradient.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toGradient() → LinearGradient
Converts this color gradient to a Flutter Gradient.
override
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited