byte_size 1.4.1 copy "byte_size: ^1.4.1" to clipboard
byte_size: ^1.4.1 copied to clipboard

ByteSize is a library that handles how byte sizes are represented and an easy to use interface to convert to other forms of representation also taking locale into consideration.

example/byte_size_example.dart

import 'package:byte_size/byte_size.dart';
import 'package:locales/locales.dart';
import 'dart:convert';

void main() {
  var size = ByteSize.FromKiloBytes(10000);
  print(size.toString('MB', 3, Locale.fr_CA)); // 9,766 MB

  var json = size.toJson();
  print(json);
  // {"b":"81920000","B":"10240000.00000000000000000000","KB":"10000.00000000000000000000",
  // "MB":"9.76562500000000000000","GB":"0.00953674316406250000","TB":"0.00000931322574615479",
  // "PB":"0.00000000909494701773"}

  var size2 = size.copy();
  print(size2.toString('KB')); // 10,000 KB

  var size3 = ByteSize.fromJson(json);
  print(size3.toString('KB')); // 10,000 KB
}
4
likes
30
points
243
downloads

Publisher

unverified uploader

Weekly Downloads

ByteSize is a library that handles how byte sizes are represented and an easy to use interface to convert to other forms of representation also taking locale into consideration.

Repository (GitHub)

License

unknown (license)

Dependencies

intl, locales

More

Packages that depend on byte_size