width method

Widget width(
  1. SizeUnit width, [
  2. Key? key
])

Sets the width of this widget using a SizeUnit.

The width can be specified as a fixed pixel value, percentage of parent, viewport-relative size, or other SizeUnit types.

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

Example:

Text('Fixed').width(100.size),
Text('Relative').width(0.5.relativeSize),

Implementation

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