prettysize 0.1.0

  • Installing
  • Versions
  • 56


Helper utility to provide pretty printed file sizes.

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


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"


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"



  • 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

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or flutter packages 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';
Version Uploaded Documentation Archive
0.1.0 Jan 31, 2018 Go to the documentation of prettysize 0.1.0 Download prettysize 0.1.0 archive


We analyzed this package on Jun 12, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.60.0
  • pana: 0.11.3


Describes how popular the package is relative to other packages. [more]
18 / 100
Code health derived from static analysis. [more]
89 / 100
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:prettysize/prettysize.dart.


  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use prettysize.dart.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 2 hints.

    Run dartfmt to format lib/prettysize.dart.

    Run dartfmt to format lib/src/prettysize_base.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <2.0.0
Dev dependencies
test ^0.12.0