TextSpanBuilder class
A span builder that creates TextSpan objects for censored text.
{@macro base_span_builder}
This implementation creates text-only spans, applying censoredStyle to censored portions and style to normal portions.
Example:
final builder = TextSpanBuilder(
censorIt: CensorIt.mask('Fuck this!'),
style: TextStyle(color: Colors.black),
censoredStyle: TextStyle(
color: Colors.red,
fontWeight: .bold,
),
);
final spans = builder.buildSpans(
revealAll: false,
);
- Inheritance
-
- Object
- BaseSpanBuilder<
TextSpan> - TextSpanBuilder
Constructors
- TextSpanBuilder({required CensorIt censorIt, required TextStyle style, required TextStyle censoredStyle})
- A span builder that creates TextSpan objects for censored text.
Properties
- censoredStyle → TextStyle
-
The text style to apply to censored (profane) text.
final
- censorIt → CensorIt
-
The CensorIt instance containing censored text and match information.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- style → TextStyle
-
The text style to apply to normal (non-censored) text.
finalinherited
Methods
-
buildCensoredSpan(
String originalWord, int index, bool revealAll) → TextSpan -
Builds a span for censored (profane) text.
override
-
buildPlainSpan(
String text) → TextSpan -
Builds a span for normal (non-censored) text.
override
-
buildSpans(
{bool revealAll = true}) → List< TextSpan> -
Builds a list of spans representing the entire text with
censoring applied.
inherited
-
getMatches(
) → List< RegExpMatch> -
Returns the list of profanity matches found in the text.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited