Skip to content

Commit ce3cd20

Browse files
authored
Fix isWeb check for WASM (#1249)
1 parent b5f0119 commit ce3cd20

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Fixes
6+
7+
- isWeb check for WASM ([#1249](https://github.com/getsentry/sentry-dart/pull/1249))
8+
39
## 7.0.0-alpha.5
410

511
### Features

dart/lib/src/platform_checker.dart

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import 'platform/platform.dart';
33
/// Helper to check in which enviroment the library is running.
44
/// The envirment checks (release/debug/profile) are mutually exclusive.
55
class PlatformChecker {
6-
const PlatformChecker({
6+
static const _jsUtil = 'dart.library.js_util';
7+
8+
PlatformChecker({
79
this.platform = instance,
8-
this.isWeb = identical(0, 0.0),
9-
});
10+
bool? isWeb,
11+
}) : isWeb = isWeb ?? _isWebWithWasmSupport();
1012

1113
/// Check if running in release/production environment
1214
bool isReleaseMode() {
@@ -48,5 +50,12 @@ class PlatformChecker {
4850
return false;
4951
}
5052

53+
static bool _isWebWithWasmSupport() {
54+
if (const bool.hasEnvironment(_jsUtil)) {
55+
return const bool.fromEnvironment(_jsUtil);
56+
}
57+
return identical(0, 0.0);
58+
}
59+
5160
final Platform platform;
5261
}

0 commit comments

Comments
 (0)