Padding constructor

const Padding({
  1. required Widget child,
  2. double? all,
  3. double? width,
  4. double? height,
  5. double? left,
  6. double? right,
  7. double? top,
  8. double? bottom,
  9. Key? key,
})

Creates a SimplePadding.

Parameters work as a tree-like structure, where all is the root node, width and height are children of all, left and right are children of width and top and bottom are children of height.

To get the padding of a parameter, its value will be checked. If it's not null, its value is returned, otherwise the padding of its parent will be returned. If this parameter has no parent, its padding will be zero. Using left as example:

double padding;
if (left == null) {
  // width is left's parent
  if (width == null) {
    // all is width's parent
    padding = all ?? 0;
  } else {
    padding = width;
  }
} else {
  padding = left;
}
left = padding;

Implementation

const Padding({
  required this.child,
  this.all,
  this.width,
  this.height,
  this.left,
  this.right,
  this.top,
  this.bottom,
  f.Key? key,
}) : super(key: key);