搜索插件、代码仓与 APP 分类

插件详情v3.0.1

humanizer

一个将 Dart 值转换为人类友好表示形式的库。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
8880
喜欢数
54
Pub 分数
155

安装插件

flutter pub add humanizer

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Humanizer 是一个 Dart 库,可将值转换为人类可读的格式,使数据更易于访问和用户友好。它支持将数字、日期和字符串转换为自然语言表示形式,例如将时间戳转换为“2 分钟前”或数字转换为“1.2K”。非常适合在跨平台应用中提升 UI 清晰度,简化本地化并以直观的方式呈现信息,从而增强用户体验。该包轻量且可无缝集成到 Flutter 项目中。

适合场景

  • 在用户界面中格式化时间戳
  • 将大数字转换为可读格式
  • 提高数值数据的可访问性
  • 提高日志可读性
  • 简化应用中的日期显示

主要特点

  • 将数字转换为K/M/B表示法
  • 相对于现在格式化日期
  • 支持复数和语法
  • 提供字符串大小写转换
  • 与 Flutter 的轻松集成

适合对象

  • Flutter 开发者
  • 需要本地化文本的应用程序
  • 数据可视化工具
  • 面向用户的仪表板
  • 面向可访问性的应用程序

使用建议

  • 仅限文本格式化工具
  • 不处理复杂的国际化
  • 需要手动处理边缘情况
  • 不支持非英文地区设置的内置支持
  • 依赖于一致的输入格式

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Humanizer

pub package

All Contributors

What?

A Dart library to convert values into human-friendly representations.

Why?

When writing user interfaces we often want to present data we have in a raw format in a way that makes sense to the end user, but doing so is often non-trivial. This library aims to make such conversions easy and flexible.

Where?

Firstly, install the humanizer package, then you can import Humanizer into your Dart code as follows:

import 'package:humanizer/humanizer.dart';

How?

This library has a broad API surface, and in fact has multiple API layers as discussed here. The following table gives a high level overview of the various features, with links to deeper discussion:

Feature Description
Approximate time Converts a Duration to a human-friendly approximation.
Cardinal numbers Converts an integral value to cardinal form (one, two, three etc).
Ordinal numbers Converts an integral value to ordinal form (1st / first, 2nd / second etc).
Plurality Alters the plurality of an input word.
String casing Converts input strings to Sentence case or Title Case.
String truncation Intelligently truncates input strings.
Symbols Converts programming symbol names into human-friendly representations.
Units of measurement Provides types to represent common units of measurement and the ability to convert those types to a human-readable form.

Note that whilst this library is locale-aware, it currently only includes an English implementation.

Who?

Thanks goes to these wonderful people (emoji key):


Kent Boogaart

💻

Arun Prakash

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

Special thanks to these inspirational open source libraries:

所属分类

依赖

依赖清单 4 项

源码仓库

使用此插件的项目