flex method
Wraps the widget in a Flexible with the specified flex value and fit.
Creates a Flexible widget that allows the child to occupy available space along the main axis of its parent Row, Column, or Flex. The flex value determines the proportion of space this widget can occupy relative to other Flexible or Expanded widgets in the same parent.
Parameters:
flex: The flex factor to use. Higher values can take more space. Defaults to 1. Must be >= 0.fit: How the child should fit within the allocated space.- FlexFit.loose: Child can be smaller than allocated space (default)
- FlexFit.tight: Child must fill allocated space
Returns a Flexible widget containing this widget as its child.
Example:
Column(
children: [
Text('Loose fit').flex(flex: 1, fit: FlexFit.loose),
Text('Tight fit').flex(flex: 2, fit: FlexFit.tight),
],
);
Implementation
Flexible flex({
int flex = 1,
FlexFit fit = FlexFit.loose,
}) =>
Flexible(
flex: flex,
fit: fit,
child: this,
);