byte_converter 2.0.0 copy "byte_converter: ^2.0.0" to clipboard
byte_converter: ^2.0.0 copied to clipboard

Provides a simple interface for conversion of Digital values such as Bytes, KiloBytes etc.

ByteConverter #

Pub Version License: MIT

High-performance byte unit converter for Dart with automatic caching and fluent API inspired by ByteSize library from C#.

Features #

  • 🚀 High-performance with cached calculations
  • 📦 Decimal (KB, MB, GB, TB, PB) and Binary (KiB, MiB, GiB, TiB, PiB) units
  • 🔢 Math operations (+, -, *, /)
  • 🔄 JSON serialization
  • 💫 Fluent API with extensions
  • 📐 Precise number formatting
  • 🧮 Storage units (sectors, blocks, pages)
  • 📈 Network transfer rates
  • ⏱️ Time-based calculations

Installation #

dependencies:
  byte_converter: ^2.0.0

Quick Start #

// Basic Usage
final size = 1.5.gigaBytes;
print(size); // 1.5 GB

// Math Operations
final total = 1.5.gigaBytes + 500.megaBytes;
print(total); // 2 GB

// Binary Units
final ram = 16.gibiBytes;
print(ram.toHumanReadable(SizeUnit.GB)); // 17.18 GB

// Network Rates
final speed = 100.megaBytes;
print(speed.megaBitsPerSecond); // 800 Mbps

// Storage Units
final disk = 4.kibiBytes;
print(disk.sectors); // 8 sectors

Advanced Usage #

final data = ByteConverter.fromGigaBytes(1.5);

// Precision Control
print(data.toHumanReadable(SizeUnit.MB, precision: 3)); // 1536.000 MB

// Transfer Time
final downloadTime = data.downloadTimeAt(10.megaBitsPerSecond);
print(downloadTime); // Duration

// Storage Alignment
final aligned = data.roundToBlock();
print(aligned.isWholeBlock); // true

Performance #

  • 🚀 Cached calculations for frequent operations
  • 🧠 Lazy initialization for better memory usage
  • 🔒 Immutable design for thread safety
  • ⚡ Optimized string formatting

License #

This project is licensed under MIT License. Read about it here: MIT License

Features and bugs #

Please file feature requests and bugs here issue tracker.

6
likes
150
points
2.1k
downloads

Publisher

verified publisherarunprakashg.com

Weekly Downloads

Provides a simple interface for conversion of Digital values such as Bytes, KiloBytes etc.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

More

Packages that depend on byte_converter