mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
[web] Fix kIsWeb
for Dart2wasm. (#112122)
This commit is contained in:
parent
90d79aa388
commit
07c5ebca78
@ -68,10 +68,4 @@ const bool kDebugMode = !kReleaseMode && !kProfileMode;
|
|||||||
const double precisionErrorTolerance = 1e-10;
|
const double precisionErrorTolerance = 1e-10;
|
||||||
|
|
||||||
/// A constant that is true if the application was compiled to run on the web.
|
/// A constant that is true if the application was compiled to run on the web.
|
||||||
///
|
const bool kIsWeb = bool.fromEnvironment('dart.library.js_util');
|
||||||
/// This implementation takes advantage of the fact that JavaScript does not
|
|
||||||
/// support integers. In this environment, Dart's doubles and ints are
|
|
||||||
/// backed by the same kind of object. Thus a double `0.0` is identical
|
|
||||||
/// to an integer `0`. This is not true for Dart code running in AOT or on the
|
|
||||||
/// VM.
|
|
||||||
const bool kIsWeb = identical(0, 0.0);
|
|
||||||
|
@ -8,7 +8,7 @@ import 'dart:developer';
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
import '_background_isolate_binary_messenger_io.dart'
|
import '_background_isolate_binary_messenger_io.dart'
|
||||||
if (dart.library.html) '_background_isolate_binary_messenger_web.dart';
|
if (dart.library.js_util) '_background_isolate_binary_messenger_web.dart';
|
||||||
|
|
||||||
import 'binary_messenger.dart';
|
import 'binary_messenger.dart';
|
||||||
import 'binding.dart';
|
import 'binding.dart';
|
||||||
@ -17,7 +17,7 @@ import 'message_codec.dart';
|
|||||||
import 'message_codecs.dart';
|
import 'message_codecs.dart';
|
||||||
|
|
||||||
export '_background_isolate_binary_messenger_io.dart'
|
export '_background_isolate_binary_messenger_io.dart'
|
||||||
if (dart.library.html) '_background_isolate_binary_messenger_web.dart';
|
if (dart.library.js_util) '_background_isolate_binary_messenger_web.dart';
|
||||||
|
|
||||||
export 'binary_messenger.dart' show BinaryMessenger;
|
export 'binary_messenger.dart' show BinaryMessenger;
|
||||||
export 'binding.dart' show RootIsolateToken;
|
export 'binding.dart' show RootIsolateToken;
|
||||||
|
@ -2,4 +2,5 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
export '_platform_selectable_region_context_menu_io.dart' if(dart.library.html) '_platform_selectable_region_context_menu_web.dart';
|
export '_platform_selectable_region_context_menu_io.dart'
|
||||||
|
if (dart.library.js_util) '_platform_selectable_region_context_menu_web.dart';
|
||||||
|
@ -11,7 +11,7 @@ import 'package:flutter_test/flutter_test.dart';
|
|||||||
// Originally here: https://github.com/flutter/engine/pull/28808
|
// Originally here: https://github.com/flutter/engine/pull/28808
|
||||||
void main() {
|
void main() {
|
||||||
test('Web library environment define exists', () {
|
test('Web library environment define exists', () {
|
||||||
expect(const bool.fromEnvironment('dart.library.html'), isTrue);
|
expect(const bool.fromEnvironment('dart.library.js_util'), isTrue);
|
||||||
expect(const bool.fromEnvironment('dart.library.someFooLibrary'), isFalse);
|
expect(const bool.fromEnvironment('dart.library.someFooLibrary'), isFalse);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import '_network_image_web_test_io.dart'
|
import '_network_image_web_test_io.dart'
|
||||||
if (dart.library.html) '_network_image_test_web.dart';
|
if (dart.library.js_util) '_network_image_test_web.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runTests();
|
runTests();
|
||||||
|
Loading…
Reference in New Issue
Block a user