truncate method

Text truncate()

Truncates the text with an ellipsis if it exceeds one line.

This mirrors Bootstrap's .text-truncate class.

Example:

Text('Very long text...').truncate()

Implementation

Text truncate() {
  return _copyWith(
    softWrap: false,
    overflow: TextOverflow.ellipsis,
    maxLines: 1,
  );
}