sprintf 3.0.2

  • README.md
  • Installing
  • Versions
  • 85


Dart implementation of sprintf.

Build Status


v3.0.2 (2017-08-17

* Fixed bad publish

v3.0.1 (2017-08-17)

* Fixed weak typing which stopped dartdevc from working (#11 thanks @bergwerf)

v3.0.0 (2017-04-20)

* Fixed rounding of floats, again. Bumping major version because it's different from previous behaviour

v2.0.0 (2017-03-23)

* Fixed rounding of floats. Bumping major version, because previous behaviour was to always round down.

v1.1.1 (2016-11-16)

* Updated to use `test` library since `unittest` has been deprecated. 

v1.1.0 (2014-08-21)

* **API change**: Any object with a valid `toString` method can be formatted with `'%s'` (#7)

v1.0.9 (2013-12-15)

* Round numbers when they're truncated. (#6)

v1.0.8 (2013-10-08)

* Remove trailing decimal point if there are no following digits (#6)

v1.0.7 (2013-05-07)

* Update for new dart version

v1.0.6 (2013-04-16)

* Update for new dart version

v1.0.5 (2013-03-25)

* Fixed dependencies example in README (#5)

v1.0.4 (2013-03-21)

* Update for new dart version

* Update for new pubspec format

v1.0.3 (2013-02-12)

* Update for dart M2

v1.0.2 (2013-01-21)

* Pubspec and whitespace fixes

v1.0.1 (2012-11-12)

* Update for new dart version

v1.0.0 (2012-10-08)

First release with semver

Getting Started

Add the following to your pubspec.yaml:

  sprintf: "^3.0.0"

then run pub install.

Next, import dart-sprintf:

import 'package:sprintf/sprintf.dart';


import 'package:sprintf/sprintf.dart';

void main() {
	print(sprintf("%04i", [-42]));
	print(sprintf("%s %s", ["Hello", "World"]));
	print(sprintf("%#04x", [10]));
Hello World


  • Negative numbers are wrapped as 64bit ints when formatted as hex or octal.

Differences to C's printf

  • When using fixed point printing of numbers with large exponents, C introduces errors after 20 decimal places. Dart-printf will just print 0s.

1. Depend on it

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

  sprintf: "^3.0.2"

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 packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:sprintf/sprintf.dart';
Version Uploaded Documentation Archive
3.0.2 Aug 18, 2017 Go to the documentation of sprintf 3.0.2 Download sprintf 3.0.2 archive
3.0.1 Aug 18, 2017 Go to the documentation of sprintf 3.0.1 Download sprintf 3.0.1 archive
3.0.0 Apr 20, 2017 Go to the documentation of sprintf 3.0.0 Download sprintf 3.0.0 archive
1.0.8 Oct 9, 2013 Go to the documentation of sprintf 1.0.8 Download sprintf 1.0.8 archive
1.0.7 May 7, 2013 Go to the documentation of sprintf 1.0.7 Download sprintf 1.0.7 archive
1.0.6 Apr 16, 2013 Go to the documentation of sprintf 1.0.6 Download sprintf 1.0.6 archive
1.0.5 Mar 29, 2013 Go to the documentation of sprintf 1.0.5 Download sprintf 1.0.5 archive
1.0.4 Mar 21, 2013 Go to the documentation of sprintf 1.0.4 Download sprintf 1.0.4 archive
1.0.3 Feb 12, 2013 Go to the documentation of sprintf 1.0.3 Download sprintf 1.0.3 archive
1.0.2 Feb 12, 2013 Go to the documentation of sprintf 1.0.2 Download sprintf 1.0.2 archive

All 12 versions...


This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1


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


Detected platforms: Flutter, web, other

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


  • Maintain CHANGELOG.md.

    Changelog entries help clients to follow the progress in your code.

  • 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.

  • 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 sprintf.dart.


Package Constraint Resolved Available
Dev dependencies
test any