maxSized method

Widget maxSized({
  1. SizeUnit? maxWidth,
  2. SizeUnit? maxHeight,
  3. Key? key,
})

Sets maximum width and height constraints simultaneously.

This is a convenience method for setting maximum size constraints. The widget will not grow beyond these dimensions. Either or both constraints can be specified.

Example:

Container().maxSized(
  maxWidth: 300.size,
  maxHeight: 200.size,
),

Implementation

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