[flutter_tools] null assertions off by default for web (#64186)

Like Android/iOS, only enable --null-assertions if asked. Previously this was enabled by default for web, but in general this has proved to be too breaking to enable by default.

#61042
This commit is contained in:
Jonah Williams
2020-08-19 14:52:47 -07:00
committed by GitHub
parent ae4b3ba2d1
commit 69fd5c50a2
6 changed files with 14 additions and 7 deletions

View File

@@ -636,6 +636,7 @@ class WebDevFS implements DevFS {
@required this.entrypoint,
@required this.expressionCompiler,
@required this.chromiumLauncher,
@required this.nullAssertions,
this.testMode = false,
});
@@ -651,6 +652,7 @@ class WebDevFS implements DevFS {
final bool testMode;
final ExpressionCompiler expressionCompiler;
final ChromiumLauncher chromiumLauncher;
final bool nullAssertions;
WebAssetServer webAssetServer;
@@ -791,8 +793,7 @@ class WebDevFS implements DevFS {
'main_module.bootstrap.js',
generateMainModule(
entrypoint: entrypoint,
nullSafety: buildInfo.extraFrontEndOptions
?.contains('--enable-experiment=non-nullable') ?? false,
nullAssertions: nullAssertions,
),
);
// TODO(jonahwilliams): refactor the asset code in this and the regular devfs to

View File

@@ -469,6 +469,7 @@ class _ResidentWebRunner extends ResidentWebRunner {
entrypoint: globals.fs.file(target).uri,
expressionCompiler: expressionCompiler,
chromiumLauncher: _chromiumLauncher,
nullAssertions: debuggingOptions.nullAssertions,
);
final Uri url = await device.devFS.create();
if (debuggingOptions.buildInfo.isDebug) {

View File

@@ -50,14 +50,14 @@ document.head.appendChild(requireEl);
/// this object is the module.
String generateMainModule({
@required String entrypoint,
@required bool nullSafety,
@required bool nullAssertions,
}) {
return '''/* ENTRYPOINT_EXTENTION_MARKER */
// Create the main module loaded below.
define("main_module.bootstrap", ["$entrypoint", "dart_sdk"], function(app, dart_sdk) {
dart_sdk.dart.setStartAsyncSynchronously(true);
dart_sdk._debugger.registerDevtoolsFormatter();
if ($nullSafety) {
if ($nullAssertions) {
dart_sdk.dart.nonNullAsserts(true);
}