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();
buf.writeln('Zorphy Doctor Report');
buf.writeln('Directory: $projectDir');
if (dryRun) {
buf.writeln('Mode: dry-run (no changes made)');
}
buf.writeln('');
buf.writeln('Deleted $deletedCount stale .zorphy.dart file(s)');
if (deletedFiles.isNotEmpty) {
for (final f in deletedFiles) {
buf.writeln(' - $f');
}
}
buf.writeln('');
if (dryRun) {
buf.writeln(
'Would run: dart run build_runner build --delete-conflicting-outputs',
);
} else {
buf.writeln(
'Build runner exited with code ${buildExitCode ?? "not run"}',
);
buf.writeln('Regenerated $regeneratedCount .zorphy.dart file(s)');
}
buf.writeln('');
if (hasInvalidType) {
buf.writeln(
'WARNING: InvalidType still found in ${remainingInvalidTypeFiles.length} file(s):',
);
for (final f in remainingInvalidTypeFiles) {
buf.writeln(' - $f');
}
buf.writeln('');
}
switch (health) {
case DoctorHealth.healthy:
buf.writeln('Project health: healthy');
case DoctorHealth.warnings:
buf.writeln('Project health: warnings (InvalidType remnants)');
case DoctorHealth.unhealthy:
buf.writeln('Project health: unhealthy (build_runner failed)');
}
return buf.toString();
}