PieceStepAnimator class
Drives a single piece through its path one cell at a time, firing
onStepComplete after every cell so the controller can update
LudoGameState and the board repaints at the right intermediate
position.
Usage:
final animator = PieceAnimator();
await animator.animate(
piece: piece,
steps: diceValue,
cell: cellSize,
color: playerColor,
onStepComplete: (intermediatePosition) {
setState(() => piece = piece.copyWith(trackPosition: intermediatePosition));
},
);
Constructors
- PieceStepAnimator({int stepDurationMs = 180})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- stepDurationMs → int
-
Duration of each individual step in milliseconds.
final
Methods
-
animate(
{required LudoPiece piece, required int steps, required void onStep(int newTrackPosition)}) → Future< void> -
Animates
pieceforward bystepscells, invokingonStepafter each cell lands. Awaiting this future means all steps are complete. -
cancel(
) → void - Cancel a running animation early (e.g. on widget dispose).
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited