relative_time
5.0.0, released 3 years ago by viter.nl
Expresses a DateTime object relative to the current time in text form.
WASM-ready
What it does
Transforms DateTime objects into relative text representations such as '3 years ago' or 'in 42 minutes'. It supports a large number of localized languages and can use natural language or numeric expressions.
AI-written summary of version 5.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to display relative timestamps like '5 minutes ago' in a Flutter app.
- Your app requires internationalized relative time formatting across many languages.
Skip it when
- You only need absolute date and time formatting.
- You want a zero-dependency Dart-only utility without Flutter localization requirements.
Strengths
- Supports a massive list of languages extracted from the Unicode CLDR Project.
- Offers both class instances and convenient DateTime extension methods.
- Allows customization of allowed time units and numeric versus natural phrasing.
Weaknesses
- Relies on Flutter localization delegates for full BuildContext integration.
- Automated translations mean PRs for language updates are not accepted.
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 3
Add RelativeTimeLocalizations.delegate to your MaterialApp localizationsDelegates.
time.relativeTime(context);Works with
Packages commonly used together with relative_time: ones it builds on, ones built on it, and its own family.