@@ -70,13 +70,17 @@ class Version implements VersionConstraint, VersionRange {
70
70
/// This is split into a list of components, each of which may be either a
71
71
/// string or a non-negative integer. It may also be empty, indicating that
72
72
/// this version has no pre-release identifier.
73
+ ///
74
+ /// **Note:** The returned list shouldn't be modified.
73
75
final List <Object > preRelease;
74
76
75
77
/// The build identifier: "foo" in "1.2.3+foo".
76
78
///
77
79
/// This is split into a list of components, each of which may be either a
78
80
/// string or a non-negative integer. It may also be empty, indicating that
79
81
/// this version has no build identifier.
82
+ ///
83
+ /// **Note:** The returned list shouldn't be modified.
80
84
final List <Object > build;
81
85
82
86
/// The original string representation of the version number.
@@ -96,8 +100,10 @@ class Version implements VersionConstraint, VersionRange {
96
100
97
101
Version ._(this .major, this .minor, this .patch, String ? preRelease,
98
102
String ? build, this ._text)
99
- : preRelease = preRelease == null ? < Object > [] : _splitParts (preRelease),
100
- build = build == null ? [] : _splitParts (build) {
103
+ : preRelease = preRelease == null || preRelease.isEmpty
104
+ ? []
105
+ : _splitParts (preRelease),
106
+ build = build == null || build.isEmpty ? [] : _splitParts (build) {
101
107
if (major < 0 ) throw ArgumentError ('Major version must be non-negative.' );
102
108
if (minor < 0 ) throw ArgumentError ('Minor version must be non-negative.' );
103
109
if (patch < 0 ) throw ArgumentError ('Patch version must be non-negative.' );
0 commit comments