removeViewInsets method Null safety

MediaQueryData removeViewInsets(
  1. {bool removeLeft = false,
  2. bool removeTop = false,
  3. bool removeRight = false,
  4. bool removeBottom = false}
)

Creates a copy of this media query data but with the given viewInsets replaced with zero.

The removeLeft, removeTop, removeRight, and removeBottom arguments must not be null. If all four are false (the default) then this MediaQueryData is returned unmodified.

See also:

Implementation

MediaQueryData removeViewInsets({
  bool removeLeft = false,
  bool removeTop = false,
  bool removeRight = false,
  bool removeBottom = false,
}) {
  if (!(removeLeft || removeTop || removeRight || removeBottom)) {
    return this;
  }
  return copyWith(
    viewPadding: viewPadding.copyWith(
      left: removeLeft ? math.max(0.0, viewPadding.left - viewInsets.left) : null,
      top: removeTop ? math.max(0.0, viewPadding.top - viewInsets.top) : null,
      right: removeRight ? math.max(0.0, viewPadding.right - viewInsets.right) : null,
      bottom: removeBottom ? math.max(0.0, viewPadding.bottom - viewInsets.bottom) : null,
    ),
    viewInsets: viewInsets.copyWith(
      left: removeLeft ? 0.0 : null,
      top: removeTop ? 0.0 : null,
      right: removeRight ? 0.0 : null,
      bottom: removeBottom ? 0.0 : null,
    ),
  );
}