format_bytes 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 81

Build Status

Format byte amounts in human readable form.

Usage #

A simple usage example:

import 'package:format_bytes/format_bytes.dart';

main() {
  print(format(1024)); // 1 KiB

Features and bugs #

Please file feature requests and bugs at the issue tracker.

1.0.1 #

  • Some minor improvements to make Dart Pub happier. No code changes to the actual library have been made.

1.0.0 #

  • Initial version, created by Huulivoide


import 'dart:io';

import 'package:format_bytes/format_bytes.dart';

class PathAndSize {
  final String path;
  final int size;

  PathAndSize(this.path, this.size);

void processDirectory(Directory dir) {
  var statStream = dir.list(recursive: true).where((entry) {
    return entry is File;
  }).asyncMap((entry) async {
    return PathAndSize(entry.path, (await entry.stat()).size);

  var totalSize = statStream.fold(0, (total, entry) {
    return total + entry.size;

  statStream.listen((entry) {
    print('${entry.path} ${format(entry.size)}');
  }).onDone(() async {
    print('Total size: ${format(await totalSize)}');

main(List<String> args) {
  Directory root = Directory(args.isNotEmpty ? args.first : '.');

Use this package as a library

1. Depend on it

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

  format_bytes: ^1.0.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:format_bytes/format_bytes.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 Oct 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21


Detected platforms: Flutter, web, other

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

Health suggestions

Format lib/src/format_bytes_base.dart.

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

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (intl).


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
intl ^0.15.7 0.15.8 0.16.0
Transitive dependencies
path 1.6.4
Dev dependencies
test ^1.0.0