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

Commit 74c350c

Browse files
authored
fix: Pubspec.environment can never be null (#137)
* fix: Pubspec.environment can never be null * chore: Add changelog entry * fix: _environmentMap to return empty map when input is null
1 parent 16562e4 commit 74c350c

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## 1.3.1-wip
22

33
- Require Dart 3.2
4+
- Set `Pubspec.environment` to non-nullable.
45
- Remove deprecated package_api_docs rule
56

67
## 1.3.0

lib/src/pubspec.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class Pubspec {
7474
final String? documentation;
7575

7676
@JsonKey(fromJson: _environmentMap)
77-
final Map<String, VersionConstraint?>? environment;
77+
final Map<String, VersionConstraint?> environment;
7878

7979
@JsonKey(fromJson: parseDeps)
8080
final Map<String, Dependency> dependencies;
@@ -186,7 +186,7 @@ class Pubspec {
186186
Version? _versionFromString(String? input) =>
187187
input == null ? null : Version.parse(input);
188188

189-
Map<String, VersionConstraint?>? _environmentMap(Map? source) =>
189+
Map<String, VersionConstraint?> _environmentMap(Map? source) =>
190190
source?.map((k, value) {
191191
final key = k as String;
192192
if (key == 'dart') {
@@ -222,4 +222,5 @@ Map<String, VersionConstraint?>? _environmentMap(Map? source) =>
222222
}
223223

224224
return MapEntry(key, constraint);
225-
});
225+
}) ??
226+
{};

0 commit comments

Comments
 (0)