MorphController class

Unified animation controller for any morph transition.

Drives a single AnimationController from 0.0 (collapsed) → 1.0 (expanded). Supports:

Usage:

late final MorphController _controller;

@override
void initState() {
  _controller = MorphController(vsync: this);
}

// Expand from a rect to fullscreen
_controller.expandFrom(
  origin: origin,
  targetRect: const Rect.fromLTWH(0, 0, 400, 800),
);
Inheritance

Constructors

MorphController({required TickerProvider vsync, Duration expandDuration = const Duration(milliseconds: 420), Duration collapseDuration = const Duration(milliseconds: 350), Curve expandCurve = Curves.easeInOutCubic, Curve collapseCurve = Curves.easeInOutCubic})

Properties

currentRect Rect?
Interpolated rect at the current progress (origin → target).
no setter
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
isAnimating bool
no setter
isCollapsed bool
no setter
isDragging bool
no setter
isExpanded bool
no setter
origin MorphOrigin?
no setter
phase MorphPhase
no setter
progress double
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state MorphState
no setter
targetRect Rect?
no setter

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
collapse({Duration? duration, Curve? curve}) → void
Collapse back to origin.
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed).
override
endDrag(double velocityPxPerSecond, double availableHeight) → void
End the drag and snap based on velocityPxPerSecond.
expand({Duration? duration, Curve? curve}) → void
Public alias for expandFrom without changing origin/target.
expandFrom({MorphOrigin? origin, Rect? targetRect, Duration? duration, Curve? curve}) → void
Begin expansion from origintargetRect.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
startDrag() → void
Begin an interactive drag session.
toString() String
A string representation of this object.
inherited
updateDrag(double delta, double availableHeight) → void
Update drag by delta pixels (negative = up/expand, positive = down/collapse).

Operators

operator ==(Object other) bool
The equality operator.
inherited