Margin class

Represents margin (external spacing) for styled content.

Margin adds space outside the border of the content.

// Uniform margin
final m1 = Margin.all(2);

// Vertical and horizontal
final m2 = Margin.symmetric(vertical: 1, horizontal: 2);

// Per-side
final m3 = Margin.only(top: 1, left: 2);

Constructors

Margin({int top = 0, int right = 0, int bottom = 0, int left = 0})
Creates margin with explicit values for each side.
const
Margin.all(int value)
Creates uniform margin on all sides.
const
Margin.only({int top = 0, int right = 0, int bottom = 0, int left = 0})
Creates margin with only the specified sides.
const
Margin.symmetric({int vertical = 0, int horizontal = 0})
Creates symmetric margin.
const

Properties

bottom → int
Margin on the bottom side.
final
hashCode → int
The hash code for this object.
no setteroverride
horizontal → int
Total horizontal margin (left + right).
no setter
isZero → bool
Whether all margin values are zero.
no setter
left → int
Margin on the left side.
final
Margin on the right side.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
top → int
Margin on the top side.
final
vertical → int
Total vertical margin (top + bottom).
no setter

Methods

copyWith({int? top, int? right, int? bottom, int? left}) → Margin
Creates a copy with the specified values replaced.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
override

Operators

operator ==(Object other) → bool
The equality operator.
override

Constants

zero → const Margin
No margin.