truncate 2.1.2

Dart native js
Flutter Android iOS web

String truncation library supporting predefined and custom truncation strategies

example/truncate_example.dart

import 'package:truncate/truncate.dart';

void 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
}
2
likes
100
pub points
77%
popularity

Publisher

avtobiografia.com

String truncation library supporting predefined and custom truncation strategies

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

More

Packages that depend on truncate