responsiveCorners static method

BorderRadius responsiveCorners(
  1. BuildContext context,
  2. double radiusPercent, {
  3. bool topLeft = true,
  4. bool topRight = true,
  5. bool bottomLeft = true,
  6. bool bottomRight = true,
  7. double minRadius = 4.0,
  8. double maxRadius = 100.0,
})

Creates a responsive border radius for specific corners that adapts to the screen size.

context The build context to get the screen size from. radiusPercent The radius as a percentage of the screen width (0.0 to 1.0). corners Which corners to apply the radius to (default: all corners). minRadius The minimum radius value to use (default: 4.0). maxRadius The maximum radius value to use (default: 100.0). Returns a BorderRadius object with the responsive radius for the specified corners.

Implementation

static BorderRadius responsiveCorners(
  BuildContext context,
  double radiusPercent, {
  bool topLeft = true,
  bool topRight = true,
  bool bottomLeft = true,
  bool bottomRight = true,
  double minRadius = 4.0,
  double maxRadius = 100.0,
}) {
  assert(radiusPercent >= 0.0 && radiusPercent <= 1.0,
      'radiusPercent must be between 0.0 and 1.0');

  final screenWidth = MediaQuery.of(context).size.width;
  final calculatedRadius = screenWidth * radiusPercent;
  final clampedRadius = calculatedRadius.clamp(minRadius, maxRadius);

  return only(
    topLeft: topLeft ? clampedRadius : 0.0,
    topRight: topRight ? clampedRadius : 0.0,
    bottomLeft: bottomLeft ? clampedRadius : 0.0,
    bottomRight: bottomRight ? clampedRadius : 0.0,
  );
}