@@ -214,32 +214,31 @@ BuildMode nativeAssetsBuildMode(build_info.BuildMode buildMode) {
214214///
215215/// Native asset builds cannot be run without a package config. If there is
216216/// no package config, leave a logging trace about that.
217- Future <bool > hasNoPackageConfig (NativeAssetsBuildRunner buildRunner) async {
217+ Future <bool > _hasNoPackageConfig (NativeAssetsBuildRunner buildRunner) async {
218218 final bool packageConfigExists = await buildRunner.hasPackageConfig ();
219219 if (! packageConfigExists) {
220220 globals.logger.printTrace ('No package config found. Skipping native assets compilation.' );
221221 }
222222 return ! packageConfigExists;
223223}
224224
225- /// Checks that if native assets is disabled, none of the dependencies declare
226- /// native assets.
227- ///
228- /// If any of the dependencies have native assets, but native assets are
229- /// disabled, exits the tool.
230- Future <bool > isDisabledAndNoNativeAssets (NativeAssetsBuildRunner buildRunner) async {
231- if (featureFlags.isNativeAssetsEnabled) {
225+ Future <bool > nativeBuildRequired (NativeAssetsBuildRunner buildRunner) async {
226+ if (await _hasNoPackageConfig (buildRunner)) {
232227 return false ;
233228 }
234229 final List <Package > packagesWithNativeAssets = await buildRunner.packagesWithNativeAssets ();
235230 if (packagesWithNativeAssets.isEmpty) {
236- return true ;
231+ return false ;
237232 }
238- final String packageNames = packagesWithNativeAssets.map ((Package p) => p.name).join (' ' );
239- throwToolExit (
240- 'Package(s) $packageNames require the native assets feature to be enabled. '
241- 'Enable using `flutter config --enable-native-assets`.' ,
242- );
233+
234+ if (! featureFlags.isNativeAssetsEnabled) {
235+ final String packageNames = packagesWithNativeAssets.map ((Package p) => p.name).join (' ' );
236+ throwToolExit (
237+ 'Package(s) $packageNames require the native assets feature to be enabled. '
238+ 'Enable using `flutter config --enable-native-assets`.' ,
239+ );
240+ }
241+ return true ;
243242}
244243
245244/// Ensures that either this project has no native assets, or that native assets
@@ -252,7 +251,7 @@ Future<void> ensureNoNativeAssetsOrOsIsSupported(
252251 FileSystem fileSystem,
253252 NativeAssetsBuildRunner buildRunner,
254253) async {
255- if (await hasNoPackageConfig (buildRunner)) {
254+ if (await _hasNoPackageConfig (buildRunner)) {
256255 return ;
257256 }
258257 final List <Package > packagesWithNativeAssets = await buildRunner.packagesWithNativeAssets ();
@@ -345,12 +344,7 @@ Future<Uri?> dryRunNativeAssets({
345344 buildRunner: buildRunner,
346345 );
347346 } else {
348- await ensureNoNativeAssetsOrOsIsSupported (
349- projectUri,
350- const LocalPlatform ().operatingSystem,
351- fileSystem,
352- buildRunner,
353- );
347+ await nativeBuildRequired (buildRunner);
354348 nativeAssetsYaml = null ;
355349 }
356350 case build_info.TargetPlatform .linux_arm64:
@@ -389,7 +383,7 @@ Future<Uri?> dryRunNativeAssetsMultipeOSes({
389383 required FileSystem fileSystem,
390384 required Iterable <build_info.TargetPlatform > targetPlatforms,
391385}) async {
392- if (await hasNoPackageConfig (buildRunner) || await isDisabledAndNoNativeAssets (buildRunner)) {
386+ if (await nativeBuildRequired (buildRunner)) {
393387 return null ;
394388 }
395389
0 commit comments