toString method
A string representation of this object.
Some classes have a default textual representation,
often paired with a static parse
function (like int.parse).
These classes will provide the textual representation as
their string representation.
Other classes have no meaningful textual representation
that a program will care about.
Such classes will typically override toString
to provide
useful information when inspecting the object,
mainly for debugging or logging.
Implementation
@override
String toString() {
String longText = getLongText();
String msg = containerFull(text: title, longText: longText.length);
if (dateTimeStart != null) {
msg += "\n[DATE TIME START]\t${dateTimeStart.toString()}";
}
if (dateTimeNow != null) {
msg += "\n[DATE TIME NOW]\t${dateTimeNow.toString()}";
}
msg += "\n${containerFull(text: "Message", longText: longText.length)}";
if (data is Map || data is List) {
msg += "\n${JsonEncoder.withIndent(" " * 2).convert(data)}";
} else {
msg += "\n${data.toString()}";
}
if (stackTrace != null) {
msg +=
"\n${containerFull(text: name.toUpperCase(), longText: longText.length)}";
List<String> error_stacks = stackTrace.toString().trim().split("\n");
for (var i = 0; i < error_stacks.length; i++) {
String error = error_stacks[i];
msg += "\n[${name}]\t${error}";
}
}
msg += "\n${containerFull(text: "Complete", longText: longText.length)}";
return msg;
}