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

refactor!: Seal the Dependency class #140

Merged
merged 11 commits into from
Dec 11, 2024
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 1.3.1-wip

- Require Dart 3.2
- Seal the `Dependency` class.

## 1.3.0

Expand Down
14 changes: 5 additions & 9 deletions lib/src/dependency.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ Dependency? _fromJson(Object? data, String name) {
return null;
}

abstract class Dependency {
Dependency._();

sealed class Dependency {
String get _info;

@override
Expand All @@ -106,8 +104,7 @@ class SdkDependency extends Dependency {
final VersionConstraint version;

SdkDependency(this.sdk, {VersionConstraint? version})
: version = version ?? VersionConstraint.any,
super._();
: version = version ?? VersionConstraint.any;

@override
String get _info => sdk;
Expand All @@ -127,7 +124,7 @@ class GitDependency extends Dependency {
final String? ref;
final String? path;

GitDependency(this.url, {this.ref, this.path}) : super._();
GitDependency(this.url, {this.ref, this.path});

factory GitDependency.fromData(Object? data) {
if (data is String) {
Expand Down Expand Up @@ -194,7 +191,7 @@ Uri? _tryParseScpUri(String value) {
class PathDependency extends Dependency {
final String path;

PathDependency(this.path) : super._();
PathDependency(this.path);

factory PathDependency.fromData(Object? data) {
if (data is String) {
Expand Down Expand Up @@ -223,8 +220,7 @@ class HostedDependency extends Dependency {
final HostedDetails? hosted;

HostedDependency({VersionConstraint? version, this.hosted})
: version = version ?? VersionConstraint.any,
super._();
: version = version ?? VersionConstraint.any;

@override
String get _info => version.toString();
Expand Down