搜尋套件、儲存庫與 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 項

原始碼儲存庫

使用此套件的專案