maxWidth method

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

Sets the maximum width constraint for this widget using a SizeUnit.

The widget will not grow beyond this width, even if the parent container or flex growing would normally make it larger.

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

Example:

Text('Long content that wraps').maxWidth(200.size),

Implementation

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