FluentSpan class sealed

A piece of a formatted message that may contain inline markup.

Sealed: every concrete span is either a FluentTextSpan or a FluentMarkupSpan. Use a switch statement to handle the tree exhaustively.

String render(List<FluentSpan> spans) {
  final buffer = StringBuffer();
  for (final span in spans) {
    switch (span) {
      case FluentTextSpan(:final text):
        buffer.write(text);
      case FluentMarkupSpan(:final children):
        buffer.write(render(children));
    }
  }
  return buffer.toString();
}

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

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