responsiveWidth static method
double
responsiveWidth(
- BuildContext context, {
- double mobileRatio = 1.0,
- double tabletRatio = 0.8,
- double desktopRatio = 0.6,
- double? maxWidth,
Implementation
static double responsiveWidth(
BuildContext context, {
double mobileRatio = 1.0,
double tabletRatio = 0.8,
double desktopRatio = 0.6,
double? maxWidth,
}) {
final screenWidth = MediaQuery.of(context).size.width;
double width;
if (isDesktop(context)) {
width = screenWidth * desktopRatio;
} else if (isTablet(context)) {
width = screenWidth * tabletRatio;
} else {
width = screenWidth * mobileRatio;
}
if (maxWidth != null && width > maxWidth) {
width = maxWidth;
}
return width;
}