truncate 3.0.1 copy "truncate: ^3.0.1" to clipboard
truncate: ^3.0.1 copied to clipboard

String truncation library supporting predefined and custom truncation strategies

truncate #

Build Status

String truncation library supporting multiple predefined and custom truncation strategies

Usage #

You can check out the package on pub.dev or read the documentation there.

A simple usage example:

import 'package:truncate/truncate.dart';

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

  truncated =
      truncate(text, 15, omission: "...", position: TruncatePosition.start);
  print("${truncated} : ${truncated.length} characters");
  // Output: ... a long text : 15 characters

  truncated =
      truncate(text, 5, omission: "zzz", position: TruncatePosition.middle);
  print("${truncated} : ${truncated.length} characters");
  // Output: Tzzzt : 5 characters

  truncated = truncator(text, 9, CutStrategy());
  print("${truncated} : ${truncated.length} characters");
  // Output: This is a : 9 characters
}

15
likes
160
points
11.9k
downloads

Publisher

verified publisheravtobiografia.com

Weekly Downloads

String truncation library supporting predefined and custom truncation strategies

Repository (GitHub)

Documentation

API reference

License

MIT (license)

More

Packages that depend on truncate