Migrate web_e2e_tests to null safety (#80628)
diff --git a/dev/integration_tests/web_e2e_tests/lib/text_editing_main.dart b/dev/integration_tests/web_e2e_tests/lib/text_editing_main.dart
index a19902f..45a6f97 100644
--- a/dev/integration_tests/web_e2e_tests/lib/text_editing_main.dart
+++ b/dev/integration_tests/web_e2e_tests/lib/text_editing_main.dart
@@ -7,7 +7,7 @@
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
- const MyApp({Key key}) : super(key: key);
+ const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
@@ -20,9 +20,9 @@
}
class MyHomePage extends StatefulWidget {
- const MyHomePage({Key key, this.title}) : super(key: key);
+ const MyHomePage({Key? key, this.title}) : super(key: key);
- final String title;
+ final String? title;
@override
_MyHomePageState createState() => _MyHomePageState();
@@ -44,7 +44,7 @@
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
- title: Text(widget.title),
+ title: Text(widget.title ?? ''),
),
body: Center(
child: Column(
diff --git a/dev/integration_tests/web_e2e_tests/pubspec.yaml b/dev/integration_tests/web_e2e_tests/pubspec.yaml
index 445e2f5..13a2417 100644
--- a/dev/integration_tests/web_e2e_tests/pubspec.yaml
+++ b/dev/integration_tests/web_e2e_tests/pubspec.yaml
@@ -2,7 +2,7 @@
publish_to: none
environment:
- sdk: ">=2.2.2 <3.0.0"
+ sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
diff --git a/dev/integration_tests/web_e2e_tests/test_driver/text_editing_integration.dart b/dev/integration_tests/web_e2e_tests/test_driver/text_editing_integration.dart
index 8afd752..ef84b1b 100644
--- a/dev/integration_tests/web_e2e_tests/test_driver/text_editing_integration.dart
+++ b/dev/integration_tests/web_e2e_tests/test_driver/text_editing_integration.dart
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// @dart = 2.9
import 'dart:html';
import 'dart:js_util' as js_util;
@@ -39,7 +38,7 @@
// Change the value of the TextFormField.
final TextFormField textFormField = tester.widget(finder);
- textFormField.controller.text = 'New Value';
+ textFormField.controller?.text = 'New Value';
// DOM element's value also changes.
expect(input.value, 'New Value');
});
@@ -67,7 +66,7 @@
// Change the value of the TextFormField.
final TextFormField textFormField = tester.widget(finder);
- textFormField.controller.text = 'New Value';
+ textFormField.controller?.text = 'New Value';
// DOM element's value also changes.
expect(input.value, 'New Value');
});
@@ -225,8 +224,8 @@
expect(input.hasAttribute('readonly'), isTrue);
// Make sure the entire text is selected.
- TextRange range =
- TextRange(start: input.selectionStart, end: input.selectionEnd);
+ TextRange? range =
+ TextRange(start: input.selectionStart!, end: input.selectionEnd!);
expect(range.textInside(text), text);
// Double tap to select the first word.
@@ -239,7 +238,7 @@
await gesture.up();
await gesture.down(firstWordOffset);
await gesture.up();
- range = TextRange(start: input.selectionStart, end: input.selectionEnd);
+ range = TextRange(start: input.selectionStart!, end: input.selectionEnd!);
expect(range.textInside(text), 'Lorem');
// Double tap to select the last word.
@@ -252,14 +251,14 @@
await gesture.up();
await gesture.down(lastWordOffset);
await gesture.up();
- range = TextRange(start: input.selectionStart, end: input.selectionEnd);
+ range = TextRange(start: input.selectionStart!, end: input.selectionEnd!);
expect(range.textInside(text), 'amet');
});
}
KeyboardEvent dispatchKeyboardEvent(
EventTarget target, String type, Map<String, dynamic> args) {
- final dynamic jsKeyboardEvent = js_util.getProperty(window, 'KeyboardEvent');
+ final Object jsKeyboardEvent = js_util.getProperty(window, 'KeyboardEvent') as Object;
final List<dynamic> eventArgs = <dynamic>[
type,
args,
diff --git a/dev/integration_tests/web_e2e_tests/test_driver/text_editing_integration_test.dart b/dev/integration_tests/web_e2e_tests/test_driver/text_editing_integration_test.dart
index 94f9938..b2d2a17 100644
--- a/dev/integration_tests/web_e2e_tests/test_driver/text_editing_integration_test.dart
+++ b/dev/integration_tests/web_e2e_tests/test_driver/text_editing_integration_test.dart
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// @dart = 2.9
import 'package:integration_test/integration_test_driver.dart' as test;
Future<void> main() async => test.integrationDriver();