Skip to content

Commit c0b2645

Browse files
authored
Use const bool.fromEnvironment("dart.tool.dart2wasm") to detect dart2wasm (#149996)
Dart2Wasm doesn't officially support `dart:ffi` (only a small sketchy subset needed in flutter web engine). We have seen user reporting issues where existing packages don't work with dart2wasm due to using `dart.library.ffi` in `bool.fromEnvironment` or in conditional imports and it doing the wrong thing. So we're going to make `dart.library.ffi` `false` in the compiler. We therefore update the code to detect whether it runs under wasm via a new `dart.tool.dart2wasm` environment variable. This is a preparation for the change in dart2wasm which will start making `const bool.fromEnvironment('dart.library.ffi')` return `false` instead of `true`.
1 parent 03b487b commit c0b2645

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/flutter/lib/src/foundation/constants.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,4 @@ const bool kIsWeb = bool.fromEnvironment('dart.library.js_util');
8989
/// in tests with [debugDefaultTargetPlatformOverride].
9090
/// * [dart:io.Platform], a way to find out the browser's platform that is not
9191
/// overridable in tests.
92-
const bool kIsWasm = kIsWeb && bool.fromEnvironment('dart.library.ffi');
92+
const bool kIsWasm = bool.fromEnvironment('dart.tool.dart2wasm');

0 commit comments

Comments
 (0)