deflate method
Returns the original state of an item attributes in animation according to
entrance
type.
Implementation
Attributes deflate(Set<MarkEntrance> entrance) {
var rst = this;
if (entrance.contains(MarkEntrance.x)) {
rst = Attributes(
index: rst.index,
tag: rst.tag,
position: rst.position
.map((p) => Offset(p.dx.isFinite ? 0 : p.dx, p.dy))
.toList(),
shape: rst.shape,
color: rst.color,
gradient: rst.gradient,
elevation: rst.elevation,
label: rst.label,
size: rst.size,
);
}
if (entrance.contains(MarkEntrance.y)) {
rst = Attributes(
index: rst.index,
tag: rst.tag,
position: rst.position
.map((p) => Offset(p.dx, p.dy.isFinite ? 0 : p.dy))
.toList(),
shape: rst.shape,
color: rst.color,
gradient: rst.gradient,
elevation: rst.elevation,
label: rst.label,
size: rst.size,
);
}
if (entrance.contains(MarkEntrance.size)) {
rst = Attributes(
index: rst.index,
tag: rst.tag,
position: rst.position,
shape: rst.shape,
color: rst.color,
gradient: rst.gradient,
elevation: rst.elevation,
label: rst.label,
size: 0,
);
}
if (entrance.contains(MarkEntrance.opacity)) {
final labelColor = rst.label?.style.textStyle?.color;
final labelRst = labelColor == null
? rst.label
: Label(
rst.label!.text,
LabelStyle(
textStyle: rst.label!.style.textStyle!.apply(color: labelColor),
span: rst.label!.style.span,
textAlign: rst.label!.style.textAlign,
textDirection: rst.label!.style.textDirection,
textScaleFactor: rst.label!.style.textScaleFactor,
maxLines: rst.label!.style.maxLines,
ellipsis: rst.label!.style.ellipsis,
locale: rst.label!.style.locale,
strutStyle: rst.label!.style.strutStyle,
textWidthBasis: rst.label!.style.textWidthBasis,
textHeightBehavior: rst.label!.style.textHeightBehavior,
minWidth: rst.label!.style.minWidth,
maxWidth: rst.label!.style.maxWidth,
offset: rst.label!.style.offset,
rotation: rst.label!.style.rotation,
align: rst.label!.style.align,
));
if (rst.gradient != null) {
final colorsRst =
rst.gradient!.colors.map((color) => color.withAlpha(0)).toList();
Gradient gradientRst;
if (rst.gradient is LinearGradient) {
gradientRst = LinearGradient(
begin: (rst.gradient as LinearGradient).begin,
end: (rst.gradient as LinearGradient).end,
colors: colorsRst,
stops: (rst.gradient as LinearGradient).stops,
tileMode: (rst.gradient as LinearGradient).tileMode,
transform: (rst.gradient as LinearGradient).transform,
);
} else if (rst.gradient is RadialGradient) {
gradientRst = RadialGradient(
center: (rst.gradient as RadialGradient).center,
radius: (rst.gradient as RadialGradient).radius,
colors: colorsRst,
stops: (rst.gradient as RadialGradient).stops,
tileMode: (rst.gradient as RadialGradient).tileMode,
focal: (rst.gradient as RadialGradient).focal,
focalRadius: (rst.gradient as RadialGradient).focalRadius,
transform: (rst.gradient as RadialGradient).transform,
);
} else if (rst.gradient is SweepGradient) {
gradientRst = SweepGradient(
center: (rst.gradient as SweepGradient).center,
startAngle: (rst.gradient as SweepGradient).startAngle,
endAngle: (rst.gradient as SweepGradient).endAngle,
colors: colorsRst,
stops: (rst.gradient as SweepGradient).stops,
tileMode: (rst.gradient as SweepGradient).tileMode,
transform: (rst.gradient as SweepGradient).transform,
);
} else {
throw ArgumentError('Wrong gradient type.');
}
rst = Attributes(
index: rst.index,
tag: rst.tag,
position: rst.position,
shape: rst.shape,
color: rst.color,
gradient: gradientRst,
elevation: rst.elevation,
label: labelRst,
size: rst.size,
);
} else {
rst = Attributes(
index: rst.index,
tag: rst.tag,
position: rst.position,
shape: rst.shape,
color: color!.withAlpha(0),
gradient: rst.gradient,
elevation: rst.elevation,
label: labelRst,
size: rst.size,
);
}
}
return rst;
}