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

fix: Pubspec.environment can never be null #137

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
- Set `Pubspec.environment` to non-nullable.
- Remove deprecated package_api_docs rule

## 1.3.0
Expand Down
7 changes: 4 additions & 3 deletions lib/src/pubspec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Pubspec {
final String? documentation;

@JsonKey(fromJson: _environmentMap)
final Map<String, VersionConstraint?>? environment;
final Map<String, VersionConstraint?> environment;

@JsonKey(fromJson: parseDeps)
final Map<String, Dependency> dependencies;
Expand Down Expand Up @@ -186,7 +186,7 @@ class Pubspec {
Version? _versionFromString(String? input) =>
input == null ? null : Version.parse(input);

Map<String, VersionConstraint?>? _environmentMap(Map? source) =>
Map<String, VersionConstraint?> _environmentMap(Map? source) =>
source?.map((k, value) {
final key = k as String;
if (key == 'dart') {
Expand Down Expand Up @@ -222,4 +222,5 @@ Map<String, VersionConstraint?>? _environmentMap(Map? source) =>
}

return MapEntry(key, constraint);
});
}) ??
{};