getSize static method
size
can be passed as number or as string
the optional parameter PrecisionValue specifies the number
of digits after comma/point (default is PrecisionValue.Two)
Example:
FileSize.getSize(1024)
FileSize.getSize(1024, precisionValue = PrecisionValue.Four)
Implementation
static String getSize(dynamic size,
{PrecisionValue precision = PrecisionValue.Two}) {
int? _size = _parseValue(size);
if (_size < _divider) return getBytes(_size);
if (_size < _getDividerValue(2)) return getKiloBytes(_size);
if (_size < _getDividerValue(3)) return getMegaBytes(_size);
if (_size < _getDividerValue(4)) return getGigaBytes(_size);
if (_size < _getDividerValue(5)) return getTeraBytes(_size);
if (_size < _getDividerValue(6)) return getPetaBytes(_size);
if (_size < _getDividerValue(7)) return getExaBytes(_size);
if (_size < _getDividerValue(8)) return getYottaBytes(_size);
if (_size < _getDividerValue(9)) return getZettaBytes(_size);
return getZettaBytes(_size);
}