1import 'package:flutter/material.dart';
2
3extension WidgetExtension on Widget {
4 Widget withPadding({
5 double all = 0,
6 double left = 0,
7 double top = 0,
8 double right = 0,
9 double bottom = 0,
10 double horizontal = 0,
11 double vertical = 0,
12 }) =>
13 switch ((all, left, top, right, bottom, horizontal, vertical)) {
14 (> 0, _, _, _, _, _, _) => Padding(
15 padding: EdgeInsets.all(all),
16 child: this,
17 ),
18 (0, 0, 0, 0, 0, >= 0, >= 0) => Padding(
19 padding: EdgeInsets.symmetric(
20 horizontal: horizontal,
21 vertical: vertical,
22 ),
23 child: this,
24 ),
25 _ => Padding(
26 padding: EdgeInsets.only(
27 left: left,
28 top: top,
29 right: right,
30 bottom: bottom,
31 ),
32 child: this,
33 ),
34 };
35}