removePadding method
Creates a copy of this media query data but with the given paddings replaced with zero.
If all four of the removeLeft
, removeTop
, removeRight
, and
removeBottom
arguments are false (the default), then this
MediaQueryData is returned unmodified.
See also:
- MediaQuery.removePadding, which uses this method to remove padding from the ambient MediaQuery.
- SafeArea, which both removes the padding from the MediaQuery and adds a Padding widget.
- removeViewInsets, the same thing but for viewInsets.
- removeViewPadding, the same thing but for viewPadding.
Implementation
MediaQueryData removePadding({
bool removeLeft = false,
bool removeTop = false,
bool removeRight = false,
bool removeBottom = false,
}) {
if (!(removeLeft || removeTop || removeRight || removeBottom)) {
return this;
}
return copyWith(
padding: padding.copyWith(
left: removeLeft ? 0.0 : null,
top: removeTop ? 0.0 : null,
right: removeRight ? 0.0 : null,
bottom: removeBottom ? 0.0 : null,
),
viewPadding: viewPadding.copyWith(
left: removeLeft ? math.max(0.0, viewPadding.left - padding.left) : null,
top: removeTop ? math.max(0.0, viewPadding.top - padding.top) : null,
right: removeRight ? math.max(0.0, viewPadding.right - padding.right) : null,
bottom: removeBottom ? math.max(0.0, viewPadding.bottom - padding.bottom) : null,
),
);
}