byte_size 1.4.1

  • Readme
  • Changelog
  • Example
  • Installing
  • new50

ByteSize License Build Status #

ByteSize is a library written in Dart language 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.

Usage #

A simple usage example:

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
}

License #

Copyright (c) 2020 Mbadiwe Nnaemeka Ronald ron2tele@gmail.com

This software is provided 'as-is', without any express or implied
warranty. In no event will the author be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation must be
specified.

2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.

3. This notice may not be removed or altered from any source distribution.
    
 

Tip Jar

  • 💵 Bitcoin: 1Mcci95WffSJnV6PsYG7KD1af1gDfUvLe6

Conclusion #

Special thanks to Xor-el for making this library available in the first place.

1.4.1 #

  • Change fromJson methods to a constructor

  • Updated the documentation

1.4.0 #

  • Added the copy, toJson and fromJson methods

1.3.4 #

  • Updated version

1.3.3 #

  • Updated version

1.3.2 #

  • Minor optimization
  • Included tests for the implemented Comparable interface

1.3.1 #

  • Updated the documentation
  • Updated README
  • Implemented Comparable interface

1.3.0 #

  • Updated the documentation
  • Implemented Comparable interface

1.2.1 #

  • Updated the documentation
  • Updated by Mbadiwe Nnaemeka Ronald

1.2.0 #

  • Updated the documentation
  • Updated by Mbadiwe Nnaemeka Ronald

1.1.1 #

  • Updated by Mbadiwe Nnaemeka Ronald

1.1.0 #

  • Updated by Mbadiwe Nnaemeka Ronald

1.0.0 #

  • Initial version, created by Mbadiwe Nnaemeka Ronald

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
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  byte_size: ^1.4.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:byte_size/byte_size.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

We analyzed this package on Jul 6, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.8.1 <3.0.0
intl ^0.16.1 0.16.1
locales ^0.1.0 0.1.0
Transitive dependencies
path 1.7.0
Dev dependencies
pedantic ^1.9.0
test ^1.14.4