LinearSteps class
A 2D linear stepped "gradient".
This class is used to represent linear steps, abstracting out
the arguments to the new ui.Gradient.linear constructor from dart:ui.
A LinearSteps has two anchor points, begin and end. The begin point
corresponds to 0.0, and the end point corresponds to 1.0.
These points are expressed in fractions.
The colors are a List<Color>.
The stops list, if specified, must have the same length as colors.
It specifies fractions of the vector from start to end, between
0.0 and 1.0, for each color.
If it is null, a uniform distribution is assumed.
The region of the canvas before begin and after end is colored according to tileMode.
Typically this class is used with BoxDecoration, which does the painting. To use a LinearSteps to paint directly on a canvas, see createShader.
{@tool snippet}
The right-most example is this LinearSteps

final stepBowLinear = Container(
decoration: BoxDecoration(
gradient: LinearSteps(
tileMode: TileMode.repeated,
begin: Alignment.topLeft,
end: Alignment.centerLeft,
colors: [
Colors.red, Colors.orange, Colors.yellow, Colors.green,
Colors.blue, Colors.indigo, Colors.purple, Colors.pink,
],
),
),
);
{@end-tool}
See also:
- LinearGradient, which represents a true linear gradient
- RadialSteps, a variety of RadialGradient that, like this
Gradient, steps instead of gradating - BoxDecoration, which can take a LinearSteps in its BoxDecoration.gradient property.
- Inheritance
- Available extensions
Constructors
-
LinearSteps({AlignmentGeometry begin = Alignment.centerLeft, AlignmentGeometry end = Alignment.centerRight, required List<
Color> colors, List<double> ? stops, TileMode tileMode = TileMode.clamp, GradientTransform? transform}) -
Construct a new
LinearStepstypeGradient.const
Properties
- asNill → Gradient
-
Available on Gradient, provided by the NillGradients extension
Gradient get asNill => nillify( /* this. */ runtimeType);no setter - begin → AlignmentGeometry
-
The offset at which stop
0.0of thisLinearStepsis placed.final - begin → AlignmentGeometry
-
Available on Gradient, provided by the GradientUtils extension
If this is a linear-typeGradient, returnsthis.begin. Otherwise the fallback retrun value is Alignment.center.no setter - center → AlignmentGeometry
-
Available on Gradient, provided by the GradientUtils extension
If this is a radial- or sweep-typeGradient, returnsthis.center. Otherwise the fallback retrun value is Alignment.center.no setter -
colors
→ List<
Color> -
The colors the gradient should obtain at each of the stops.
finalinherited
- distance → double
-
Available on Gradient, provided by the GradientUtils extension
If this is aShadedSteps-typeGradient, returnsthis.distance. Otherwise the fallback retrun value is0.0.no setter - end → AlignmentGeometry
-
The offset at which stop
1.0of thisLinearStepsis placed.final - end → AlignmentGeometry
-
Available on Gradient, provided by the GradientUtils extension
If this is a linear-typeGradient, returnsthis.end. Otherwise the fallback retrun value is Alignment.center.no setter - endAngle → double
-
Available on Gradient, provided by the GradientUtils extension
If this is a sweep-typeGradient, returnsthis.endAngle. Otherwise the fallback retrun value is0.0.no setter - focal → AlignmentGeometry?
-
Available on Gradient, provided by the GradientUtils extension
If this is a radial-typeGradient, returnsthis.focalwhich may benull. Otherwise the fallback retrun value isnull.no setter - focalRadius → double
-
Available on Gradient, provided by the GradientUtils extension
If this is a radial-typeGradient, returnsthis.focalRadius. Otherwise the fallback retrun value is0.0.no setter - hashCode → int
-
The hash code for this object.
no setteroverride
- radius → double
-
Available on Gradient, provided by the GradientUtils extension
If this is a radial-typeGradient, returnsthis.radius. Otherwise the fallback retrun value is0.0.no setter - reversed → Gradient
-
Available on Gradient, provided by the GradientUtils extension
Returns a copy of thisGradientwith itsList<Color>colors reversed as well as any potential stops.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shadeFactor → double
-
Available on Gradient, provided by the GradientUtils extension
If this is aShadedSteps-typeGradient, returnsthis.shadeFactor. Otherwise the fallback retrun value is0.no setter - shadeFunction → ColorArithmetic
-
Available on Gradient, provided by the GradientUtils extension
If this is aShadedSteps-typeGradient, returnsthis.shadeFunction. Otherwise the fallback retrun value is Shades.withWhite.no setter - softness → double
-
Available on Gradient, provided by the GradientUtils extension
If this is a Steps-typeGradient, returnsthis.softness. Otherwise the fallback retrun value is0.0.no setter - startAngle → double
-
Available on Gradient, provided by the GradientUtils extension
If this is a sweep-typeGradient, returnsthis.startAngle. Otherwise the fallback retrun value is0.0.no setter -
steppedColors
→ List<
Color> -
Available on Gradient, provided by the GradientUtils extension
If this is a Steps-typeGradient, returnsthis.steppedColors. Otherwise the fallback retrun value is colors.no setter -
steppedStops
→ List<
double> ? -
Available on Gradient, provided by the GradientUtils extension
If this is a Steps-typeGradient, returnsthis.steppedStops. Otherwise the fallback retrun value is stops.no setter -
stops
→ List<
double> ? -
A list of values from 0.0 to 1.0 that denote fractions along the gradient.
finalinherited
- tileMode → TileMode
-
How this
LinearStepsshould tile the plane beyond the region before begin and after end.final - tileMode → TileMode
-
Available on Gradient, provided by the GradientUtils extension
How thisGradienttiles in the plane beyond the region before its starting stop and after its ending stop.no setter - transform → GradientTransform?
-
The transform, if any, to apply to the gradient.
finalinherited
Methods
-
animate(
{required Animation< double> controller, Map<GradientAnimation, dynamic> storyboard = const {}, GradientCopyWith overrideCopyWith = spectrumCopyWith}) → Gradient -
Available on Gradient, provided by the GradientUtils extension
Returns the AnimatedGradient.observe animatedGradientoutput from anew AnimatedGradientconstructed bythisgradient and the provided parameters. -
copyWith(
{List< Color> ? colors, List<double> ? stops, AlignmentGeometry? begin, AlignmentGeometry? end, TileMode? tileMode, GradientTransform? transform}) → LinearSteps -
📋 Returns a new copy of this
LinearStepswith any provided optional parameters overriding those ofthis. -
copyWith(
{List< Color> ? colors, List<double> ? stops, GradientTransform? transform, TileMode? tileMode, AlignmentGeometry? begin, AlignmentGeometry? end, AlignmentGeometry? center, double? radius, AlignmentGeometry? focal, double? focalRadius, double? startAngle, double? endAngle}) → Gradient -
Available on Gradient, provided by the GradientUtils extension
📋 Returns a new copy of thisGradientwith any appropriate optional parameters overriding those ofthis. -
copyWith(
{List< Color> ? colors, List<double> ? stops, GradientTransform? transform, TileMode? tileMode, AlignmentGeometry? begin, AlignmentGeometry? end, AlignmentGeometry? center, double? radius, AlignmentGeometry? focal, double? focalRadius, double? startAngle, double? endAngle, double? softness, ColorArithmetic? shadeFunction, double? shadeFactor, double? distance}) → Gradient -
Available on Gradient, provided by the GradientUtils extension
📋 Returns a new copy of thisGradientwith any appropriate optional parameters overriding those ofthis. -
createShader(
Rect rect, {TextDirection? textDirection}) → Shader -
Creates a
ui.Gradient.linearwith duplicatedcolorsandstops.override -
lerpFrom(
Gradient? a, double t) → Gradient? -
Linearly interpolates from another Gradient to
this.override -
lerpTo(
Gradient? b, double t) → Gradient? -
Linearly interpolates from
thisto another Gradient.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
scale(
double factor) → LinearSteps -
Returns a new LinearSteps with its colors scaled by the given factor.
Since the alpha channel is what receives the scale factor,
0.0or less results in a gradient that is fully transparent.override -
toString(
) → String -
A string representation of this object.
override
-
withOpacity(
double opacity) → Gradient -
Returns a new Gradient with each color set to the given opacity.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
Static Methods
-
lerp(
LinearSteps? a, LinearSteps? b, double t) → LinearSteps? -
Copied from LinearGradient.
Linearly interpolate between two LinearSteps.override