margin method

Widget margin({
  1. double? all,
  2. double? top,
  3. double? bottom,
  4. double? leading,
  5. double? trailing,
  6. double? horizontal,
  7. double? vertical,
  8. bool handover = true,
})

A modifier that insets margin around its widget by the given value(s).

Example:

This snippet creates "Hello World!" Text inside a Card that has margin around it by sixteen pixels in each direction.

Card(child:
  Text('Hello World!')
      .padding(all: 16),
)

Implementation

Widget margin({
  double? all,
  double? top,
  double? bottom,
  double? leading,
  double? trailing,
  double? horizontal,
  double? vertical,
  bool handover = true,
}) {
  final insets = _insets(
    all: all,
    top: top,
    bottom: bottom,
    leading: leading,
    trailing: trailing,
    horizontal: horizontal,
    vertical: vertical,
  );
  if (handover && this is Container) {
    return (this as Container)._rebase(margin: insets);
  }
  return Container(child: this, margin: insets);
}