motor 2.0.0-dev.0
motor: ^2.0.0-dev.0 copied to clipboard
A complete motion orchestration system for Flutter with multi-property tracks, keyframes, loops, sync barriers, phases, springs, and curves.
2.0.0-dev.0 #
Note: This is the first Motor 2.0 pre-release. Existing
Motion.*factories,MotionController,MotionBuilder,MotionSequence,SequenceMotionController, andSequenceMotionBuilderstay source-compatible with a few exceptions, though several runtime behaviors have changed. Every change that can break 1.x code is listed under Breaking changes, and MIGRATION.md walks through migrating.
Breaking changes #
Each entry explains what changed, how 1.x behaved, and how to migrate.
- BREAKING: Springs now snap exactly onto their target when they settle (
snapToEnddefaults totrueonSpringMotion,CupertinoMotion,MaterialSpringMotion, and the spring factories onMotion). In 1.1.0 it defaulted tofalse, so a spring could stop slightly short of its target (such as0.9996instead of1.0). PasssnapToEnd: falseto keep the 1.x behavior. - BREAKING: Controllers and motion builders track velocity by default. When you set
valuemanually (for example while dragging) and then animate withoutwithVelocity, the animation continues with the tracked velocity instead of starting from rest as in 1.x. PassvelocityTracking: const .off()to restore the old behavior, or pass gesture velocity directly viawithVelocityfor best accuracy. - BREAKING:
statusnow reportsreversewhile a value moves down when using a directionalMotionConverter(SingleMotionConverteror a customDirectionalMotionConverter). In 1.x,MotionController.statuswas alwaysforwardwhile animating. Non-directional multi-dimensional converters (Offset,Size,Rect,Color, and plain custom converters) still reportforwardwhile animating andcompletedat rest. UseisAnimatinginstead ofstatus == .forwardto check whether a controller is running. - BREAKING: With a directional converter, a move down now settles as
dismissedand any other move settles ascompleted(including after settingvaluedirectly). For non-directional converters, status settles ascompleted, anddismissedonly when settling exactly on the initial value. In 1.x, status wasdismissedonly when the last animation target equaled the initial value. Check!status.isAnimatingor await the returnedMotionFutureinstead of comparing againstcompleted. - BREAKING:
BoundedMotionControllerstatus now follows the same rule asMotionControllerinstead of beingdismissedatlowerBoundandcompletedatupperBound. Directional converters behave the same in practice (reverse()endsdismissed,forward()endscompleted); for non-directional bounded controllers (such as a boundedOffset),reverse()now endscompletedunlesslowerBoundis the initial value. ComparevaluewithlowerBoundandupperBoundto check which bound you are at. - BREAKING:
SequenceMotionControllerandSequenceMotionBuilderreportreversewhile a phase moves down (for example on the way back inLoopMode.pingPong) anddismissedafter a final move down. They still never reportcompletedbetween loop cycles. UseisAnimatinginstead of checkingforwardorcompleted. - BREAKING: Calling
animateTowith the current value keeps the previous direction asstatus(in 1.x it reportedforward). - BREAKING:
MotionController.animateToandstop, andBoundedMotionController.animateTo,forward, andreverse, now returnMotionFutureinstead ofTickerFuture. Callers are unaffected becauseMotionFutureimplementsTickerFuture; subclasses overriding these methods must update their return type toMotionFuture. - BREAKING:
PhaseTransition.settled(...)andPhaseTransition.transitioning(...)are removed. ConstructPhaseSettled(phase)andPhaseTransitioning(from: a, to: b)directly. A newphasegetter returns the current or target phase. - BREAKING: Curve velocities now report their actual rate of change. In 1.x,
CurvedMotionandLinearMotionreported velocities 4× too large, causing a spring taking over mid-curve to launch 4× too fast. If you tuned springs around that overshoot, retune them. - BREAKING: The motion hierarchy is now rooted in a sealed
MotionBase, withMotionfor target-based motions andFreeMotionfor self-directed ones. Custom classes extendingMotioncontinue to work; exhaustive switches over motion types must now handleFreeMotion. - BREAKING: Simulations created by custom motions (
Motion.createSimulation,FreeMotion.createSimulation) must be pure functions of time. Motor queries them ahead to compute settle times and backward when scrubbing, seeking, or looping. Stateful step-by-step simulations must reset from their initial state when queried at an earlier time; see MIGRATION.md. - BREAKING:
MotionConverterimplementations must not retain or mutate the lists Motor hands them.denormalizenow receives a reused internal buffer and Motor may keep the list returned bynormalize. Converters that construct a new value from the numbers are unaffected and now allocate less; if yours returns or stores the list itself, copy it withList.of(values). - BREAKING: Motor no longer depends on
equatable.MotionSequenceand its subclasses no longer mix inEquatableMixin(nopropsorstringify). They still compare by value; custom subclasses that overrodepropsshould override==andhashCodeinstead. - BREAKING: Classes that
implements Motion(instead of extending it) must now implementdurationandscaleTo(Duration). Classes thatextends Motioninherit default implementations. - BREAKING:
CupertinoMotion()andMotion.cupertino()now default to500 ms(matching SwiftUI's defaultSpring(), identical toCupertinoMotion.smooth()) instead of550 ms. Passduration: const Duration(milliseconds: 550)to keep the 1.x timing. - BREAKING:
CupertinoMotion.interactive()andMotion.interactiveSpring()now use bounce0.15instead of0.14to match SwiftUI's currentAnimation.interactiveSpring, andextraBounceadds to0.15. UseCupertinoMotion(duration: const Duration(milliseconds: 150), bounce: 0.14)for the 1.x spring. - BREAKING: A graceful
stop()no longer cancels pending futures onMotionController,BoundedMotionController,TrackController, andPhaseTrackController. It completesendedimmediately and the future itself once the motion settles, matchingAnimationController.stop(canceled: false). Passstop(canceled: true)to cancel. - BREAKING:
ColorRgbMotionConverter.denormalizeno longer clamps channels to0..1itself; the converter now declares bounded dimensions so the displayed value is clamped while internal spring state and velocity are preserved. Code callingdenormalizedirectly may see out-of-range channels. - BREAKING: Classes that
implements MotionConvertermust add thedimensionsgetter (returnnullfor linear dimensions). Classes thatextends MotionConverteror useMotionConverter.customkeep compiling. - BREAKING:
MotionPadding,PaddingExtended, andMotionDraggablemoved to the newmotor_widgetspackage and are no longer exported frompackage:motor.MotionDraggablenow animates every drop (accepted, rejected, or removed), takes builder callbacks forfeedbackandchildWhenDragging, removesonlyReturnWhenCanceledandfeedbackMatchesConstraints, and defaultsmotiontoCupertinoMotion.smooth(). See MIGRATION.md.
Tracks: multi-property motion orchestration #
- FEAT: Add
Track<T>, an identity-based key for one animated property carrying aMotionConverter, optionalinitialvalue, optional defaultmotion/motionPerDimension, and optionaldebugLabel. Call a track with a list of steps to build aTrackAnimation<T>(track([.to(1)])), or usetrack.value(..., velocity:)/track.velocity(...)to build snapshots forsetandinitialValues. - FEAT: Add
TrackStep<T>, the building block of track choreography:TrackStep.to(value, motion:, until:)— animate toward a target, handing off atWaitUntil.settled(default) orWaitUntil.ended(after the motion'sduration, carrying current value and velocity into the next step).TrackStep.at(time, value, motion:)— keyframe that arrives atvalueat an exact time on the track's clock, stretching when there is spare time or trimming the previous step so the keyframe lands on schedule.TrackStep.hold(duration)— hold at the current value while letting any precedingWaitUntil.endedspring finish settling.TrackStep.free(motion:)— hand off to a self-directedFreeMotion(such asFrictionMotion) until rest.TrackStep.sync(token:)— coordinate tracks on the same controller so every track sharingtokenwaits until the last one arrives before continuing together.TrackStep.loop(steps, mode:, count:, together:)— repeat any slice of steps withLoopMode(.loop,.pingPong,.seamless,.none), optional finitecount:, and optionaltogether:token to keep sibling loops synchronized each cycle.
- FEAT: Add
TrackController, a single-ticker multi-track controller that backs every widget and controller in Motor:animatestarts or redirects tracks,setjumps immediately,stopsettles springs or halts withcanceled: true, andpause,resume, andscrubTooperate on a single controller timeline.- Sync barriers release at the exact arrival moment independent of frame rate, release cleanly if a participant is stopped or redirected, and resolve identically when scrubbing.
- Playback is a pure function of time: ticking live, jumping ahead, and scrubbing back always agree, and repeating loops run in constant memory.
onStepfires in order for every step a track enters, even when multiple steps occur within one frame.animationOf(track)returns a cachedAnimation<T>for interop with Flutter transitions and tweens, reporting that track's ownAnimationStatus.statuscombines all tracks moved since the controller was last idle.
- FEAT: Add
TrackPhaseTimeline<P>,PhaseTrackController<P>, andPhaseTrackBuilder<P>for named UI states with automatic sync barriers between phases,initialValues(with optional starting velocities),loopmodes,onTransition(PhaseTransitioning/PhaseSettled), andflattenedfor playing phases once inside a plainTrackBuilderorTrackController. - FEAT: Add
TrackBuilderfor declarative multi-track playback withanimations,initialValues,active,restartTrigger,velocityTracking,tickerRate, anddebugLabel. Rebuilds only redirect tracks whose animation changed, so one track can follow live input while others keep playing. - FEAT: Add
delay:on track animations (track([...], delay:)) for staggering. When redirecting a running track with a delay, the running motion keeps playing through the delay (and any leading holds or barriers) before handing off its value and velocity to the first moving step. - FEAT: Mark
StepTo,StepFree,StepHold,StepAt,StepSync,StepLoop,TrackValue,TrackAnimation, andTrackPhaseTimelineasfinal, andTrackasbase.
Inspection and tooling #
- FEAT: Add an
@experimentalinspection library (package:motor/inspection.dart) for developer tools.MotorInspectionRegistrydiscovers live controllers,inspectPlayback()returns immutable snapshots (plans, resolved segments, loop cycles, playheads, barrier waits, and recorded/estimated step durations), andplaybackSpeed/motionOverridelet tools slow down or swap motions on a single controller.MotorInspectionScopeand per-controllerinspectionGroup/inspectablecontrol grouping and visibility. When no tool is attached, inspection overhead is skipped. - FEAT: Add
debugLabelto controllers, builders, and tracks so they appear with readable names in inspection tools. - FEAT: Introduce the companion
motor_devtoolspackage for an optional in-app timeline inspector and spring tuner.
Deprecations #
- DEPRECATION:
MotionSequence(StateSequence,StepSequence,SpanningSequence,ValueWithMotion,SingleMotionPhaseSequence),SequenceMotionController,SequenceMotionBuilder, and sequence helper extensions are deprecated and will be removed in 3.0. They continue to work on the 2.0 track engine; migrate toTrackandTrackPhaseTimelineusing MIGRATION.md. - DEPRECATION:
NoMotionandMotion.noneare deprecated and will be removed in 3.0. UseMotion.instantto jump to a target immediately, orTrackStep.holdto pause at the current value. - DEPRECATION:
Motion.unboundedWillSettleis deprecated and will be removed in 3.0. Motor no longer reads it; remove your overrides.
Motion type hierarchy #
- FEAT: Add
Motion.instantfor immediate target updates (useful for reduced motion or toggling animations off). - FEAT: Introduce the sealed
MotionBaseroot withMotion(target-based) andFreeMotion(self-directed), includingFrictionMotion(FreeMotion.friction) withfinalValueandprojecthelpers. - FEAT: Add
MotionBase.scaleTo(Duration)to retime any motion to a givenduration(FixedDurationMotionandFixedDurationFreeMotionpreserve spring bounce and start velocity). - FEAT: Add
Motion.durationandFreeMotion.durationfor perceived motion length,MotionFuture(aTickerFuturewith.endedcompleting atduration), and theSettlingSimulationmixin (settlesAtandSimulation.simulateSettleTime()). - FEAT: Add
snapToEnd(defaulting totrue) toMotion.customSpring, matchingSpringMotion.
Single-value controllers, velocity tracking, and converters #
- REFACTOR: Rebuild
MotionControlleras a thin wrapper over a single-trackTrackController, and rebuild the deprecated sequence stack on the same engine. - FEAT: Add
MotionController.play(List<TrackStep<T>>, {onStep})for multi-step and looping single-value playback, plustrackedVelocityEstimate. - FEAT: Add automatic velocity tracking (
VelocityTracking,MotionVelocityTracker,MotionVelocityEstimate), enabled by default on all controllers and builders. - FEAT: Add
DirectionalMotionConverter,ComparableMotionConverter, andMotionConverter.customDirectionalfor directionalAnimationStatusreporting. - FEAT: Add
MotionDimension(linear(),periodic(period),bounded(min, max)),MotionConverter.dimensions, andMotionConverter.anglefor shortest-path radian animations. - REFACTOR: Extract
LoopModeinto its own file (still re-exported frommotion_sequence.dart).
Fixed tick rates #
- FEAT: Add
tickerRateandTickerRateScopesupport viafixed_tickeracross all Motor builders, and re-exportTickerRate,TickerRateScope,FixedTickerProviderStateMixin, andSingleFixedTickerProviderStateMixinfrompackage:motor.
Performance #
- PERF: Significantly reduced per-frame allocations (in-place sampling, reused buffers, lazy velocities and segment ends). In AOT release benchmarks against equivalent
AnimationControllersetups, 10–1000 tracks on oneTrackControllercost 0.89×–1.06× per frame. See benchmark/README.md (thanks to definev for the original benchmark harness and allocation work). - PERF: Starting
Ntracks sharing a sync token now runs in linearO(N)time instead ofO(N²)(4096 staggered tracks with three sync barriers dropped from 355 ms to 15 ms in AOT).
Fixes #
- FIX: Motions that never settle (undamped springs, non-terminating free motions, or simulations whose
simulateSettleTime()isnull) now keep animating until redirected or stopped instead of settling artificially at a fixed horizon; settle searches cap at 120 s consistently. - FIX: Zero-period, single-step, or stalled loops settle cleanly instead of ticking forever.
- FIX:
CupertinoMotionasserts in debug mode ifbounceis outside(-1, 1]and clampsbounce > 1to1in release builds (matching SwiftUI) instead of producing negative damping. - FIX:
stop(),pause(), andresume()no longer notify value listeners when no value changes (unless releasing a sync barrier), matchingAnimationController.stopand allowing render objects to stop controllers during layout. - FIX: Animations already resting on their only target don't tick, notify, or change status, and their futures complete immediately.
- FIX: Instant downward moves (such as
Motion.instant()) now reportreverseanddismissedinstead offorwardandcompleted. - FIX:
LoopMode.pingPongreverses each step to where the preceding step ended even when holds, barriers, or free steps sit between targets. - FIX:
TrackStep.atandTrimmedMotionnow hand off their true arrival velocity to the following step, andTrimmedMotionsettles accurately on its target. - FIX: Two-keyframe
SpanningSequences withLoopMode.seamlessnow use the full return slice instead of a degenerate zero-extent motion. - FIX: Fixed equality and
hashCodeonSpringMotion(snapToEnd,tolerance),CurvedMotion(tolerance),NoMotion(duration), steps/animations/sequences (comparing motions by movement equivalence), andMotionConverters (by type or function identity). - FIX:
CupertinoMotion.copyWithnow reads defaults from its storedduration/bouncefields rather than round-tripping throughSpringDescription. - FIX: Motion builders no longer stop and reset on every rebuild while
activeisfalse— only on thetrue → falsetransition. - FIX: Springs now settle only once they remain within
tolerancepermanently, rather than on the first frame passing through the target near a peak.
1.1.0 #
-
FEAT: added
MotionPadding, motors equivalent toAnimatedPaddingthat can handle negative values. -
FEAT: allow swapping
MotionConverteronMotionControllerandMotionBuildertypes.This enables animating supertypes (such as
EdgeInsetsGeometry, as long as you make sure to always set the converter to match the right subtype. -
DOCS: correct
PhaseMotionControllertoSequenceMotionController.
1.0.1 #
- FIX: velocity scaling when overdragging with resistance.
- DOCS: updated README.
1.0.0 #
- Graduate package to a stable release. See pre-releases prior to this version for changelog entries.
1.0.0-dev.10 #
Note: This release has breaking changes.
- FIX: accept any motion in
SingleMotionController. - FIX: Motion changes in sequences are now picked up correctly.
- BREAKING REFACTOR: rename
TrimmedMotionparameters andMotionTrimmingextension methods to be more intuitive. - BREAKING FEAT: on phase changed callback now returns the full transition.
1.0.0-dev.9 #
- FIX: import internal from package:meta again.
1.0.0-dev.8 #
Note: This release has breaking changes.
- FIX: all motion controllers now correctly report their status, even for imprecise simulations.
- BREAKING REFACTOR:
Motion.nonewill not jump to target anymore, but hold at current value instead. - BREAKING FEAT: all spring motions now default to
snapToEnd: falseto reduce unexpected jitter when animating.
1.0.0-dev.7 #
Note: This release has breaking changes.
-
BREAKING FIX:
SequenceMotionControllerwill not skip the initial phase (#164).However, all sequences with a single provided motion will now return
NoMotionfor the very initial phase only. This retains the expected playing behavior, while working better with customized motions per phase.
1.0.0-dev.6 #
Note: This release has breaking changes.
- FEAT: add constants for included MotionConverters.
- FEAT: add sequence animations to motor.
- FEAT: add TrimmedMotion as a way to take subsets of any motion.
- DOCS: add phase animation to readme.
- DOCS: way better examples.
- BREAKING REFACTOR: use
MotionConverter.custom()if you want to pass custom normalization callbacks. - BREAKING REFACTOR: use const constructors for material springs and make default constructor private.
- BREAKING REFACTOR: use positional parameters for
CurvedMotion. - BREAKING BUILD: require Flutter 3.32.
1.0.0-dev.5 #
- Nothing relevant
1.0.0-dev.4 #
- FIX: use the correct parameters for
MaterialSpringMotion(#127).
1.0.0-dev.3 #
- DOCS: add title gif to README.
- DOCS: add title slide to example.
1.0.0-dev.2 #
Note: This release has breaking changes.
- FEAT: add Material 3 Expressive spring tokens.
- BREAKING REFACTOR: turned
CupertinoMotionconstants into constructors so parameters can be adjusted on the fly.
1.0.0-dev.1 #
Small updates
1.0.0-dev.0 #
Initial release 🥂