ByteComparison class

Provides comparison and relationship utilities for byte values.

Access via the compare extension property on ByteConverter:

final used = ByteConverter.fromGB(75);
final total = ByteConverter.fromGB(100);

print(used.compare.percentOf(total));      // 75.0
print(used.compare.relativeTo(total));     // "75% of"
print(used.compare.percentageBar(total));  // "███████████████░░░░░"

Constructors

ByteComparison(double _bytes)
Creates comparison utilities for the given byte value.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

clamp(ByteConverter min, ByteConverter max) ByteConverter
Clamps this value to be within min and max.
difference(ByteConverter other) ByteConverter
Returns the difference between this value and other.
equals(ByteConverter other, {double tolerance = 1e-9}) bool
Returns true if this value equals other (within floating point tolerance).
isLargerThan(ByteConverter other) bool
Returns true if this value is larger than other.
isSmallerThan(ByteConverter other) bool
Returns true if this value is smaller than other.
isWithin(ByteConverter range, {required ByteConverter of}) bool
Returns true if this value is within range of other.
max(ByteConverter other) ByteConverter
Returns the maximum of this and other.
min(ByteConverter other) ByteConverter
Returns the minimum of this and other.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
percentageBar(ByteConverter total, {int width = 20, String filled = '█', String empty = '░'}) String
Generates an ASCII progress bar showing percentage of total.
percentOf(ByteConverter total) double
Calculates what percentage this value is of total.
ratio(ByteConverter other) double
Calculates the ratio of this value to other.
relativeTo(ByteConverter other, {bool useMultiplier = true}) String
Returns a human-readable description of the relationship to other.
signedDifference(ByteConverter other) double
Returns the signed difference (this - other).
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

compressionRatio(ByteConverter original, ByteConverter compressed) String
Formats a compression ratio between original and compressed.