StacGradient class

A Stac representation of gradients for visual effects.

This class supports linear, radial, and sweep gradients with customizable colors, stops, and positioning. Gradients can be used for backgrounds, text styling, and other visual effects.

{@tool snippet} Dart Example:

StacLinearGradient(
  colors: [StacColors.blue, StacColors.red],
  stops: [0.0, 1.0],
  begin: StacAlignment.topLeft,
  end: StacAlignment.bottomRight,
)

{@end-tool}

{@tool snippet} JSON Example:

{
  "gradientType": "linear",
  "colors": ["#2196F3", "#F44336"],
  "stops": [0.0, 1.0],
  "begin": "topLeft",
  "end": "bottomRight"
}

{@end-tool}

Annotations
  • @JsonSerializable.new()

Constructors

StacGradient({StacGradientType? gradientType, List<StacColor>? colors, List<double>? stops, StacAlignment? begin, StacAlignment? end, StacAlignment? center, StacAlignment? focal, StacTileMode? tileMode, double? focalRadius, double? radius, double? startAngle, double? endAngle})
Creates a gradient with optional configuration parameters.
const
StacGradient.fromJson(Map<String, dynamic> json)
Creates a StacGradient from a JSON map.
factory
StacGradient.linear({required List<StacColor>? colors, List<double>? stops, StacAlignment? begin, StacAlignment? end, StacTileMode? tileMode})
Creates a linear gradient.
const
StacGradient.radial({required List<StacColor>? colors, List<double>? stops, StacAlignment? center, StacAlignment? focal, double? focalRadius, double? radius, StacTileMode? tileMode})
Creates a radial gradient.
const
StacGradient.sweep({required List<StacColor>? colors, List<double>? stops, StacAlignment? center, double? startAngle, double? endAngle, StacTileMode? tileMode})
Creates a sweep gradient.
const

Properties

begin → StacAlignment?
The starting alignment for linear gradients.
final
center → StacAlignment?
The center alignment for radial and sweep gradients.
final
colors → List<StacColor>?
The list of colors used in the gradient.
final
end → StacAlignment?
The ending alignment for linear gradients.
final
endAngle → double?
The ending angle for sweep gradients (in radians).
final
focal → StacAlignment?
The focal point alignment for radial gradients.
final
focalRadius → double?
The radius of the focal point for radial gradients.
final
gradientType → StacGradientType?
The type of gradient (linear, radial, or sweep).
final
hashCode → int
The hash code for this object.
no setterinherited
radius → double?
The radius for radial gradients.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
startAngle → double?
The starting angle for sweep gradients (in radians).
final
stops → List<double>?
The stop positions for each color (values between 0.0 and 1.0).
final
tileMode → StacTileMode?
How the gradient should handle areas outside its bounds.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() → Map<String, dynamic>
Converts this StacGradient instance to a JSON map.
toString() → String
A string representation of this object.
inherited

Operators

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