Skip to content
pubscout

sprintf

7.0.0, released 4 years ago by an unverified publisher

Dart implementation of C-style sprintf formatting

WASM-ready
$ flutter pub add sprintf
Source repository

What it does

Provides printf-like string formatting for Dart, supporting positional arguments, flags, width, precision, and various numeric bases. Handles Infinity, NaN, and negative numbers for hex/octal.

AI-written summary of version 7.0.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need formatted strings with C printf syntax
  • You need positional arguments in format strings
  • You need consistent formatting across platforms

Skip it when

  • You prefer Dart's built-in string interpolation
  • You need advanced templating or internationalization

Strengths

  • Supports a wide range of printf specifiers
  • Handles positional arguments
  • Cross-platform (android, ios, web, windows, macos, linux)

Weaknesses

  • No support for locale-aware formatting
  • Limited to printf syntax, not full templating
  • No type safety for arguments

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
0

Add dependency to pubspec and 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]));
}

Alternatives

Packages that do the same job and could replace sprintf.

  • smart_date_formatter

    Flutter utility for formatting, parsing and manipulating DateTime with human‑readable strings and ready‑made widgets.

Works with

Packages commonly used together with sprintf: ones it builds on, ones built on it, and its own family.