highlight method Null safety

  1. @override
String highlight(
  1. {dynamic color}
)
override

Prints the text associated with this span in a user-friendly way.

This is identical to message, except that it doesn't print the file name, line number, column number, or message. If length is 0 and this isn't a SourceSpanWithContext, returns an empty string.

color may either be a String, a bool, or null. If it's a string, it indicates an ANSI terminal color escape that should be used to highlight the span's text (for example, "\u001b[31m" will color red). If it's true, it indicates that the text should be highlighted using the default color. If it's false or null, it indicates that the text shouldn't be highlighted.

This uses the full range of Unicode characters to highlight the source span if glyph.ascii is false (the default), but only uses ASCII characters if it's true.

Implementation

@override
String highlight({color}) {
  if (this is! SourceSpanWithContext && length == 0) return '';
  return Highlighter(this, color: color).highlight();
}