dynamicPadding method

Widget dynamicPadding({
  1. double? all,
  2. double? horizontal,
  3. double? vertical,
  4. double? top,
  5. double? bottom,
  6. double? left,
  7. double? right,
  8. BuildContext? context,
})

Implementation

Widget dynamicPadding({
  double? all,
  double? horizontal,
  double? vertical,
  double? top,
  double? bottom,
  double? left,
  double? right,
  BuildContext? context,
}) {
  double width = 0;
  double height = 0;

  if (context != null) {
    width = MediaQuery.of(context).size.width;
    height = MediaQuery.of(context).size.height;
  }

  return Padding(
    padding: EdgeInsets.only(
      top: top != null
          ? height * top
          : (vertical != null
                ? height * vertical
                : (all != null ? height * all : 0)),
      bottom: bottom != null
          ? height * bottom
          : (vertical != null
                ? height * vertical
                : (all != null ? height * all : 0)),
      left: left != null
          ? width * left
          : (horizontal != null
                ? width * horizontal
                : (all != null ? width * all : 0)),
      right: right != null
          ? width * right
          : (horizontal != null
                ? width * horizontal
                : (all != null ? width * all : 0)),
    ),
    child: this,
  );
}