Margin class

A class representing margins around a chart area.

Margin encapsulates spacing values for all four sides, commonly used for chart padding and margins.

Constructors

Margin({double top = 0, double right = 0, double bottom = 0, double left = 0})
Creates a Margin with individual values for each side.
const
Margin.all(double value)
Creates a Margin with the same value on all sides.
const
Margin.fromEdgeInsets(EdgeInsets insets)
Creates a Margin from EdgeInsets.
factory
Margin.only({double top = 0, double right = 0, double bottom = 0, double left = 0})
Creates a Margin with only the specified sides.
const
Margin.symmetric({double vertical = 0, double horizontal = 0})
Creates a Margin with symmetric horizontal and vertical values.
const

Properties

bottom → double
The bottom margin.
final
hashCode → int
The hash code for this object.
no setteroverride
horizontal → double
The horizontal margin (left + right).
no setter
isZero → bool
Whether all margins are zero.
no setter
left → double
The left margin.
final
offset → Offset
Returns the offset for positioning content within the margin.
no setter
The right margin.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
top → double
The top margin.
final
totalHeight → double
The total height consumed by margins.
no setter
totalWidth → double
The total width consumed by margins.
no setter
vertical → double
The vertical margin (top + bottom).
no setter

Methods

applyToBounds(Bounds outer) → Bounds
Applies this margin to Bounds, returning the inner bounds.
applyToSize(Size outer) → Size
Applies this margin to a Size, returning the inner size.
copyWith({double? top, double? right, double? bottom, double? left}) → Margin
Creates a copy with updated values.
expandBounds(Bounds inner) → Bounds
Expands Bounds by this margin.
expandSize(Size inner) → Size
Expands a Size by this margin.
lerp(Margin other, double t) → Margin
Interpolates between this margin and another.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toEdgeInsets() → EdgeInsets
Converts to EdgeInsets.
toString() → String
A string representation of this object.
override

Operators

operator *(double scalar) → Margin
Multiplies this margin by a scalar.
operator +(Margin other) → Margin
Adds another margin to this one.
operator -(Margin other) → Margin
Subtracts another margin from this one.
operator /(double scalar) → Margin
Divides this margin by a scalar.
operator ==(Object other) → bool
The equality operator.
override

Constants

defaultChart → const Margin
Default chart margin.
zero → const Margin
Zero margin.