width static method
return a reasonable width value
.
if maxWidth
is null then the value
will be at most designedWidth
logical pixel otherwise, the value
will be at most maxWidth
logical pixels.
value
can be any double between zero and maximum width.
Implementation
static double width(
double designedWidth, {
double? maxWidth,
}) {
final orientation = _orientation;
if (orientation == Orientation.portrait) {
final _width = _screenWidth * designedWidth / _designedDeviceWidth;
if (maxWidth == null) {
if (_width <= designedWidth) {
return _width;
} else {
return designedWidth;
}
} else {
return _comparator(
value: designedWidth,
maxValue: maxWidth,
);
}
} else {
final _width = _screenWidth * designedWidth / _designedDeviceHeight;
if (maxWidth == null) {
if (_width <= designedWidth) {
return _width;
} else {
return designedWidth;
}
} else {
return _comparator(
value: designedWidth,
maxValue: maxWidth,
);
}
}
}