MarginWidgetExtension extension
Extension methods for Widget that provide convenient margin functionality.
This extension adds methods to easily apply margins to any widget using various margin configurations. All methods return new Container widgets with the specified margins without modifying the original widget.
The extension provides both granular control (marginOnly) and convenient shortcuts (marginAll, marginHorizontal, etc.) for common margin patterns.
Note: Unlike padding, margins are applied using Container widgets, which means they create a new container around the widget with the specified margin.
Example usage:
Text('Hello World')
.marginAll(16.0)
.marginHorizontal(8.0); // Adds 16px margin all around, then 8px more horizontally
- on
Methods
-
margin(
EdgeInsets margin) → Container -
Available on Widget, provided by the MarginWidgetExtension extension
Applies the specified EdgeInsets margin to the widget. -
marginAll(
double margin) → Container -
Available on Widget, provided by the MarginWidgetExtension extension
Applies uniform margin to all sides of the widget. -
marginBottom(
double bottom) → Container -
Available on Widget, provided by the MarginWidgetExtension extension
Applies margin to the bottom side only. -
marginHorizontal(
double horizontal) → Container -
Available on Widget, provided by the MarginWidgetExtension extension
Applies margin to the left and right sides only. -
marginLeft(
double left) → Container -
Available on Widget, provided by the MarginWidgetExtension extension
Applies margin to the left side only. -
marginOnly(
{double? top, double? left, double? right, double? bottom}) → Container -
Available on Widget, provided by the MarginWidgetExtension extension
Applies specific margin to individual sides of the widget. -
marginRight(
double right) → Container -
Available on Widget, provided by the MarginWidgetExtension extension
Applies margin to the right side only. -
marginSymmetric(
{double horizontal = 0, double vertical = 0}) → Container -
Available on Widget, provided by the MarginWidgetExtension extension
Applies symmetric margin to horizontal and vertical axes. -
marginTop(
double top) → Container -
Available on Widget, provided by the MarginWidgetExtension extension
Applies margin to the top side only. -
marginVertical(
double vertical) → Container -
Available on Widget, provided by the MarginWidgetExtension extension
Applies margin to the top and bottom sides only.