@@ -221,17 +221,28 @@ class FlutterNativeAssetsBuildRunnerImpl implements FlutterNativeAssetsBuildRunn
221221 }
222222 });
223223
224- late final Uri _dartExecutable = fileSystem.directory (Cache .flutterRoot).uri.resolve ('bin/dart' );
224+ // Flutter wraps the Dart executable to update it in place
225+ // ($FLUTTER_ROOT/bin/dart). However, since this is a Dart process invocation
226+ // in a Flutter process invocation, it should not try to update in place, so
227+ // use the Dart standalone executable
228+ // ($FLUTTER_ROOT/bin/cache/dart-sdk/bin/dart).
229+ late final Uri _dartExecutable = fileSystem
230+ .directory (Cache .flutterRoot)
231+ .uri
232+ .resolve ('bin/cache/dart-sdk/bin/dart' );
225233
226234 late final NativeAssetsBuildRunner _buildRunner = NativeAssetsBuildRunner (
227235 logger: _logger,
228236 dartExecutable: _dartExecutable,
229237 fileSystem: fileSystem,
230- // TODO(dcharkes): Filter the environment with
231- // NativeAssetsBuildRunner.hookEnvironmentVariablesFilter.
232- hookEnvironment: const LocalPlatform ().environment,
238+ hookEnvironment: filteredEnvironment (NativeAssetsBuildRunner .hookEnvironmentVariablesFilter),
233239 );
234240
241+ static Map <String , String > filteredEnvironment (Set <String > allowList) => < String , String > {
242+ for (final MapEntry <String , String > entry in const LocalPlatform ().environment.entries)
243+ if (allowList.contains (entry.key.toUpperCase ())) entry.key: entry.value,
244+ };
245+
235246 @override
236247 Future <bool > hasPackageConfig () {
237248 return fileSystem.file (packageConfigPath).exists ();
0 commit comments