spaced method
Adds the same ammount of padding to a list of Widgets This can be usefull if you need to have some of the widgets of a list spaced, and some don't
Example:
[
const Text('BASF'),
const Text('MOBILE SOLUTIONS'),
].spaced();
// or
].spaced(padding: const EdgeInsets.all(10));
Implementation
List<Widget> spaced({EdgeInsetsGeometry? padding, bool excludeFlex = true}) {
final spacedWidgets = <Widget>[];
for (final w in this) {
if (excludeFlex && (w is Expanded || w is Spacer || w is Flexible)) {
spacedWidgets.add(w);
} else {
spacedWidgets.add(
Padding(
padding: padding ??
const EdgeInsets.fromLTRB(
Dimens.paddingMediumLarge,
0,
Dimens.paddingMediumLarge,
0,
),
child: w,
),
);
}
}
return spacedWidgets;
}