withPadding method
Wraps this widget in a Padding with the given values.
If all is provided, it overrides other parameters.
Example:
myWidget.withPadding(all: 16);
myWidget.withPadding(horizontal: 8, vertical: 16);
myWidget.withPadding(top: 10, bottom: 20);
Implementation
Widget withPadding({
double? all,
double? horizontal,
double? vertical,
double? top,
double? bottom,
double? left,
double? right,
}) {
if (all != null) {
return Padding(padding: EdgeInsets.all(all), child: this);
}
return Padding(
padding: EdgeInsets.only(
top: vertical ?? top ?? 0,
bottom: vertical ?? bottom ?? 0,
left: horizontal ?? left ?? 0,
right: horizontal ?? right ?? 0,
),
child: this,
);
}