Paint class final

A fill or stroke paint: a solid color, a gradient or an image. Several paints stack, first at the bottom.

Annotations
  • @immutable

Constructors

Paint({PaintType type = PaintType.solid, String? id, bool visible = true, double opacity = 1, BlendMode blendMode = BlendMode.srcOver, Color? color, List<ColorStop> stops = const [], List<double>? transform, TileMode tileMode = TileMode.clamp, ImagePaint? image, double? radius, Alignment? begin, Alignment? end, Alignment? center, double? length, double? angle, NoisePaint? noise})
const
Paint.solid(Color color, {String? id, double opacity = 1})
const

Properties

angle → double?
A linear gradient's direction in degrees, as CSS linear-gradient(<angle>, …): 0 runs up, 90 to the right, 180 down, clockwise. Its line passes through the box's middle and is as long as a line at that angle needs to reach the box's farthest corners, so the angle stays the same in the world at any aspect (a banner that grows taller as its text wraps keeps its 103° sheen). In place of begin, end and transform. Null: those.
final
begin → Alignment?
A linear gradient's start and end as written (Flutter's LinearGradient.begin/end), kept for encoding; transform holds the axis they give when no transform is written.
final
blendMode → BlendMode
final
center → Alignment?
A radial (sweep, diamond) gradient's center as written (Flutter's RadialGradient.center), kept for encoding; transform holds it.
final
color → Color?
Solid color (type solid).
final
effectiveColor → Color?
The solid color with the paint's opacity applied.
no setter
end → Alignment?
A linear gradient's start and end as written (Flutter's LinearGradient.begin/end), kept for encoding; transform holds the axis they give when no transform is written.
final
hashCode → int
The hash code for this object.
no setteroverride
id → String?
Stable id, so a binding can target one paint (fill-<id>).
final
image → ImagePaint?
Image (type image).
final
isGradient → bool
no setter
length → double?
A gradient's length in logical pixels (CSS repeating-linear-gradient(..., 80px), Flutter's ui.Gradient.linear between two points in pixels): linear, from begin toward end; radial, its radius. With tileMode: repeated the pattern repeats every length px whatever the box's size. Null: the extent begin/end, radius or transform gives (a share of the box).
final
noise → NoisePaint?
A noise paint's noise (null for other types).
final
opacity → double
final
radius → double?
A radial gradient's radius as a share of the box's shortest side, centered (Flutter's RadialGradient(radius:)), in place of the one transform gives (which reaches the box's edge across its width). Null: the transform's.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
stops → List<ColorStop>
Gradient stops (gradient types).
final
tileMode → TileMode
final
transform → List<double>?
Gradient transform: a 2×3 affine matrix [a, b, tx, c, d, ty] mapping the unit square onto the box (Figma's gradient transform).
final
type → PaintType
final
visible → bool
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() → Json
toString() → String
A string representation of this object.
inherited

Operators

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

Static Methods

centerTransform(Alignment? center) → List<double>?
The transform of a linear gradient from begin to end, as Flutter's LinearGradient(begin, end) draws it: the gradient's axis runs from the point begin names to the point end names. JSON may give begin and end (alignments: [x, y] in -1..1, or names such as "topCenter") instead of a transform; they are read into one. The transform of a radial (or sweep, diamond) gradient centered at center (Flutter's RadialGradient.center), else null.
fromJson(Object? json) → Paint?
linearTransform(Alignment? begin, Alignment? end) → List<double>?
listFromJson(Object? json) → List<Paint>