format property
String
get
format
Utility to print templated Strings.
Example:
Given a templated String:
final String foo = """|A multi-line message
|is a message
|that exists of
|multiple lines.
|
|True story"""";
Will produce a multi-line String:
'A multi-line message is a message that exists of multiple lines.
True story'
Implementation
String get format => replaceAllMapped(
// Find all '|' char including preceding whitespaces.
RegExp(r"(\s+?\|)"),
// Replace them with a single linebreak.
(_) => "\n")
.replaceAll(RegExp(r"(!?,)\|"), "")
.trimLeft()
.replaceAll(",|", "|");