TruncateToFixedWordLengthTransformation class
A transformation to convert a String into a truncated variant that contains at most length words.
If the input contains more than length words, it is truncated. The truncationIndicator will be prepended or appended depending on truncateAt.
final transformation = TruncateToFixedWordLengthTransformation(
length: 4,
truncationIndicator: '~',
truncateAt: TruncateAt.end,
);
// 'A string that is~'
transformation.transform('A string that is too long', 'en_US');
- Inheritance
-
- Object
- Transformation<
String, String> - TruncateToFixedWordLengthTransformation
- Available Extensions
Constructors
- TruncateToFixedWordLengthTransformation({required int length, required String truncationIndicator, required TruncateAt truncateAt})
-
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- length → int
-
The maximum number of words to allow in a transformed String.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- truncateAt → TruncateAt
-
Whether to truncate from the start or end of the input.
final
- truncationIndicator → String
-
The truncation indicator that should be prepended or appended if a String is truncated, subject to available
space.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
transform(
String input, String locale) → String -
Transforms
input
into an instance ofU
using the providedlocale
.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited