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 buf = StringBuffer();
if (latestVersion == null) {
buf.writeln('Could not determine latest version.');
} else {
buf.writeln('Current version: $currentVersion');
buf.writeln('Latest version: $latestVersion');
if (updateAvailable) {
buf.writeln('');
buf.writeln('A newer version is available!');
} else {
buf.writeln('');
buf.writeln('CLI is up to date.');
}
}
if (message.isNotEmpty && latestVersion == null) {
buf.writeln(message);
}
return buf.toString();
}