RadialSteps class

A 2D radial stepping "gradient".

This class represent radial steps, abstracting out the arguments to the new ui.Gradient.radial constructor from dart:ui.

A normal RadialSteps has a center and a radius. The center point corresponds to 0.0, and the ring at radius from the center corresponds to 1.0. These lengths are expressed in fractions.

It is also possible to create a two-point (or focal pointed) RadialSteps (which is sometimes referred to as a two point conic gradient, but is not the same as a CSS conic gradient which corresponds to a SweepSteps).

A focal point and focalRadius can be specified similarly to center and radius, which will make the rendered gradient appear to be pointed or directed in the direction of the focal point. This is only important if focal and center are not equal or focalRadius is greater than 0.0 (as this case is visually identical to a normal RadialSteps).

One important case to avoid is having focal and center both resolve to Offset.zero when focalRadius is greater than 0.0. In such a case, a valid shader cannot be created by the framework.

The colors are described by a List<Color>. The stops list, if specified, must have the same length as colors. It specifies fractions of the radius between 0.0 and 1.0, giving concentric rings for each color stop. If it is null, a uniform distribution is assumed.

The region of the canvas beyond radius from the center is painted according to tileMode.

Typically this class is used with BoxDecoration, which does the painting. To use a RadialSteps to paint directly on a canvas, see createShader.

{@tool snippet}

The center example is this RadialSteps

the center example is this RadialSteps

final stepBowRadial = Container(
  decoration: BoxDecoration(
    gradient: RadialSteps(
      tileMode: TileMode.repeated,
      radius: 0.5,
      colors: [
        Colors.pink, Colors.purple, Colors.indigo, Colors.blue,
        Colors.green, Colors.yellow, Colors.orange, Colors.red,
      ],
    );

{@end-tool}

See also:

Inheritance
Available extensions

Constructors

RadialSteps({AlignmentGeometry center = Alignment.center, double radius = 0.5, required List<Color> colors, List<double>? stops, AlignmentGeometry? focal, double focalRadius = 0.0, TileMode tileMode = TileMode.clamp, GradientTransform? transform})
Construct a new RadialSteps type Gradient.
const

Properties

center AlignmentGeometry
The center of this RadialSteps as an offset into the (-1.0, -1.0) x (1.0, 1.0) square describing the Gradient which will be mapped onto the paint box.
final
colors List<Color>
The colors the gradient should obtain at each of the stops.
finalinherited
focal AlignmentGeometry?
The focal point of this RadialSteps. If specified, the RadialSteps will appear to be focused along the vector from center to focal.
final
focalRadius double
The radius of the focal point of this RadialSteps as a fraction of the shortest side of the paint box.
final
hashCode int
The hash code for this object.
no setteroverride
radius double
The radius of this RadialSteps as a fraction of the shortest side of the paint box.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stops List<double>?
A list of values from 0.0 to 1.0 that denote fractions along the gradient.
finalinherited
tileMode TileMode
How this RadialSteps should tile the plane beyond the outer ring at radius pixels from the center.
final
transform GradientTransform?
The transform, if any, to apply to the gradient.
finalinherited

Methods

copyWith({List<Color>? colors, List<double>? stops, AlignmentGeometry? center, double? radius, AlignmentGeometry? focal, double? focalRadius, TileMode? tileMode, GradientTransform? transform}) RadialSteps
📋 Returns a new copy of this RadialSteps with any provided optional parameters overriding those of this.
createShader(Rect rect, {TextDirection? textDirection}) Shader
Creates a ui.Gradient.radial with duplicated colors and stops.
override
lerpFrom(Gradient? a, double t) Gradient?
Linearly interpolates from another Gradient to this.
override
lerpTo(Gradient? b, double t) Gradient?
Linearly interpolates from this to another Gradient.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
scale(double factor) RadialSteps
Returns a new RadialSteps with its colors scaled by the given factor. Since the alpha channel is what receives the scale factor, 0.0 or less results in a gradient that is fully transparent.
override
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override

Static Methods

lerp(RadialSteps? a, RadialSteps? b, double t) RadialSteps?
Copied from RadialGradient.
Linearly interpolate between two RadialStepss.
override