StacHero class

A Stac model representing Flutter's Hero widget.

Enables hero animations between routes by tagging widgets with the same tag. Optionally customizes the rectangle tween and shuttle/placeholder builders. Renders its child.

{@tool snippet} Dart Example:

StacHero(
  tag: 'userAvatar',
  child: StacImage(network: 'https://example.com/avatar.png'),
)

{@end-tool}

{@tool snippet} JSON Example:

{
  "type": "hero",
  "tag": "userAvatar",
  "child": { "type": "image", "network": "https://example.com/avatar.png" }
}

{@end-tool}

See also:

  • Flutter's Hero documentation (https://api.flutter.dev/flutter/widgets/Hero-class.html)
Inheritance
Annotations
  • @JsonSerializable(explicitToJson: true)

Constructors

StacHero.new({required dynamic tag, required StacWidget child, StacRectTween? createRectTween, StacWidget? flightShuttleBuilder, StacWidget? placeholderBuilder, bool? transitionOnUserGestures})
Creates a StacHero.
const
StacHero.fromJson(Map<String, dynamic> json)
Creates a StacHero from a JSON map.
factory

Properties

child StacWidget
The widget subtree for this hero.
final
createRectTween StacRectTween?
Optional rectangle tween configuration for the hero animation.
final
flightShuttleBuilder StacWidget?
Optional widget used as the in-flight shuttle during the hero animation.
final
hashCode int
The hash code for this object.
no setterinherited
jsonData Map<String, dynamic>?
Raw JSON data for this widget
finalinherited
placeholderBuilder StacWidget?
Optional placeholder widget displayed while the destination hero builds.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
tag → dynamic
The hero tag used to match heroes across routes.
final
transitionOnUserGestures bool?
Whether the hero should participate in a user gesture driven transition.
final
type String
Widget type identifier.
no setteroverride

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Converts this StacHero instance to a JSON map.
override
toString() String
A string representation of this object.
inherited

Operators

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