byte_converter 3.0.0
byte_converter: ^3.0.0 copied to clipboard
High-performance byte and data-rate conversions with BigInt precision, expression parsing, transfer planning, storage profiles, and localization-ready formatting.
๐ข ByteConverter #
A fast, comprehensive byte & data-rate conversion library for Dart
๐ Documentation ยท ๐ Report Bug ยท ๐ก Request Feature
โจ Features #
| Feature | Description | |
|---|---|---|
| ๐ | Multi-Standard | SI (KB, MB, GB), IEC (KiB, MiB, GiB), and JEDEC support |
| ๐ | Smart Parsing | Parse any format: "1.5 GB", "2 GiB + 512 MiB", "1,234 bytes" |
| ๐ข | BigInt Support | Arbitrary precision for massive values (YB, ZiB, and beyond) |
| ๐ | Data Rates | Full bits/bytes per second with transfer time estimation |
| ๐ | 9 Languages | Built-in localization: EN, DE, FR, ES, PT, HI, JA, ZH, RU |
| ๐ฏ | Clean API | Namespace-based: display, storage, rate, compare, accessibility |
| โฟ | Accessible | Screen reader friendly output & ARIA labels |
| ๐ | Statistics | Streaming quantiles, percentiles, and aggregation |
๐ Quick Start #
Installation #
dependencies:
byte_converter: ^3.0.0
Basic Usage #
import 'package:byte_converter/byte_converter.dart';
void main() {
// ๐ฆ Create from any unit
final size = ByteConverter.fromGigaBytes(1.5);
// ๐จ Display formats
print(size.display.auto()); // "1.5 GB"
print(size.display.fuzzy()); // "about 1.5 GB"
print(size.display.gnu()); // "1.5G"
// ๐ Parse strings (even expressions!)
final parsed = ByteConverter.parse('2 GiB + 512 MiB');
print(parsed.gigaBytes); // 2.68435456
// ๐ Data rates & transfer estimation
final rate = DataRate.parse('100 Mbps');
final plan = size.estimateTransfer(rate);
print(plan.etaString()); // "2m 0s"
}
๐ฆ Import Options #
// ๐ฏ Core (most use cases)
import 'package:byte_converter/byte_converter.dart';
// ๐ฅ Full (statistics, streaming, interop)
import 'package:byte_converter/byte_converter_full.dart';
// ๐ชถ Locale-aware numbers without extra dependencies
// (built-in separators for en, de, fr, es, pt, ja, zh, ru)
import 'package:byte_converter/byte_converter_lite.dart';
The package has no runtime dependencies. To format numbers with
package:intl, register a formatter once:registerHumanizeNumberFormatter((value, o) { final locale = o.locale; if (locale == null || locale.isEmpty) return ''; // '' = use the default final f = NumberFormat.decimalPattern(locale) ..minimumFractionDigits = o.minimumFractionDigits ?? 0 ..maximumFractionDigits = o.maximumFractionDigits ?? o.minimumFractionDigits ?? o.precision; return f.format(value); });
๐ฏ Namespace API #
final size = ByteConverter.fromMegaBytes(1536);
// ๐จ Display - formatting options
size.display.auto() // "1.54 GB"
size.display.fuzzy() // "about 1.54 GB"
size.display.scientific() // "1.54 ร 10โน B"
// ๐พ Storage - disk alignment
size.storage.sectors // 3000000 (512B sectors)
size.storage.blocks // 375000 (4KB blocks)
// ๐ก Rate - network calculations
size.rate.bitsPerSecond // 12288000000.0
size.rate.transferTime(rate) // Duration
// ๐ Compare - size comparisons
size.compare.percentOf(total) // 15.0
size.compare.percentageBar(total) // "โโโโโโโโโโโโโโโโโโโโ" (20 chars)
// โฟ Accessibility
size.accessibility.screenReader() // "one point five four gigabytes"
๐ Documentation #
| Resource | Description |
|---|---|
| ๐ Wiki | Full documentation |
| ๐ Getting Started | Installation & setup |
| ๐ Usage Guide | Core functionality |
| ๐งฐ Utilities | Advanced features |
| ๐ Upgrading to 3.0 | Breaking changes and the old โ new API table |
Made with โค๏ธ for the Dart community