rsize function
Size Responsive con variaciones por plataforma: Calcula tamaños (padding, margin, icon size) con valores específicos por dispositivo.
Ejemplos:
Icon(
Icons.star,
size: rsize(mobile: 24, tablet: 28, desktop: 32),
)
padding: EdgeInsets.all(rsize(mobile: 16, tablet: 20, desktop: 24))
Implementation
double rsize({
num? mobile,
num? tablet,
num? desktop,
num? ios,
num? android,
num? web,
}) {
final screenInfo = ScreenInfoManager().info;
final values = <DeviceType, num>{};
if (mobile != null) values[DeviceType.mobile] = mobile;
if (tablet != null) values[DeviceType.tablet] = tablet;
if (desktop != null) values[DeviceType.desktop] = desktop;
if (ios != null) values[DeviceType.ios] = ios;
if (android != null) values[DeviceType.android] = android;
if (web != null) values[DeviceType.web] = web;
if (values.isEmpty) {
throw FlutterError('rsize() requiere al menos un valor de plataforma');
}
final directValue = _getDirectValueForDevice(screenInfo, values);
return screenInfo.width * (directValue * 0.1 / 100);
}