Search packages, repositories and app categories

Package detailsv3.0.1

humanizer

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

AndroidiOSWebmacOSWindowsLinux
30-day downloads
8.9K
Likes
54
Pub points
155

Install package

flutter pub add humanizer

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

Humanizer is a Dart library that transforms values into human-readable formats, making data more accessible and user-friendly. It supports converting numbers, dates, and strings into natural language representations, such as turning timestamps into '2 minutes ago' or numbers into '1.2K'. Ideal for improving UI clarity in apps across platforms, it simplifies localization and enhances user experience by presenting information in intuitive ways. The package is lightweight and integrates seamlessly with Flutter projects.

Use cases

  • Formatting timestamps in user interfaces
  • Converting large numbers to readable formats
  • Improving accessibility of numeric data
  • Enhancing log readability
  • Simplifying date display in apps

Key features

  • Converts numbers to K/M/B notation
  • Formats dates relative to now
  • Supports pluralization and grammar
  • Provides string case transformations
  • Easy integration with Flutter

Suitable for

  • Flutter developers
  • Apps requiring localized text
  • Data visualization tools
  • User-facing dashboards
  • Accessibility-focused applications

Considerations

  • Limited to text formatting utilities
  • Does not handle complex internationalization
  • Requires manual handling of edge cases
  • No built-in support for non-English locales
  • Depends on consistent input formatting

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

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:

Categories

Dependencies

Dependency list 4 items

Source repository

Projects using this package