get method
Implementation
double? get({
required final BuildContext context,
required final bool isWidth,
}) {
String? sizeValue;
if (context.deviceType == frame.DeviceType.phone) {
sizeValue = size;
} else if (context.deviceType == frame.DeviceType.tablet) {
sizeValue = sizeTablet?.isNotEmpty ?? false ? sizeTablet ?? size : size;
} else {
sizeValue = sizeDesktop?.isNotEmpty ?? false ? sizeDesktop ?? size : size;
}
if (size.isEmpty) return null;
if (sizeValue.toLowerCase() == 'max' ||
sizeValue.toLowerCase() == 'inf' ||
sizeValue.toLowerCase() == '100%') {
return double.maxFinite;
} else if (sizeValue.toLowerCase() == 'null' ||
sizeValue.toLowerCase() == 'auto') {
return null;
}
final temp = sizeValue.replaceAll('%', '');
final value = double.tryParse(temp);
if (value == null) {
return null;
}
if (sizeValue.contains('%')) {
if (isWidth) {
final side = context.deviceInfo.screenSize.width;
return side * (value / 100);
} else {
final side = context.deviceInfo.screenSize.height;
return side * (value / 100);
}
}
return value;
}