prettysize 0.1.0

  • Readme
  • Changelog
  • Installing
  • 0

dart-prettysize #

Helper utility to provide pretty printed file sizes.

This library is dart port of davglass/prettysize javascript library. All credits should go directly here.

Usage #

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

  prettysize: "^0.1.0"

and use it like that:

import 'package:prettysize/prettysize.dart';

String str = prettysize(1024);
//str = "1 kB"

str = prettysize(1024 * 1024);
//str = "1 MB"

str = prettysize(123456789);
//str = "117.7 MB"

Arguments #

prettysize(123456, nospace: true, one: true, places: 2);

First arg is size
Second argument is to remove the space from the output
Third argument is to use a single character for the size.
Forth argument is the number of decimal places to return, default is 1. 

Srting str = prettysize(1024 * 1024, true);
//str = "1MB"

str = prettysize(123456789, nospace: true) // pretty(123456789, true, true);
//str = "117.7M"

str = prettysize(123456789, one: true) // pretty(123456789, false, true);
//str = "117.7 M"

str = prettysize(123456789, one: true, places: 2) // pretty(123456789, false, true, 2);
//str = "117.74 M"

str = prettysize(123456789, one: true, places: 3) // pretty(123456789, false, true, 3);
//str = "117.738 M"

Changelog #

0.1.0 #

  • Initial version, created by Stagehand

Use this package as a library

1. Depend on it

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

  prettysize: ^0.1.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

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

3. Import it

Now in your Dart code, you can use:

import 'package:prettysize/prettysize.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.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <2.0.0