Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit 358f96a

Browse files
committed
fix: Don't use runtimeType for toString
1 parent c39e45a commit 358f96a

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

lib/src/dependency.dart

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,7 @@ Dependency? _fromJson(Object? data, String name) {
9090
return null;
9191
}
9292

93-
sealed class Dependency {
94-
String get _info;
95-
96-
@override
97-
String toString() => '$runtimeType: $_info';
98-
}
93+
sealed class Dependency {}
9994

10095
@JsonSerializable()
10196
class SdkDependency extends Dependency {
@@ -106,15 +101,15 @@ class SdkDependency extends Dependency {
106101
SdkDependency(this.sdk, {VersionConstraint? version})
107102
: version = version ?? VersionConstraint.any;
108103

109-
@override
110-
String get _info => sdk;
111-
112104
@override
113105
bool operator ==(Object other) =>
114106
other is SdkDependency && other.sdk == sdk && other.version == version;
115107

116108
@override
117109
int get hashCode => Object.hash(sdk, version);
110+
111+
@override
112+
String toString() => 'SdkDependency($sdk)';
118113
}
119114

120115
@JsonSerializable()
@@ -138,9 +133,6 @@ class GitDependency extends Dependency {
138133
throw ArgumentError.value(data, 'git', 'Must be a String or a Map.');
139134
}
140135

141-
@override
142-
String get _info => 'url@$url';
143-
144136
@override
145137
bool operator ==(Object other) =>
146138
other is GitDependency &&
@@ -150,6 +142,9 @@ class GitDependency extends Dependency {
150142

151143
@override
152144
int get hashCode => Object.hash(url, ref, path);
145+
146+
@override
147+
String toString() => 'GitDependency($url, ref: $ref, path: $path)';
153148
}
154149

155150
Uri? parseGitUriOrNull(String? value) =>
@@ -200,15 +195,15 @@ class PathDependency extends Dependency {
200195
throw ArgumentError.value(data, 'path', 'Must be a String.');
201196
}
202197

203-
@override
204-
String get _info => 'path@$path';
205-
206198
@override
207199
bool operator ==(Object other) =>
208200
other is PathDependency && other.path == path;
209201

210202
@override
211203
int get hashCode => path.hashCode;
204+
205+
@override
206+
String toString() => 'PathDependency($path)';
212207
}
213208

214209
@JsonSerializable(disallowUnrecognizedKeys: true)
@@ -222,9 +217,6 @@ class HostedDependency extends Dependency {
222217
HostedDependency({VersionConstraint? version, this.hosted})
223218
: version = version ?? VersionConstraint.any;
224219

225-
@override
226-
String get _info => version.toString();
227-
228220
@override
229221
bool operator ==(Object other) =>
230222
other is HostedDependency &&
@@ -233,6 +225,9 @@ class HostedDependency extends Dependency {
233225

234226
@override
235227
int get hashCode => Object.hash(version, hosted);
228+
229+
@override
230+
String toString() => 'HostedDependency(version: $version, hosted: $hosted)';
236231
}
237232

238233
@JsonSerializable(disallowUnrecognizedKeys: true)

0 commit comments

Comments
 (0)