human_file_size library

A robust, customisable package to get a human representation of the size of your files.

Classes

BestFitUnitConversion
The size is converted to the largest possible unit that most accurately describes its magnitude, subject to the NumeralSystem used. The conversion works identically for negative values.
BinaryNumeralSystem
The binary numeral system with the factor between sequential magnitudes being 1024 or 2^10. Commonly used in Linux systems.
CustomQuantityDisplayMode
The quantity passes through a custom converter to get its display format.
DecimalNumeralSystem
The decimal numeral system with the factor between sequential magnitudes being 1000 or 10^3. This is the common system used to represent sizes of data for regular users.
IntlQuantityDisplayMode
The quantity is displayed using basic calls to Decimal.toString and Decimal.toStringAsFixed.
LongLowercaseUnitStyle
The unit will be displayed in its long form with the prefix in lowercase.
LongUppercaseUnitStyle
The unit will be displayed in its long form with the prefix in lowercase.
NumeralSystem
Represents the numeral system of units.
OutputFormatter
Defines how to format the output.
QuantityDisplayMode
Defines how the final quantity should be displayed, where the quantity is the amount of a given unit.
ShortLowercaseUnitStyle
The unit will be displayed concisely with the prefix in lowercase.
ShortUppercaseUnitStyle
The unit will be displayed concisely with the prefix in uppercase.
SimpleOutputFormatter
The quantity and unit are formatted as '${quantity} ${unit}'.
SimpleQuantityDisplayMode
The quantity is displayed using basic calls to Decimal.toString and Decimal.toStringAsFixed.
SpecificUnitConversion
data.
Unit
Represents a unit used for describing the size of digital information.
UnitConversion
Defines which unit the file size should be converted into before displaying.
UnitStyle
Represents the display style of a unit.
UnitSymbols
Stores the symbols used to represent a given unit.

Extensions

NumHumanFileSize on num
Adds a method humanFileSize to nums.

Constants

defaultOutputFormatter → const SimpleOutputFormatter
The default number format is SimpleOutputFormatter.
defaultQuantityDisplayMode → const SimpleQuantityDisplayMode
The default quantity display mode is SimpleQuantityDisplayMode.
defaultUnitConversion → const BestFitUnitConversion
The default unit conversion is BestFitUnitConversion with the DecimalNumeralSystem.
defaultUnitStyle → const ShortUppercaseUnitStyle
The default unit style is ShortUppercaseUnitStyle.
fileSizeToString → const String Function(num quantity, {Unit? inputUnit, OutputFormatter outputFormatter = defaultOutputFormatter, QuantityDisplayMode quantityDisplayMode = defaultQuantityDisplayMode, UnitConversion unitConversion = defaultUnitConversion, UnitStyle unitStyle = defaultUnitStyle})
Alias of humanFileSize.

Properties

defaultNumberFormat → NumberFormat
The default number format is NumberFormat.decimalPattern.
final
defaultUnit Unit
The default unit is Unit.byte.
final

Functions

humanFileSize(num quantity, {Unit? inputUnit, UnitConversion unitConversion = defaultUnitConversion, QuantityDisplayMode quantityDisplayMode = defaultQuantityDisplayMode, UnitStyle unitStyle = defaultUnitStyle, OutputFormatter outputFormatter = defaultOutputFormatter}) String
Given a quantity, formats the quantity as a human-readable string.