data_size 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • new50

๐Ÿ”Ÿ Customizable data size (bit & byte) formatting for interfacing with the user

Build, Test & Lint Coverage

Features #

  • format DataUnit.bit and DataUnit.byte
  • select a prefix:
    • Prefix.decimal (kB, MB, โ€ฆ with multiples of 1000)
    • Prefix.binary (KiB, MiB, โ€ฆ with multiples of 1024)
  • select a precision (number of decimal places)

Examples #

final defaultString = 12345.formatByteSize();                     // "12.35โ€‰kB"
final noDecimalPlaces = 12345.formatByteSize(precision: 0);       // "12โ€‰kB"
final binaryPrefix = 12345.formatByteSize(prefix: Prefix.binary); // "12.06โ€‰KiB"
final bits = 12345.formatBitSize();                               // "12.35โ€‰kb"

Changelog #

All notable changes to this project will be documented in this file.

This project adheres to Semantic Versioning.

Unreleased #

0.1.0 ยท 2020-06-12 #

Initial release ๐ŸŽ‰


import 'package:data_size/data_size.dart';

// ignore_for_file: avoid_print

void main() {
  print(12345.formatByteSize()); // "12.35โ€‰kB"
  print(12345.formatByteSize(precision: 0)); // "12โ€‰kB"
  print(12345.formatByteSize(prefix: Prefix.binary)); // "12.06โ€‰KiB"
  print(12345.formatBitSize()); // "12.35โ€‰kb"

Use this package as a library

1. Depend on it

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

  data_size: ^0.1.0

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:data_size/data_size.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.13

Health issues and suggestions

Document public APIs. (-1 points)

16 out of 16 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
basics ^0.4.0 0.4.0+1
meta ^1.1.8 1.1.8
pedantic ^1.8.0+1 1.9.0 1.9.1
Transitive dependencies
matcher 0.12.8
path 1.7.0
quiver 2.1.3
stack_trace 1.9.5
Dev dependencies
test ^1.14.3
test_coverage ^0.4.1