MorphIcon class

A stroke icon that morphs into any other stroke icon.

Three modes, exactly as in the web and React Native bindings:

The lifecycle contract:

  1. Lazy driver. Mounting with no icon at all is fine — it paints nothing, and the first icon to arrive (a late icon prop, a late pair, or an imperative call) brings the driver to life without animating. morphTo before there is anything to fly from behaves as set.
  2. Controlled wins. While from and to are both non-null, the pair owns the path and icon changes are ignored. Drop the pair and icon takes over, animated.
  3. Clean re-entry. Any exit from controlled mode invalidates the frozen pair, so returning to the same pair re-bases on from and renders exactly like a fresh mount at that progress.
Inheritance

Constructors

MorphIcon({Key? key, MorphIconData? icon, MorphIconData? from, MorphIconData? to, double? progress, SpringPreset? preset, double? stiffness, double? damping, Duration? duration, double size = 24, Color? color, double strokeWidth = 2, bool absoluteStrokeWidth = false, String? label})
const

Properties

absoluteStrokeWidth bool
When true the stroke keeps a constant on-screen width regardless of size, like absoluteStrokeWidth in the lucide bindings.
final
color Color?
Stroke colour. Defaults to the ambient IconTheme — the Flutter equivalent of SVG's currentColor.
final
damping double?
Overrides the preset's damping.
final
duration Duration?
How long a morph should take, instead of how stiff it should be.
final
from MorphIconData?
Controlled mode: source endpoint of the pair.
final
hashCode int
The hash code for this object.
no setterinherited
icon MorphIconData?
Uncontrolled mode: the current icon; changing it animates.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
label String?
Accessibility: with a label the icon is exposed as an image; without one it is hidden from assistive technology (the analogue of aria-hidden).
final
preset SpringPreset?
Physics for uncontrolled and imperative mode.
final
progress double?
Controlled mode: (0.0..1.0] progress of the frozen morph (no spring).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
size double
Rendered size in logical pixels. Icons are drawn on a 24×24 grid and scaled to this.
final
stiffness double?
Overrides the preset's stiffness.
final
strokeWidth double
Stroke width in the 24×24 icon space.
final
to MorphIconData?
Controlled mode: target endpoint of the pair.
final

Methods

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