From 38e0c25823e28fc778d1014125f3324a42ef7e9c Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Wed, 19 Aug 2020 13:25:42 -0700 Subject: [PATCH] [flutter_tools] reland: enable --null-assertions for flutter framework tests (#64120) Reland of acdb909 with fixes to semantics.dart #61042 --- dev/bots/test.dart | 2 +- .../flutter/lib/src/rendering/proxy_box.dart | 2 +- .../lib/src/services/raw_keyboard_web.dart | 4 ++-- .../test/painting/text_painter_test.dart | 2 +- .../flutter/test/painting/text_span_test.dart | 21 ++----------------- 5 files changed, 7 insertions(+), 24 deletions(-) diff --git a/dev/bots/test.dart b/dev/bots/test.dart index c568e1341e8..8d8a04ddf94 100644 --- a/dev/bots/test.dart +++ b/dev/bots/test.dart @@ -538,7 +538,7 @@ Future _runAddToAppLifeCycleTests() async { Future _runFrameworkTests() async { final bq.BigqueryApi bigqueryApi = await _getBigqueryApi(); - final List nullSafetyOptions = ['--enable-experiment=non-nullable']; + final List nullSafetyOptions = ['--enable-experiment=non-nullable', '--null-assertions']; final List trackWidgetCreationAlternatives = ['--track-widget-creation', '--no-track-widget-creation']; Future runWidgets() async { diff --git a/packages/flutter/lib/src/rendering/proxy_box.dart b/packages/flutter/lib/src/rendering/proxy_box.dart index b83f1b10546..1b098ab8ef3 100644 --- a/packages/flutter/lib/src/rendering/proxy_box.dart +++ b/packages/flutter/lib/src/rendering/proxy_box.dart @@ -3624,7 +3624,7 @@ class RenderSemanticsAnnotations extends RenderProxyBox { RenderSemanticsAnnotations({ RenderBox child, bool container = false, - bool explicitChildNodes, + bool explicitChildNodes = false, bool excludeSemantics = false, bool enabled, bool checked, diff --git a/packages/flutter/lib/src/services/raw_keyboard_web.dart b/packages/flutter/lib/src/services/raw_keyboard_web.dart index c933b7bade5..77b399efcd5 100644 --- a/packages/flutter/lib/src/services/raw_keyboard_web.dart +++ b/packages/flutter/lib/src/services/raw_keyboard_web.dart @@ -36,7 +36,7 @@ class RawKeyEventDataWeb extends RawKeyEventData { /// /// See /// for more information. - final String key; + final String? key; /// The modifiers that were present when the key event occurred. /// @@ -56,7 +56,7 @@ class RawKeyEventDataWeb extends RawKeyEventData { final int metaState; @override - String get keyLabel => key; + String? get keyLabel => key; @override PhysicalKeyboardKey get physicalKey { diff --git a/packages/flutter/test/painting/text_painter_test.dart b/packages/flutter/test/painting/text_painter_test.dart index 3eafef984f0..5d106213c0b 100644 --- a/packages/flutter/test/painting/text_painter_test.dart +++ b/packages/flutter/test/painting/text_painter_test.dart @@ -149,7 +149,7 @@ void main() { test('TextPainter error test', () { final TextPainter painter = TextPainter(textDirection: TextDirection.ltr); - expect(() { painter.paint(null, Offset.zero); }, throwsFlutterError); + expect(() { painter.paint(null, Offset.zero); }, anyOf(throwsFlutterError, throwsAssertionError)); }); test('TextPainter requires textDirection', () { diff --git a/packages/flutter/test/painting/text_span_test.dart b/packages/flutter/test/painting/text_span_test.dart index 039dcbcbf95..66bd8e092b2 100644 --- a/packages/flutter/test/painting/text_span_test.dart +++ b/packages/flutter/test/painting/text_span_test.dart @@ -6,8 +6,7 @@ import 'package:flutter/painting.dart'; import 'package:flutter/widgets.dart'; - -import '../flutter_test_alternative.dart'; +import 'package:flutter_test/flutter_test.dart'; void main() { test('TextSpan equals', () { @@ -44,7 +43,6 @@ void main() { TextSpan(), ], ), - null, TextSpan( text: 'c', ), @@ -59,7 +57,6 @@ void main() { ' "b"\n' ' TextSpan:\n' ' (empty)\n' - ' \n' ' TextSpan:\n' ' "c"\n' )); @@ -245,21 +242,7 @@ void main() { null, ], ); - FlutterError error; - try { - text.computeToPlainText(StringBuffer()); - } on FlutterError catch (e) { - error = e; - } - expect(error, isNotNull); - expect(error.toStringDeep(), - 'FlutterError\n' - ' TextSpan contains a null child.\n' - ' A TextSpan object with a non-null child list should not have any\n' - ' nulls in its child list.\n' - ' The full text in question was:\n' - ' TextSpan("foo bar")\n' - ); + expect(() => text.computeToPlainText(StringBuffer()), anyOf(throwsFlutterError, throwsAssertionError)); }); }