flexGrow method

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

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

The flex grow factor determines how much of the remaining space in the flex container should be assigned to this widget. A value of 1 means the widget will take its proportional share of extra space.

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

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

Example:

Container().flexGrow(1),  // Takes 1 part of remaining space
Container().flexGrow(2),  // Takes 2 parts of remaining space

Implementation

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