flexShrink method

Widget flexShrink(
  1. double flexShrink, [
  2. Key? key
])

Sets the flex shrink factor for this widget within a flex container.

The flex shrink factor determines how much the widget should shrink relative to other flex items when there is insufficient space. A value of 1 means the widget will shrink proportionally with others.

This wraps the widget in a FlexItem with the specified shrink factor.

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

Example:

Container().flexShrink(1),  // Shrinks normally
Container().flexShrink(0),  // Does not shrink

Implementation

Widget flexShrink(double flexShrink, [Key? key]) {
  return _WidgetWrapper._wrapOrCopyWith(
    child: this,
    key: key != null ? () => key : null,
    childType: () => FlexItem,
    flexShrink: () => flexShrink,
  );
}