withPadding method

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

Implementation

Widget withPadding(
    {double? top,
    double? bottom,
    double? left,
    double? right,
    double? horizontal,
    double? vertical,
    double? all,
    EdgeInsetsGeometry? padding}) {
  assert(() {
    if (all != null) {
      if (top != null ||
          bottom != null ||
          left != null ||
          right != null ||
          horizontal != null ||
          vertical != null) {
        throw FlutterError(
            'All padding properties cannot be used with other padding properties.');
      }
    } else if (horizontal != null) {
      if (left != null || right != null) {
        throw FlutterError(
            'Horizontal padding cannot be used with left or right padding.');
      }
    } else if (vertical != null) {
      if (top != null || bottom != null) {
        throw FlutterError(
            'Vertical padding cannot be used with top or bottom padding.');
      }
    }
    return true;
  }());
  var edgeInsets = EdgeInsets.only(
    top: top ?? vertical ?? all ?? 0,
    bottom: bottom ?? vertical ?? all ?? 0,
    left: left ?? horizontal ?? all ?? 0,
    right: right ?? horizontal ?? all ?? 0,
  );
  return Padding(
    padding: padding ?? edgeInsets,
    child: this,
  );
}