EdgeInsets class
An immutable set of offsets in each of the four cardinal directions.
Typically used for an offset from each of the four sides of a box. For example, the padding inside a box can be represented using this class.
The EdgeInsets class specifies offsets in terms of visual edges, left, top, right, and bottom. These values are not affected by the TextDirection. To support both left-to-right and right-to-left layouts, consider using EdgeInsetsDirectional, which is expressed in terms of start, top, end, and bottom, where start and end are resolved in terms of a TextDirection (typically obtained from the ambient Directionality).
Here are some examples of how to create EdgeInsets instances:
Typical eight-pixel margin on all sides:
const EdgeInsets.all(8.0)
Eight pixel margin above and below, no horizontal margins:
const EdgeInsets.symmetric(vertical: 8.0)
Left margin indent of 40 pixels:
const EdgeInsets.only(left: 40.0)
See also:
- Padding, a widget that accepts EdgeInsets to describe its margins.
- EdgeInsetsDirectional, which (for properties and arguments that accept the type EdgeInsetsGeometry) allows the horizontal insets to be specified in a TextDirection-aware manner.
- Inheritance
- Object
- EdgeInsetsGeometry
- EdgeInsets
Constructors
- EdgeInsets.all(double value)
-
Creates insets where all the offsets are
value
. [...]const - EdgeInsets.fromLTRB(double left, double top, double right, double bottom)
-
Creates insets from offsets from the left, top, right, and bottom.
const
- EdgeInsets.fromWindowPadding(WindowPadding padding, double devicePixelRatio)
- Creates insets that match the given window padding. [...]
- EdgeInsets.only({double left: 0.0, double top: 0.0, double right: 0.0, double bottom: 0.0 })
-
Creates insets with only the given values non-zero. [...]
const
- EdgeInsets.symmetric({double vertical: 0.0, double horizontal: 0.0 })
-
Creates insets with symmetrical vertical and horizontal offsets. [...]
const
Properties
- bottom → double
-
The offset from the bottom.
final
- bottomLeft → Offset
-
An Offset describing the vector from the bottom left of a rectangle to the
bottom left of that rectangle inset by this object.
read-only
- bottomRight → Offset
-
An Offset describing the vector from the bottom right of a rectangle to the
bottom right of that rectangle inset by this object.
read-only
- flipped → EdgeInsets
-
An EdgeInsets with top and bottom as well as left and right flipped.
read-only, override
- left → double
-
The offset from the left.
final
- right → double
-
The offset from the right.
final
- top → double
-
The offset from the top.
final
- topLeft → Offset
-
An Offset describing the vector from the top left of a rectangle to the
top left of that rectangle inset by this object.
read-only
- topRight → Offset
-
An Offset describing the vector from the top right of a rectangle to the
top right of that rectangle inset by this object.
read-only
- collapsedSize → Size
-
The size that this EdgeInsets would occupy with an empty interior.
read-only, inherited
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- horizontal → double
-
The total offset in the horizontal direction.
read-only, inherited
- isNonNegative → bool
-
Whether every dimension is non-negative.
read-only, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
- vertical → double
-
The total offset in the vertical direction.
read-only, inherited
Methods
-
add(
EdgeInsetsGeometry other) → EdgeInsetsGeometry -
Returns the sum of two EdgeInsetsGeometry objects. [...]
override
-
copyWith(
{double left, double top, double right, double bottom }) → EdgeInsets - Creates a copy of this EdgeInsets but with the given fields replaced with the new values.
-
deflateRect(
Rect rect) → Rect - Returns a new rect that is smaller than the given rect in each direction by the amount of inset in each direction. Specifically, the left edge of the rect is moved right by left, the top edge of the rect is moved down by top, the right edge of the rect is moved left by right, and the bottom edge of the rect is moved up by bottom. [...]
-
inflateRect(
Rect rect) → Rect - Returns a new rect that is bigger than the given rect in each direction by the amount of inset in each direction. Specifically, the left edge of the rect is moved left by left, the top edge of the rect is moved up by top, the right edge of the rect is moved right by right, and the bottom edge of the rect is moved down by bottom. [...]
-
resolve(
TextDirection direction) → EdgeInsets -
Convert this instance into an EdgeInsets, which uses literal coordinates
(i.e. the
left
coordinate being explicitly a distance from the left, and theright
coordinate being explicitly a distance from the right). [...]override -
subtract(
EdgeInsetsGeometry other) → EdgeInsetsGeometry -
Returns the difference between two EdgeInsetsGeometry objects. [...]
override
-
along(
Axis axis) → double -
The total offset in the given direction.
inherited
-
deflateSize(
Size size) → Size -
Returns a new size that is smaller than the given size by the amount of
inset in the horizontal and vertical directions. [...]
inherited
-
inflateSize(
Size size) → Size -
Returns a new size that is bigger than the given size by the amount of
inset in the horizontal and vertical directions. [...]
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
toString(
) → String -
Returns a string representation of this object.
inherited
Operators
-
operator %(
double other) → EdgeInsets -
Computes the remainder in each dimension by the given factor.
override
-
operator *(
double other) → EdgeInsets -
Scales the EdgeInsets in each dimension by the given factor.
override
-
operator +(
EdgeInsets other) → EdgeInsets - Returns the sum of two EdgeInsets.
-
operator -(
EdgeInsets other) → EdgeInsets - Returns the difference between two EdgeInsets.
-
operator /(
double other) → EdgeInsets -
Divides the EdgeInsets in each dimension by the given factor.
override
-
operator unary-(
) → EdgeInsets -
Returns the EdgeInsets object with each dimension negated. [...]
override
-
operator ~/(
double other) → EdgeInsets -
Integer divides the EdgeInsets in each dimension by the given factor.
override
-
operator ==(
dynamic other) → bool -
The equality operator. [...]
inherited
Static Methods
-
lerp(
EdgeInsets a, EdgeInsets b, double t) → EdgeInsets -
Linearly interpolate between two EdgeInsets. [...]
override
Constants
- zero → const EdgeInsets
-
An EdgeInsets with zero offsets in each direction.
const EdgeInsets.only()