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() {
// `//` even when the project is empty. It is what makes the whole thing get
// linkified when pasted, and what an OS registers to route a click back
// here; `fw:/…` would be equally correct per RFC and recognised by nothing.
var out = StringBuffer('$scheme://${_encode(project ?? '')}');
// Always the leading slash, so `fw:///` names nothing and reads as an empty
// authority rather than as a truncated address.
out.write('/');
if (space != null) {
out.write(_encode(space!));
if (worktree != null) {
out.write('/${_encode(worktree!)}');
if (plugin != null) {
out.write('/${_encode(plugin!)}');
for (var segment in segments) {
out.write('/${_encode(segment)}');
}
}
}
}
if (axes.isNotEmpty) {
out.write('?');
// `encodeComponent`, not `encodeQueryComponent`: the latter is HTML form
// encoding, where a space becomes `+`. An address gets pasted into logs,
// filenames and terminals, and `+` only decodes back to a space for a
// reader who knows it is form-encoded. `%20` is unambiguous everywhere.
out.write(
[
for (var entry in axes.entries)
'${Uri.encodeComponent(entry.key)}=${Uri.encodeComponent(entry.value)}',
].join('&'),
);
}
return out.toString();
}