Skip to content
pubscout

truncate

3.0.1, released 6 years ago by avtobiografia.com

String truncation library supporting predefined and custom truncation strategies.

WASM-ready
$ flutter pub add truncate
Source repository

What it does

Provides functions to truncate strings using different positions such as start, end, or middle. It supports custom omission strings and custom truncation strategies.

AI-written summary of version 3.0.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to shorten long strings to a specific character limit
  • You need to place truncation indicators at the start, middle, or end of a string

Skip it when

  • You need advanced text layout measurements or multi-line wrapping handled by widgets

Strengths

  • Supports multiple truncation positions
  • Allows custom truncation strategies and omission strings
  • Null safe

Weaknesses

  • Very limited scope dealing only with basic string truncation

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
0
import 'package:truncate/truncate.dart';

main() {
  var text = "This is a long text";
  var truncated = truncate(text, 17, omission: "...", position: TruncatePosition.end);
  print(truncated);
}

Alternatives

Packages that do the same job and could replace truncate.