withResponsivePadding method

Row withResponsivePadding({
  1. required BuildContext context,
  2. double smallPadding = 8.0,
  3. double mediumPadding = 16.0,
  4. double largePadding = 24.0,
})

Adds responsive padding to the Row based on screen size

Implementation

Row withResponsivePadding({
  required BuildContext context,
  double smallPadding = 8.0,
  double mediumPadding = 16.0,
  double largePadding = 24.0,
}) {
  double padding;
  double screenWidth = MediaQuery.of(context).size.width;

  if (screenWidth < 600) {
    padding = smallPadding;
  } else if (screenWidth < 1200) {
    padding = mediumPadding;
  } else {
    padding = largePadding;
  }

  return Row(
    children: [Padding(padding: EdgeInsets.all(padding), child: this)],
  );
}