responsiveCorners static method
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,
);
}