Skip to content

Instantly share code, notes, and snippets.

@fredgrott
Created October 20, 2025 18:30
Show Gist options
  • Save fredgrott/1bf2c3e6ebe03dbafe1de11710410120 to your computer and use it in GitHub Desktop.
Save fredgrott/1bf2c3e6ebe03dbafe1de11710410120 to your computer and use it in GitHub Desktop.
motor, sequence animation widget
import 'pacakge:motor/motor.dart';
enum LoadingState { idle, spinning, complete }
SequenceMotionBuilder<LoadingState, double>(
sequence: .states({
.idle: 0.0,
.spinning: 2 * pi,
.complete: 2 * pi,
}, motion: .smoothSpring()),
converter: .single,
playing: true, // Auto-progress through phases
currentPhase: currentState, // Or control manually
onTransition: (transition) => print('Now in transition: $transition'),
builder: (context, rotation, phase, child) {
return Transform.rotate(
angle: rotation,
child: Icon(
phase == .complete ? Icons.check : Icons.refresh,
color: phase == .complete ? Colors.green : Colors.blue,
),
);
},
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment