Pad class
Pad is an EdgeInsetsGeometry which is easy to type and remember.
It can be used in all widgets that accept padding
,
like Container
, Padding
and Box
.
Instead of EdgeInsets.all(12)
,
write Pad(all: 12)
Instead of EdgeInsets.only(top: 8, bottom: 8, left: 4)
,
write Pad(top: 8, bottom: 8, left: 4)
Instead of EdgeInsets.symmetric(vertical: 12)
,
write Pad(vertical: 12)
You can also compose paddings. For example, if you want 40 pixels of
padding in all directions, but you want the top with 50 pixels,
write Pad(all: 40, top: 10)
.
- Inheritance
Constructors
- Pad.new({double all = 0, double vertical = 0, double horizontal = 0, double left = 0, double top = 0, double right = 0, double bottom = 0})
-
Creates insets with the given values:
const
- Pad.x({double? all, double? vertical, double? horizontal, double? left, double? top, double? right, double? bottom})
-
Sometimes you need to temporarily remove the padding, for debugging reasons.
Unfortunately you can't just comment the padding parameter, because the
Padding widget doesn't accept
null
padding. But you can just add.x
to the Pad class to remove it. It's marked as deprecated so that you don't forget to change it back to normal.const
Properties
- bottom → double
-
The offset from the bottom.
finalinherited
- 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.
no setterinherited
- 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.
no setterinherited
- collapsedSize → Size
-
The size that this EdgeInsets would occupy with an empty interior.
no setterinherited
- flipped → EdgeInsets
-
An EdgeInsets with top and bottom as well as left and right flipped.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- horizontal → double
-
The total offset in the horizontal direction.
no setterinherited
- isNonNegative → bool
-
Whether every dimension is non-negative.
no setterinherited
- left → double
-
The offset from the left.
finalinherited
- right → double
-
The offset from the right.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- top → double
-
The offset from the top.
finalinherited
- 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.
no setterinherited
- 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.
no setterinherited
- vertical → double
-
The total offset in the vertical direction.
no setterinherited
Methods
-
add(
EdgeInsetsGeometry other) → EdgeInsetsGeometry -
Returns the sum of two EdgeInsetsGeometry objects.
inherited
-
along(
Axis axis) → double -
The total offset in the given direction.
inherited
-
clamp(
EdgeInsetsGeometry min, EdgeInsetsGeometry max) → EdgeInsetsGeometry -
Returns a new EdgeInsetsGeometry object with all values greater than
or equal to
min
, and less than or equal tomax
.inherited -
copyWith(
{double? left, double? top, double? right, double? bottom}) → Pad -
Creates a copy of this padding but with the given fields replaced
with the new values.
override
-
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.
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
-
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.
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
-
minus(
{double? left, double? top, double? right, double? bottom, double? all = 0, double? vertical = 0, double? horizontal = 0}) → Pad - Creates a copy of this padding, minus the given parameters.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
plus(
{double? left, double? top, double? right, double? bottom, double? all = 0, double? vertical = 0, double? horizontal = 0}) → Pad - Creates a copy of this padding, plus the given parameters.
-
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).inherited -
subtract(
EdgeInsetsGeometry other) → EdgeInsetsGeometry -
Returns the difference between two EdgeInsetsGeometry objects.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator %(
double other) → EdgeInsets -
Computes the remainder in each dimension by the given factor.
inherited
-
operator *(
double other) → EdgeInsets -
Scales the EdgeInsets in each dimension by the given factor.
inherited
-
operator +(
EdgeInsets other) → EdgeInsets -
Returns the sum of two EdgeInsets.
inherited
-
operator -(
EdgeInsets other) → EdgeInsets -
Returns the difference between two EdgeInsets.
inherited
-
operator /(
double other) → EdgeInsets -
Divides the EdgeInsets in each dimension by the given factor.
inherited
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator unary-(
) → EdgeInsets -
Returns the EdgeInsets object with each dimension negated.
inherited
-
operator ~/(
double other) → EdgeInsets -
Integer divides the EdgeInsets in each dimension by the given factor.
inherited