FLUTTER ECOSYSTEM

Naddiseo/dart-sprintf

Dart 中的 sprintf 实现

dart-sprintf 项目封面
Stars
89
Forks
20
最近推送(UTC)
2022年10月31日
项目状态
未归档
no GitHub avatar
GITHUB User

no ↗

n/aearth
语言DartPython

技术话题

此仓库发布的插件

使用的依赖

依赖清单 2 项
  • test开发依赖^1.16.0-nullsafety.13
  • lints开发依赖^1.0.1

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

展开 / 收起项目 README

dart-sprintf

Dart implementation of sprintf.

Build Status

ChangeLog

ChangeLog.md

Getting Started

Add the following to your pubspec.yaml:

dependencies:
  sprintf: "^7.0.0"

then run pub install.

Next, import dart-sprintf:

import 'package:sprintf/sprintf.dart';
Example
import 'package:sprintf/sprintf.dart';

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

Limitations

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