StretchAct class
Animates non-uniform scaling with separate X and Y scale factors.
Unlike ScaleAct, which scales both axes equally, StretchAct allows independent control over horizontal and vertical scaling.
Use separate Stretch values for from and to to specify different
X and Y factors. The scaling occurs around a fixed center alignment.
Basic Stretch Animation
Actor(
acts: [
.stretch(
from: Stretch(x: 1.0, y: 1.0),
to: Stretch(x: 1.2, y: 0.8),
),
],
child: MyWidget(),
)
Vertical Compression
// Compress vertically while maintaining horizontal size
Actor(
acts: [
.stretch(
from: Stretch.none,
to: Stretch(x: 1.0, y: 0.5),
motion: Spring.smooth(damping: 23),
),
],
child: MyWidget(),
)
Width Animation Only
// Animate width while keeping height constant
Actor(
acts: [
.stretch(
from: Stretch(x: 1.0, y: 1.0),
to: Stretch(x: 1.5, y: 1.0),
),
],
child: MyWidget(),
)
Keyframe Sequences
Actor(
acts: [
StretchAct .keyframed(
frames: Keyframes.fractional([
.key(Stretch.none, at: 0.0),
.key(Stretch(x: 1.2, y: 0.8), at: 0.5),
.key(Stretch.none, at: 1.0),
], duration: 1000.ms),
),
],
child: MyWidget(),
)
Constructors
-
StretchAct({Stretch from = Stretch.none, Stretch to = Stretch.none, CueMotion? motion, ReverseBehavior<
Stretch> reverse = const ReverseBehavior.mirror(), Duration delay = Duration.zero, AlignmentGeometry alignment = Alignment.center}) -
Animates non-uniform scaling with separate X and Y factors.
const
-
StretchAct.keyframed({required Keyframes<
Stretch> frames, KFReverseBehavior<Stretch> reverse = const KFReverseBehavior.mirror(), Duration delay = Duration.zero, AlignmentGeometry alignment = Alignment.center}) -
Animates through multiple non-uniform stretch keyframes.
const
Properties
- alignment → AlignmentGeometry
-
The alignment point around which stretching occurs.
final
- delay → Duration
-
Delay before this act's forward animation starts.
finalinherited
-
frames
→ Keyframes<
Stretch> ? -
Keyframes for this act (keyframed mode only).
finalinherited
- from → Stretch?
-
The initial animated value for this tween.
finalinherited
- hashCode → int
-
The hash code for this object.
no setteroverride
- isConstant → bool
-
Whether this tween is a no-op (from == to).
no setterinherited
- key → ActKey
-
The unique identifier for this act type.
final
- motion → CueMotion?
-
Per-act motion override. When non-null, replaces the motion inherited
from Actor or Cue for this act only.
finalinherited
-
reverse
→ ReverseBehaviorBase<
Stretch> -
Reverse behavior for this act — controls what happens when the animation
plays in reverse.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- to → Stretch?
-
The final animated value for this tween (tween mode only).
finalinherited
Methods
-
apply(
BuildContext context, covariant Animation< Stretch> animation, Widget child) → Widget -
Applies the animated value to
childand returns the resulting widget. -
applyInternal(
BuildContext context, covariant CueAnimation< Object?> animation, Widget child) → Widget -
Delegates to
applyafter asserting thatanimationhas the expected typeCueAnimation<R>.inherited -
buildAnimation(
CueTimeline timline, ActContext context) → CueAnimation< Stretch> -
Builds and registers the animation tracks on
timline, returning a CueAnimation that provides the current animated value at each frame.inherited -
buildAnimtable(
ActContext context) → CueAnimtable< Stretch> -
Assembles the forward and reverse animatables into a single
CueAnimtable, wrapping them in a DualAnimatable when a separate
reverse animatable is present.
inherited
-
buildTweens(
ActContext context) → (CueAnimtable< Stretch> , CueAnimtable<Stretch> ?) -
Implements the core reverse behavior logic for tween and keyframed acts.
inherited
-
createSingleTween(
Stretch from, Stretch to) → Animatable< Stretch> -
Creates a single Animatable from
fromtotovalues.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resolve(
ActContext context) → ActContext -
Resolves the final ActContext for this act by calling resolveMotion.
inherited
-
resolveTween(
ActContext context, {required Stretch? from, required Stretch? to, Stretch? iniitalkeyframe, Stretch? implicitFrom, bool forReverse = false, required Keyframes< Stretch> ? keyframes}) → CueAnimtable<Stretch> -
Builds a CueAnimtable from tween or keyframe values.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
transform(
ActContext _, Stretch value) → Stretch -
Identity transform — returns the input value unchanged.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override