diff --git a/pkgs/native_assets_cli/CHANGELOG.md b/pkgs/native_assets_cli/CHANGELOG.md index 27462e51a..0159aabd4 100644 --- a/pkgs/native_assets_cli/CHANGELOG.md +++ b/pkgs/native_assets_cli/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.3.2 + +- Fixed an issue where `Depenendencies.dependencies` could not be + modified when expected to. + ## 0.3.1 - Added `Target.androidRiscv64`. diff --git a/pkgs/native_assets_cli/lib/src/model/build_output.dart b/pkgs/native_assets_cli/lib/src/model/build_output.dart index 20dc0c6eb..6f88407cc 100644 --- a/pkgs/native_assets_cli/lib/src/model/build_output.dart +++ b/pkgs/native_assets_cli/lib/src/model/build_output.dart @@ -33,8 +33,10 @@ class BuildOutput { Metadata? metadata, }) : timestamp = (timestamp ?? DateTime.now()).roundDownToSeconds(), assets = assets ?? [], - dependencies = dependencies ?? const Dependencies([]), - metadata = metadata ?? const Metadata({}); + // ignore: prefer_const_constructors + dependencies = dependencies ?? Dependencies([]), + // ignore: prefer_const_constructors + metadata = metadata ?? Metadata({}); static const _assetsKey = 'assets'; static const _dependenciesKey = 'dependencies'; diff --git a/pkgs/native_assets_cli/lib/src/model/dependencies.dart b/pkgs/native_assets_cli/lib/src/model/dependencies.dart index 4db792a69..9ecc2cb91 100644 --- a/pkgs/native_assets_cli/lib/src/model/dependencies.dart +++ b/pkgs/native_assets_cli/lib/src/model/dependencies.dart @@ -10,6 +10,7 @@ import '../utils/uri.dart'; import '../utils/yaml.dart'; class Dependencies { + /// The dependencies a build relied on. final List dependencies; const Dependencies(this.dependencies); @@ -19,7 +20,8 @@ class Dependencies { if (yaml is YamlList) { return Dependencies.fromYaml(yaml); } - return const Dependencies([]); + // ignore: prefer_const_constructors + return Dependencies([]); } factory Dependencies.fromYaml(YamlList? yamlList) => Dependencies([ diff --git a/pkgs/native_assets_cli/pubspec.yaml b/pkgs/native_assets_cli/pubspec.yaml index 47149e533..1c944d73a 100644 --- a/pkgs/native_assets_cli/pubspec.yaml +++ b/pkgs/native_assets_cli/pubspec.yaml @@ -2,7 +2,7 @@ name: native_assets_cli description: >- A library that contains the argument and file formats for implementing a native assets CLI. -version: 0.3.1 +version: 0.3.2 repository: https://github.com/dart-lang/native/tree/main/pkgs/native_assets_cli topics: diff --git a/pkgs/native_assets_cli/test/model/build_output_test.dart b/pkgs/native_assets_cli/test/model/build_output_test.dart index ef23bb872..0dc0bad27 100644 --- a/pkgs/native_assets_cli/test/model/build_output_test.dart +++ b/pkgs/native_assets_cli/test/model/build_output_test.dart @@ -159,4 +159,15 @@ version: ${BuildOutput.version}'''), throwsFormatException, ); }); + + test('BuildOutput dependencies can be modified', () { + // TODO(https://github.com/dart-lang/native/issues/25): + // Remove once dependencies are made immutable. + final buildOutput = BuildOutput(); + expect( + () => buildOutput.dependencies.dependencies + .add(Uri.file('path/to/file.ext')), + returnsNormally, + ); + }); }