Skip to content

Commit 07c5ebc

Browse files
authored
[web] Fix kIsWeb for Dart2wasm. (#112122)
1 parent 90d79aa commit 07c5ebc

File tree

5 files changed

+7
-12
lines changed

5 files changed

+7
-12
lines changed

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,4 @@ const bool kDebugMode = !kReleaseMode && !kProfileMode;
6868
const double precisionErrorTolerance = 1e-10;
6969

7070
/// A constant that is true if the application was compiled to run on the web.
71-
///
72-
/// This implementation takes advantage of the fact that JavaScript does not
73-
/// support integers. In this environment, Dart's doubles and ints are
74-
/// backed by the same kind of object. Thus a double `0.0` is identical
75-
/// to an integer `0`. This is not true for Dart code running in AOT or on the
76-
/// VM.
77-
const bool kIsWeb = identical(0, 0.0);
71+
const bool kIsWeb = bool.fromEnvironment('dart.library.js_util');

packages/flutter/lib/src/services/platform_channel.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'dart:developer';
88
import 'package:flutter/foundation.dart';
99

1010
import '_background_isolate_binary_messenger_io.dart'
11-
if (dart.library.html) '_background_isolate_binary_messenger_web.dart';
11+
if (dart.library.js_util) '_background_isolate_binary_messenger_web.dart';
1212

1313
import 'binary_messenger.dart';
1414
import 'binding.dart';
@@ -17,7 +17,7 @@ import 'message_codec.dart';
1717
import 'message_codecs.dart';
1818

1919
export '_background_isolate_binary_messenger_io.dart'
20-
if (dart.library.html) '_background_isolate_binary_messenger_web.dart';
20+
if (dart.library.js_util) '_background_isolate_binary_messenger_web.dart';
2121

2222
export 'binary_messenger.dart' show BinaryMessenger;
2323
export 'binding.dart' show RootIsolateToken;

packages/flutter/lib/src/widgets/platform_selectable_region_context_menu.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
export '_platform_selectable_region_context_menu_io.dart' if(dart.library.html) '_platform_selectable_region_context_menu_web.dart';
5+
export '_platform_selectable_region_context_menu_io.dart'
6+
if (dart.library.js_util) '_platform_selectable_region_context_menu_web.dart';

packages/flutter/test/dart/browser_environment_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import 'package:flutter_test/flutter_test.dart';
1111
// Originally here: https://github.com/flutter/engine/pull/28808
1212
void main() {
1313
test('Web library environment define exists', () {
14-
expect(const bool.fromEnvironment('dart.library.html'), isTrue);
14+
expect(const bool.fromEnvironment('dart.library.js_util'), isTrue);
1515
expect(const bool.fromEnvironment('dart.library.someFooLibrary'), isFalse);
1616
});
1717
}

packages/flutter/test/painting/network_image_web_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// found in the LICENSE file.
44

55
import '_network_image_web_test_io.dart'
6-
if (dart.library.html) '_network_image_test_web.dart';
6+
if (dart.library.js_util) '_network_image_test_web.dart';
77

88
void main() {
99
runTests();

0 commit comments

Comments
 (0)