sentry-dart
sentry-dart copied to clipboard
Make `isWeb` check compatible with WASM
Description
This check here
https://github.com/getsentry/sentry-dart/blob/ab3023814195ce35814d3c87ed0fb09a2e255d7e/dart/lib/src/platform_checker.dart#L8
needs to be made compatible with WASM. Otherwise, it might report the wrong value.
See also https://github.com/flutter/flutter/pull/112122
I guess something like the following code might work while keeping it backwards compatible with earlier Dart/Flutter versions:
bool isWeb() {
if(bool.hasEnvironment('dart.library.js_util')) {
return bool.fromEnvironment('dart.library.js_util');
}
return identical(0, 0.0);
}
@ueman damn, what's about the conditional html import, is this a problem to WASM as well or just the isWeb check?
That's actually a very good question. I'm guessing it's just about the isWeb check for now. But when WASM for Dart/Flutter eventually gets rolled out, it should definitely be tested.