AnimatedMorph class

content that morphs, outline into outline, to each new content it's given: a word into another word or an icon, an icon into a word or another icon, any style into any other.

The implicit counterpart of MorphBetween, as morphnext's AnimatedMorphIcon is to MorphIcon, and driven the same way: changing content starts a spring (morphnext's MorphSprings.snappy by default) from what's on screen. Turning back before it settles reverses from where it is, keeping its velocity. A third target arriving mid-flight starts from whichever of the two is nearer.

Give it a curve instead for a fixed duration, as Flutter's implicit animations run.

At rest it is plain text (or an Icon), pixel for pixel. Hinted text never quite matches an outline (on the web, light text renders thinner, its baseline snapped to the pixel), so the text fades in over the outlines in the last of the motion (handoff), while the word is still moving, rather than switching once it's still.

When the platform asks for reduced motion (MediaQueryData.disableAnimations), changes apply at once.

Inheritance

Constructors

AnimatedMorph(MorphContent content, {Key? key, SpringDescription spring = MorphSprings.snappy, Curve? curve, Duration duration = defaultDuration, double handoff = defaultHandoff, VoidCallback? onEnd, String? semanticsLabel})
Creates content that morphs to each new content.
const

Properties

content → MorphContent
What to show, and to morph into when it changes.
final
curve → Curve?
A curve to run each morph along over duration instead of the spring. Null for the spring.
final
duration → Duration
How long each morph takes along a curve.
final
handoff → double
The share of the morph's end, 0..1, over which the end's plain text fades in over the outlines, while the word is still moving, so the switch from outline to hinted text (which never quite match) blends instead of stepping once it lands. A spring's remaining speed counts too, so an overshoot in flight is still motion. 0 swaps at the end.
final
hashCode → int
The hash code for this object.
no setterinherited
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onEnd → VoidCallback?
Called when a morph ends; not for the first content, nor for a morph that was interrupted.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
semanticsLabel → String?
The label announced; content's when null.
final
spring → SpringDescription
The spring that drives each morph: morphnext's MorphSprings or any SpringDescription. Ignored with a curve.
final

Methods

createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<AnimatedMorph>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String
Returns a one-line detailed description of the object.
inherited
toStringShort() → String
A short, textual description of this widget.
inherited

Operators

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

Constants

defaultDuration → const Duration
The default duration for a curve.
defaultHandoff → const double
The default handoff: the last tenth of the morph, chosen by eye on the web, where the mismatch is largest.