margin method
Applies margin to all sides or specific directions.
all Margin for all sides.
vertical Vertical margin (top and bottom).
horizontal Horizontal margin (left and right).
Implementation
Container margin(
{double all = 0.0, double vertical = 0.0, double horizontal = 0.0}) {
if (all != 0.0) {
return Container(
margin: EdgeInsets.all(all),
child: this,
);
} else if (vertical != 0.0 || horizontal != 0.0) {
return Container(
margin:
EdgeInsets.symmetric(vertical: vertical, horizontal: horizontal),
child: this,
);
}
return Container(
margin: EdgeInsets.zero,
child: this,
);
}