DataRate class

Represents a network/data rate. Internally stored as bits per second.

Provides human-readable formatting (including time base selection), parsing from common strings, and convenience constructors for SI/IEC units.

Implemented types
Available extensions

Constructors

DataRate.bitsPerSecond(double _bitsPerSecond)
Constructs a rate in bits per second.
const
DataRate.bytesPerSecond(double bytesPerSecond)
Constructs a rate given bytesPerSecond.
factory
DataRate.gibiBitsPerSecond(double value)
IEC: gibibits per second.
factory
DataRate.gibiBytesPerSecond(double value)
IEC: gibibytes per second.
factory
DataRate.gigaBitsPerSecond(double value)
SI: gigabits per second.
factory
DataRate.gigaBytesPerSecond(double value)
SI: gigabytes per second.
factory
DataRate.kibiBitsPerSecond(double value)
IEC: kibibits per second.
factory
DataRate.kibiBytesPerSecond(double value)
IEC: kibibytes per second.
factory
DataRate.kiloBitsPerSecond(double value)
SI: kilobits per second.
factory
DataRate.kiloBytesPerSecond(double value)
SI: kilobytes per second.
factory
DataRate.mebiBitsPerSecond(double value)
IEC: mebibits per second.
factory
DataRate.mebiBytesPerSecond(double value)
IEC: mebibytes per second.
factory
DataRate.megaBitsPerSecond(double value)
SI: megabits per second.
factory
DataRate.megaBytesPerSecond(double value)
SI: megabytes per second.
factory

Properties

bitsPerSecond → double
Bits per second.
no setter
bytesPerSecond → double
Bytes per second.
no setter
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

compareTo(DataRate other) → int
Compares this object to another object.
override
formatWith(String pattern, {ByteFormatOptions options = const ByteFormatOptions(), String per = 's'}) → String
Formats the rate using a custom pattern.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toFullWords({ByteFormatOptions options = const ByteFormatOptions(), String per = 's'}) → String
Formats the rate as full words (e.g., "12 megabytes per second"). per controls the time unit denominator ('s', 'ms', 'min', 'h').
toHumanReadableAuto({ByteStandard standard = ByteStandard.si, bool useBytes = false, int precision = 2, bool showSpace = true, bool nonBreakingSpace = false, bool fullForm = false, Map<String, String>? fullForms, String? separator, String? spacer, int? minimumFractionDigits, int? maximumFractionDigits, bool truncate = false, bool signed = false, String? forceUnit, String? locale, bool useGrouping = true, SiKSymbolCase siKSymbolCase = SiKSymbolCase.upperK, int? fixedWidth, bool includeSignInWidth = false, String per = 's'}) → String
Formats this data rate using humanized units.
toHumanReadableAutoWith(ByteFormatOptions options) → String
Convenience overload using ByteFormatOptions.
toHumanReadableCompound({CompoundFormatOptions options = const CompoundFormatOptions(), String per = 's'}) → String
Compound mixed-unit formatting for data rates. Appends '/s'.
toString() → String
A string representation of this object.
override
transferableBytes(Duration window) → ByteConverter

Available on DataRate, provided by the DataRatePlanning extension

Returns the maximum transferable bytes in the given window at this rate.
transferTimeForBytes(double bytes) → Duration
Duration to transfer bytes at this data rate.

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

parse(String input, {ByteStandard standard = ByteStandard.si}) → DataRate
Parses a string like "100 Mb/s", "12.5 MB/s", or "2 kibps" to a DataRate.
tryParse(String input, {ByteStandard standard = ByteStandard.si}) → ParseResult<DataRate>
Safe parsing variant that returns diagnostics instead of throwing.