withResponsiveSpacing method
Row
withResponsiveSpacing({
- required BuildContext context,
- double smallSpacing = 8.0,
- double mediumSpacing = 16.0,
- double largeSpacing = 24.0,
Adds responsive spacing between children
Implementation
Row withResponsiveSpacing({
required BuildContext context,
double smallSpacing = 8.0,
double mediumSpacing = 16.0,
double largeSpacing = 24.0,
}) {
double spacing;
double screenWidth = MediaQuery.of(context).size.width;
if (screenWidth < 600) {
spacing = smallSpacing;
} else if (screenWidth < 1200) {
spacing = mediumSpacing;
} else {
spacing = largeSpacing;
}
return Row(
children: [
for (int i = 0; i < children.length; i++)
i == children.length - 1
? children[i]
: Padding(
padding: EdgeInsets.only(right: spacing),
child: children[i],
),
],
);
}