FlexibleWidgetExtension extension

Extension methods for Widget that provide convenient flexible layout functionality.

This extension adds methods to easily wrap widgets in Flexible widgets for flexible layout control within Row, Column, and Flex widgets. All methods return new Flexible widgets without modifying the original widget.

The extension provides both flexible control (flex) and convenient shortcuts for common flex values (flex2, flex3, etc.) with different FlexFit options.

Unlike Expanded, Flexible widgets can occupy less than the available space if their child doesn't need it all, depending on the FlexFit setting:

Example usage:

Row(
  children: [
    Text('Flexible').flex(),           // Takes needed space, up to 1 part
    Text('Tight').flexTight(2),        // Forces 2 parts of space
    Text('Loose').flexLoose(1),        // Up to 1 part, but can be smaller
  ],
);
on

Methods

flex({int flex = 1, FlexFit fit = FlexFit.loose}) Flexible

Available on Widget, provided by the FlexibleWidgetExtension extension

Wraps the widget in a Flexible with the specified flex value and fit.
flex2([FlexFit fit = FlexFit.loose]) Flexible

Available on Widget, provided by the FlexibleWidgetExtension extension

Wraps the widget in a Flexible with flex value 2.
flex3([FlexFit fit = FlexFit.loose]) Flexible

Available on Widget, provided by the FlexibleWidgetExtension extension

Wraps the widget in a Flexible with flex value 3.
flex4([FlexFit fit = FlexFit.loose]) Flexible

Available on Widget, provided by the FlexibleWidgetExtension extension

Wraps the widget in a Flexible with flex value 4.
flex5([FlexFit fit = FlexFit.loose]) Flexible

Available on Widget, provided by the FlexibleWidgetExtension extension

Wraps the widget in a Flexible with flex value 5.
flex6([FlexFit fit = FlexFit.loose]) Flexible

Available on Widget, provided by the FlexibleWidgetExtension extension

Wraps the widget in a Flexible with flex value 6.
flex7([FlexFit fit = FlexFit.loose]) Flexible

Available on Widget, provided by the FlexibleWidgetExtension extension

Wraps the widget in a Flexible with flex value 7.
flex8([FlexFit fit = FlexFit.loose]) Flexible

Available on Widget, provided by the FlexibleWidgetExtension extension

Wraps the widget in a Flexible with flex value 8.
flexLoose(int flex) Flexible

Available on Widget, provided by the FlexibleWidgetExtension extension

Wraps the widget in a Flexible with loose fit.
flexTight(int flex) Flexible

Available on Widget, provided by the FlexibleWidgetExtension extension

Wraps the widget in a Flexible with tight fit.