copyWith method
Gradient
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,
📋 Returns a new copy of this Gradient
with any appropriate
optional parameters overriding those of this
.
Recognizes LinearGradient, RadialGradient, & SweepGradient, as well as this package's LinearSteps, RadialSteps, & SweepSteps.
Defaults back to LinearGradient if Type
cannot be matched.
Gradient copyWith({
List<Color>? colors, List<double>? stops, GradientTransform? transform, TileMode? tileMode,
// Linear
AlignmentGeometry? begin, AlignmentGeometry? end,
// Radial or Sweep
AlignmentGeometry? center,
// Radial
double? radius, AlignmentGeometry? focal, double? focalRadius,
// Sweep
double? startAngle, double? endAngle,
})
Implementation
// ignore: lines_longer_than_80_chars
/// List<Color>? colors, List<double>? stops, GradientTransform? transform, TileMode? tileMode,
/// // Linear
/// AlignmentGeometry? begin, AlignmentGeometry? end,
/// // Radial or Sweep
/// AlignmentGeometry? center,
/// // Radial
/// double? radius, AlignmentGeometry? focal, double? focalRadius,
/// // Sweep
/// double? startAngle, double? endAngle,
/// })
/// ```
Gradient copyWith({
List<Color>? colors,
List<double>? stops,
GradientTransform? transform,
TileMode? tileMode,
// Linear
AlignmentGeometry? begin,
AlignmentGeometry? end,
// Radial or Sweep
AlignmentGeometry? center,
// Radial
double? radius,
AlignmentGeometry? focal,
double? focalRadius,
// Sweep
double? startAngle,
double? endAngle,
}) =>
(this is RadialGradient)
? RadialGradient(
colors: colors ?? this.colors,
stops: stops ?? this.stops,
transform: transform ?? this.transform,
tileMode: tileMode ?? (this as RadialGradient).tileMode,
center: center ?? (this as RadialGradient).center,
radius: radius ?? (this as RadialGradient).radius,
focal: focal ?? (this as RadialGradient).focal,
focalRadius: focalRadius ?? (this as RadialGradient).focalRadius,
)
: (this is SweepGradient)
? SweepGradient(
colors: colors ?? this.colors,
stops: stops ?? this.stops,
transform: transform ?? this.transform,
tileMode: tileMode ?? (this as SweepGradient).tileMode,
center: center ?? (this as SweepGradient).center,
startAngle: startAngle ?? (this as SweepGradient).startAngle,
endAngle: endAngle ?? (this as SweepGradient).endAngle,
)
: (this is LinearSteps)
? LinearSteps(
colors: colors ?? this.colors,
stops: stops ?? this.stops,
transform: transform ?? this.transform,
tileMode: tileMode ?? (this as LinearSteps).tileMode,
begin: begin ?? (this as LinearSteps).begin,
end: end ?? (this as LinearSteps).end,
)
: (this is RadialSteps)
? RadialSteps(
colors: colors ?? this.colors,
stops: stops ?? this.stops,
transform: transform ?? this.transform,
tileMode: tileMode ?? (this as RadialSteps).tileMode,
center: center ?? (this as RadialSteps).center,
radius: radius ?? (this as RadialSteps).radius,
focal: focal ?? (this as RadialSteps).focal,
focalRadius:
focalRadius ?? (this as RadialSteps).focalRadius,
)
: (this is SweepSteps)
? SweepSteps(
colors: colors ?? this.colors,
stops: stops ?? this.stops,
transform: transform ?? this.transform,
tileMode:
tileMode ?? (this as SweepSteps).tileMode,
center: center ?? (this as SweepSteps).center,
startAngle:
startAngle ?? (this as SweepSteps).startAngle,
endAngle:
endAngle ?? (this as SweepSteps).endAngle,
)
: LinearGradient(
colors: colors ?? this.colors,
stops: stops ?? this.stops,
transform: transform ?? this.transform,
tileMode:
tileMode ?? (this as LinearGradient).tileMode,
begin: begin ?? (this as LinearGradient).begin,
end: end ?? (this as LinearGradient).end,
);