From 964f8e48717c9422efd39dc8acd377c7cf6987c8 Mon Sep 17 00:00:00 2001 From: Stefan Schaller Date: Fri, 24 Feb 2023 09:34:04 +0100 Subject: [PATCH] change dynamic to object --- lib/version.dart | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/lib/version.dart b/lib/version.dart index 51199af..5b9e253 100644 --- a/lib/version.dart +++ b/lib/version.dart @@ -65,27 +65,23 @@ class Version implements Comparable { List get preRelease => List.from(_preRelease); /// Determines whether the left-hand [Version] represents a lower precedence than the right-hand [Version]. - bool operator <(dynamic o) => o is Version && _compare(this, o) < 0; + bool operator <(Object o) => o is Version && _compare(this, o) < 0; /// Determines whether the left-hand [Version] represents an equal or lower precedence than the right-hand [Version]. - bool operator <=(dynamic o) => o is Version && _compare(this, o) <= 0; + bool operator <=(Object o) => o is Version && _compare(this, o) <= 0; /// Determines whether the left-hand [Version] represents an equal precedence to the right-hand [Version]. @override - bool operator ==(dynamic o) => o is Version && _compare(this, o) == 0; + bool operator ==(Object o) => o is Version && _compare(this, o) == 0; /// Determines whether the left-hand [Version] represents a greater precedence than the right-hand [Version]. - bool operator >(dynamic o) => o is Version && _compare(this, o) > 0; + bool operator >(Object o) => o is Version && _compare(this, o) > 0; /// Determines whether the left-hand [Version] represents an equal or greater precedence than the right-hand [Version]. - bool operator >=(dynamic o) => o is Version && _compare(this, o) >= 0; + bool operator >=(Object o) => o is Version && _compare(this, o) >= 0; @override - int compareTo(Version? other) { - if (other == null) { - throw ArgumentError.notNull("other"); - } - + int compareTo(Version other) { return _compare(this, other); } @@ -188,15 +184,7 @@ class Version implements Comparable { build: build, preRelease: preReleaseList); } - static int _compare(Version? a, Version? b) { - if (a == null) { - throw ArgumentError.notNull("a"); - } - - if (b == null) { - throw ArgumentError.notNull("b"); - } - + static int _compare(Version a, Version b) { if (a.major > b.major) return 1; if (a.major < b.major) return -1;