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() {
final buffer = StringBuffer();
final parts = <dynamic>[];
if (isSuccess()) {
buffer.write('Success(');
if (data != null) {
parts.add(data);
}
} else {
buffer.write('Failure(');
parts.add(code);
}
if (msg != null) parts.add(msg);
if (requestId != null) parts.add(requestId);
buffer.write(parts.join(', '));
buffer.write(')');
return buffer.toString();
}