-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Welcome to the byte_converter wiki! This is your guide to converting and formatting bytes, bits, and data rates in Dart with both simple and advanced controls.
• Easy conversions (KB, MB, GB… and KiB, MiB, GiB) • Human‑readable formatting with SI/IEC/JEDEC standards • Parse strings like "1.5 GB", "2GiB", or "100 Mbps" • BigInt support for ultra‑large values (YB, ZiB…) • Extensions on int/double/BigInt for fluent usage
— Latest version: 2.3.1 — SDK: Dart >= 3.0.0
- 🚀 Getting started → Getting-Started
- 📦 Usage & examples → Usage
- 🎛️ Formatting options → Formatting
- 🧮 Parsing strings → Parsing
- 📶 Data rates → Data-Rate
- 🧱 BigInt and arbitrary precision → BigInt
- 🧩 Extensions (int/double/BigInt) → Extensions
- 📚 API reference → API-Reference
- 🧪 Edge cases → Edge-Cases
- ❓ FAQ → FAQ
- 🧯 Troubleshooting → Troubleshooting
- 🍳 Recipes → Recipes
- 📝 Changelog → Changelog
Tip: You can add a logo or banner under
images/and reference it here like[[images/logo.png]].
import 'package:byte_converter/byte_converter.dart';
void main() {
final file = ByteConverter.fromMegaBytes(1500); // 1500 MB
// Human readable auto (SI by default)
print(file.toHumanReadableAuto()); // e.g., "1.5 GB"
// Choose a unit
print(file.toHumanReadable(SizeUnit.GB)); // "1.5 GB"
// Parse a size
final parsed = ByteConverter.parse('2 GiB', standard: ByteStandard.iec);
print(parsed.toHumanReadableAuto(standard: ByteStandard.iec)); // "2 GiB"
// Data rate formatting
final rate = DataRate.megaBitsPerSecond(100);
print(rate.toHumanReadableAuto()); // "100 Mb/s"
}- Three standards: SI (kilo), IEC (kibi), and JEDEC (binary multipliers with KB, MB, GB symbols)
- Flexible formatting: precision, spacing, full‑form names, min/max fraction digits, signed values, forceUnit, and locale-aware number formatting (NEW in 2.3.0)
- Locale-aware formatting with built-in translations for en/de/fr and custom unit name registration (NEW in 2.3.0)
-
Safe non-throwing
tryParsemethods that return detailed diagnostics for validation (NEW in 2.3.0) - Powerful parsing resilient to spaces/commas/underscores, handles bits vs bytes, and unit words (e.g., "megabytes")
- BigInt counterpart covers enormous numbers precisely with rounding controls
- Convenient extensions for fluent usage:
10.gibiBytes,500.kiloBytes,BigInt.from(1).yottaBytes, etc.
Version compatibility: This wiki targets byte_converter v2.3.1 (Dart SDK >= 3.0.0). Features match tests in this repository branch.
Continue with Getting-Started to install and run your first snippets.