discontinuedPackage flutter_censor_it has been discontinued and replaced by censor_it_flutter.

WidgetSpanBuilder class

A span builder that creates WidgetSpan objects for censored text.

{@macro base_span_builder}

This implementation replaces censored words with widgets using WidgetSpan. When revealAll is true, the original text is shown instead of the widget.

Example:

final builder = WidgetSpanBuilder(
  censorIt: CensorIt.mask('Fuck this!'),
  style: TextStyle(color: Colors.black),
  child: Icon(Icons.block, size: 16),
  alignment: .middle,
);
final spans = builder.buildSpans(revealAll: false);
Inheritance

Constructors

WidgetSpanBuilder({required CensorIt censorIt, required TextStyle style, required Widget child, PlaceholderAlignment alignment = .middle, TextBaseline? baseline = .ideographic})
A span builder that creates WidgetSpan objects for censored text.

Properties

alignment → PlaceholderAlignment
How to align the widget vertically within the text line.
final
baseline → TextBaseline?
The baseline to use when alignment is .baseline.
final
censorIt → CensorIt
The CensorIt instance containing censored text and match information.
finalinherited
child → Widget
The widget to display in place of censored words.
final
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 revealedAll) → InlineSpan
Builds a span for censored (profane) text.
override
buildPlainSpan(String text) → InlineSpan
Builds a span for normal (non-censored) text.
override
buildSpans({bool revealAll = true}) → List<InlineSpan>
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