getWidth method
Returns the width equivalent of the percentage
provided.
Implementation
double getWidth(double? percentage) {
final int _decPlaces = 5;
_screenWidth = _screenWidth
.floorToDouble(); // Extracts Device Screen maximum percentage.
double _rsWidth = 0;
if (_screenWidth == _fixedWidth) {
// If input percentage matches fixedWidth then do normal scaling.
_rsWidth =
_roundToDecimals((_screenWidth * (percentage! / 100)), _decPlaces);
} else {
// If input percentage !match fixedWidth then do adjustment factor scaling.
double _scaleRatioWidth =
_roundToDecimals((_screenWidth / _fixedWidth), _decPlaces);
double _scalerWidth =
((percentage! + log(percentage + 1)) * pow(1, _scaleRatioWidth)) /
100;
_rsWidth = _roundToDecimals((_screenWidth * _scalerWidth), _decPlaces);
}
return _screenWidth * percentage/100;
}