top method

Widget top(
  1. PositionUnit top, [
  2. Key? key
])

Sets the distance from the top edge of the parent container.

This positions the widget at a specific offset from the top edge using a PositionUnit. Can be used with absolute or relative positioning.

The optional key parameter assigns a key to the wrapped widget.

Example:

Text('Header').top(10.position),
Text('Centered').top(0.5.relativePosition),

Implementation

Widget top(PositionUnit top, [Key? key]) {
  return _WidgetWrapper._wrapOrCopyWith(
    child: this,
    key: key != null ? () => key : null,
    top: () => top,
  );
}