MorphAnchor class
The declarative layer on top of the engine: a morph as a function of state, in the spirit of SwiftUI's matchedGeometryEffect, adapted to Flutter's rules.
The anchor and the overlay are colocated in the tree (like MenuAnchor); the source of truth is isOpen owned by the state holder. Opening, closing, and interruption are just a bool flip: toggled mid-flight - the spring retargets with velocity carry-over. A scrim tap and Esc do not close the overlay themselves; they call onDismiss - state flows down, events flow up.
Identity is implicit: the State itself serves as the tag (analogous to a SwiftUI Namespace); no global string ids required.
MorphAnchor(
isOpen: _sharing,
onDismiss: () => setState(() => _sharing = false),
target: MorphTargetSpec.sheet(),
shape: const StadiumBorder(),
closedBuilder: (context) =>
ShareButton(onTap: () => setState(() => _sharing = true)),
openBuilder: (context) => ShareSheet(),
)
The imperative showMorph remains alongside as an escape hatch - like showDialog next to OpenContainer.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- MorphAnchor
Constructors
- MorphAnchor({Key? key, required bool isOpen, required VoidCallback onDismiss, required MorphTargetSpec target, required WidgetBuilder closedBuilder, required MorphContentBuilder openBuilder, Object? tagId, MorphSurfaceSpec? spec, ShapeBorder shape = const RoundedRectangleBorder(), Color? surfaceColor, double elevation = 0, Widget? replica, bool snapshotGhost = false, MorphMotion? motion, bool barrierDismissible = true, double? maxScrimOpacity, Color? scrimColor, Color? shadowColor, String? semanticLabel})
-
Creates a declarative morph driven by
isOpen.const
Properties
- barrierDismissible → bool
-
Whether scrim taps and Esc request dismissal.
final
- closedBuilder → WidgetBuilder
-
Builds the inline widget (the flight's source).
final
- elevation → double
-
The source elevation (MorphTag.elevation semantics): a source
with its own shadow must declare it, or the shadow pops at launch
and handoff.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isOpen → bool
-
Whether the overlay should be open; changes retarget the flight.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- maxScrimOpacity → double?
-
Scrim ceiling; null resolves MorphTheme, then the default.
final
- motion → MorphMotion?
-
Motion profile; null resolves MorphTheme, then the default.
final
- onDismiss → VoidCallback
-
Called when the user dismisses (scrim tap, Esc, back): flip the
state that feeds isOpen - state down, events up.
final
- openBuilder → MorphContentBuilder
-
Builds the overlay content. Rebuilt when the anchor rebuilds, so
content derived from the owner's state stays fresh in the open
overlay.
final
- replica → Widget?
-
The in-flight copy for the shuttle (MorphTag.replica semantics).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrimColor → Color?
-
Scrim hue; null resolves MorphTheme, then black.
final
- semanticLabel → String?
-
Accessibility name of the opened overlay (screen readers announce
it).
final
- shadowColor → Color?
-
Shadow color of the flying surface, opacity included; null
resolves MorphTheme, then 60% black.
final
- shape → ShapeBorder
-
The source outline the shuttle takes off from.
final
- snapshotGhost → bool
-
Fly a pixel snapshot instead of a widget replica
(MorphTag.snapshotGhost semantics).
final
- spec → MorphSurfaceSpec?
-
The source surface model as one value (MorphTag.spec semantics:
wins over shape/surfaceColor/elevation).
final
- surfaceColor → Color?
-
The source surface color.
final
- tagId → Object?
-
An explicit tag id instead of identity-by-State. Needed when the
anchor's flight must be visible to outside consumers by name - for
example, a MorphPiece with the same id gets the flight neck for
free. Must stay stable for the anchor's whole lifetime.
final
- target → MorphTargetSpec
-
The destination description.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< MorphAnchor> -
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