diff --git a/sdk/lib/_internal/js_dev_runtime/patch/math_patch.dart b/sdk/lib/_internal/js_dev_runtime/patch/math_patch.dart index 288f66e838dc..fe52156c96f6 100644 --- a/sdk/lib/_internal/js_dev_runtime/patch/math_patch.dart +++ b/sdk/lib/_internal/js_dev_runtime/patch/math_patch.dart @@ -67,14 +67,14 @@ const int _POW2_32 = 0x100000000; @patch class Random { - static Random? _secureRandom; + static final Random _secureRandom = _JSSecureRandom(); @patch factory Random([int? seed]) => (seed == null) ? const _JSRandom() : _Random(seed); @patch - factory Random.secure() => _secureRandom ??= _JSSecureRandom(); + factory Random.secure() => _secureRandom; } class _JSRandom implements Random { diff --git a/sdk/lib/_internal/js_runtime/lib/math_patch.dart b/sdk/lib/_internal/js_runtime/lib/math_patch.dart index 585f4c5aec48..64236b30932f 100644 --- a/sdk/lib/_internal/js_runtime/lib/math_patch.dart +++ b/sdk/lib/_internal/js_runtime/lib/math_patch.dart @@ -63,14 +63,14 @@ const int _POW2_32 = 0x100000000; @patch class Random { - static Random? _secureRandom; + static final Random _secureRandom = _JSSecureRandom(); @patch factory Random([int? seed]) => - (seed == null) ? const _JSRandom() : new _Random(seed); + (seed == null) ? const _JSRandom() : _Random(seed); @patch - factory Random.secure() => _secureRandom ??= _JSSecureRandom(); + factory Random.secure() => _secureRandom; } class _JSRandom implements Random {