55import '../config.dart' ;
66import '../encoded_asset.dart' ;
77import 'architecture.dart' ;
8+ import 'config.dart' ;
89import 'link_mode.dart' ;
910import 'os.dart' ;
1011import 'syntax.g.dart' as syntax;
@@ -34,31 +35,30 @@ import 'syntax.g.dart' as syntax;
3435/// * Assets which designate symbols present in the target system
3536/// ([DynamicLoadingSystem] ), process ([LookupInProcess] ), or executable
3637/// ([LookupInExecutable] ). These assets do not have a [file] .
37- /// * Dynamic libraries bundled into the application
38- /// ([DynamicLoadingBundled] ). These assets must provide a [file] to be
39- /// bundled.
38+ /// * Dynamic libraries bundled into the application ([DynamicLoadingBundled] ).
39+ /// These assets must provide a [file] to be bundled.
4040///
41- /// An application is compiled to run on a specific target [os] and
42- /// [architecture] . Different targets require different assets, so the package
43- /// developer must specify which asset to bundle for which target.
41+ /// An application is compiled to run on a specific target [CodeConfig.targetOS]
42+ /// and [CodeConfig.targetArchitecture] . Different targets require different
43+ /// assets, so the package developer must specify which asset to bundle for
44+ /// which target.
4445///
4546/// An asset has different ways of being accessible in the final application. It
4647/// is either brought in "manually" by having the package developer specify a
4748/// [file] path of the asset on the current system, it can be part of the Dart
4849/// or Flutter SDK ([LookupInProcess] ), or it can be already present in the
49- /// target system ([DynamicLoadingSystem] ). If the asset is bundled
50- /// "manually", the Dart or Flutter SDK will take care of copying the asset
51- /// [file] from its specified location on the current system into the
52- /// application bundle.
50+ /// target system ([DynamicLoadingSystem] ). If the asset is bundled "manually",
51+ /// the Dart or Flutter SDK will take care of copying the asset [file] from its
52+ /// specified location on the current system into the application bundle.
5353final class CodeAsset {
5454 /// The id of this code asset.
5555 final String id;
5656
5757 /// The operating system this asset can run on.
58- final OS os ;
58+ final OS _os ;
5959
6060 /// The architecture this asset can run on.
61- final Architecture architecture ;
61+ final Architecture _architecture ;
6262
6363 /// The link mode for this native code.
6464 ///
@@ -99,10 +99,11 @@ final class CodeAsset {
9999 CodeAsset ._({
100100 required this .id,
101101 required this .linkMode,
102- required this . os,
102+ required OS os,
103103 required this .file,
104- required this .architecture,
105- });
104+ required Architecture architecture,
105+ }) : _architecture = architecture,
106+ _os = os;
106107
107108 factory CodeAsset .fromEncoded (EncodedAsset asset) {
108109 assert (asset.type == CodeAsset .type);
@@ -128,8 +129,8 @@ final class CodeAsset {
128129 }) => CodeAsset ._(
129130 id: id ?? this .id,
130131 linkMode: linkMode ?? this .linkMode,
131- os: os ?? this .os ,
132- architecture: architecture ?? this .architecture ,
132+ os: os ?? _os ,
133+ architecture: architecture ?? _architecture ,
133134 file: file ?? this .file,
134135 );
135136
@@ -140,28 +141,36 @@ final class CodeAsset {
140141 }
141142 return other.id == id &&
142143 other.linkMode == linkMode &&
143- other.architecture == architecture &&
144- other.os == os &&
144+ other._architecture == _architecture &&
145+ other._os == _os &&
145146 other.file == file;
146147 }
147148
148149 @override
149- int get hashCode => Object .hash (id, linkMode, architecture, os , file);
150+ int get hashCode => Object .hash (id, linkMode, _architecture, _os , file);
150151
151152 EncodedAsset encode () {
152153 final encoding = syntax.NativeCodeAssetEncoding (
153- architecture: architecture .toSyntax (),
154+ architecture: _architecture .toSyntax (),
154155 file: file,
155156 id: id,
156157 linkMode: linkMode.toSyntax (),
157- os: os.toSyntax (),
158+
159+ os: _os.toSyntax (),
158160 );
159161 return EncodedAsset (CodeAsset .type, encoding.json);
160162 }
161163
162164 static const String type = 'native_code' ;
163165}
164166
167+ // These field will be removed in the future, prevent anyone from reading them.
168+ extension ForValidationOnly on CodeAsset {
169+ OS get os => _os;
170+
171+ Architecture get architecture => _architecture;
172+ }
173+
165174extension OSLibraryNaming on OS {
166175 /// The default dynamic library file name on this os.
167176 String dylibFileName (String name) {
0 commit comments