Box class final

A solid block, bar, or divider — animatable like anything else:

Box(color: Colors.white, size: Size(0.5, 0.01))     // a thin rule
    .animate([Animation.from(const Keyframe(scaleX: 0))]);   // grows in

size components are always fractions of the parent: Size(0.5, 0.01) is half the parent's width by 1% of its height, and null expands to the whole parent. There is no "values above one are pixels" heuristic — for absolute dimensions wrap a plain SizedBox, exactly like the rest of the layout story uses Flutter's real widgets.

An optional shared anchor wraps the box in a SharedElement so it morphs across the boundary it shares with the same anchor in the adjacent scene; null mounts no SharedElement.

Inheritance
Available extensions

Constructors

Box({Color? color, Size? size, BoxDecoration? decoration, Anchor? shared, Key? key})
Creates a block filling size of its parent with color or decoration (at most one; neither paints a transparent spacer).
const

Properties

color Color?
The fill color, or null when decoration (or nothing) paints.
final
decoration BoxDecoration?
The fill decoration, or null when color (or nothing) paints.
final
hashCode int
The hash code for this object.
no setterinherited
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
shared Anchor?
An optional hero anchor: when non-null the box morphs across the boundary it shares with the same anchor in the adjacent scene. null mounts no SharedElement.
final
size Size?
The parent-fraction size (width fraction × height fraction), or null to expand to the whole parent.
final

Methods

animate(List<Animation> animations, {Anchor? anchor, TimeRange? window, Defaults? defaults}) Widget

Available on Widget, provided by the Animate extension

Binds animations to this widget by wrapping it in a MotionTarget.
build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
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
show({Time? from, Time? to}) Widget

Available on Widget, provided by the Animate extension

Visibility-window sugar: animate([], window: from.to(to)) with from defaulting to the window start and to to its end.
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