MorphSharedElement class

Shared elements inside a flight: a piece of content (an album cover, an avatar, an icon) that TRAVELS from its place in the source to its place in the target instead of riding the fade-through crossfade.

Mark the element on both sides with the same id:

// in the button:
MorphSharedElement(id: 'cover', child: AlbumArt(size: 48))
// in the dialog content:
MorphSharedElement(id: 'cover', child: AlbumArt(size: 240))

Unlike route-level hero frameworks there is no teleportation and no second animation: both contents already live inside the one shuttle, so the flying frame is a pure function of the same spring value (geometry linear in value - interruptions stay continuous by construction), and the element is clipped by the morphing container shape like everything else.

Rules and graceful degradation:

  • an id present on only one side simply renders in place;
  • with snapshotGhost the source side has no live markers, so pairs do not form and the flight falls back to fade-through;
  • the child must not carry a GlobalKey (it is replicated into the flying layer).
Inheritance

Constructors

MorphSharedElement({Key? key, required Object id, MorphSharedFade fade = .through, required Widget child})
Marks child as one side of the shared pair id.
const

Properties

child Widget
The content that flies between its endpoint rects.
final
fade MorphSharedFade
How the two sides blend while flying; either side declaring MorphSharedFade.none applies it to the whole pair.
final
hashCode int
The hash code for this object.
no setterinherited
id Object
Pair identity; the same id on both sides of a flight forms a pair.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<MorphSharedElement>
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