Unverified Commit e48c9b55 authored by Kate Lovett's avatar Kate Lovett Committed by GitHub

[NNBD] Migrating some Material tests (#67689)

parent d6d06ed9
...@@ -2,13 +2,11 @@ ...@@ -2,13 +2,11 @@
// 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.
// @dart = 2.8
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
MaterialApp _appWithDialog(WidgetTester tester, Widget dialog, { ThemeData theme }) { MaterialApp _appWithDialog(WidgetTester tester, Widget dialog, { ThemeData? theme }) {
return MaterialApp( return MaterialApp(
theme: theme, theme: theme,
home: Material( home: Material(
...@@ -40,7 +38,7 @@ Material _getMaterialFromDialog(WidgetTester tester) { ...@@ -40,7 +38,7 @@ Material _getMaterialFromDialog(WidgetTester tester) {
} }
RenderParagraph _getTextRenderObject(WidgetTester tester, String text) { RenderParagraph _getTextRenderObject(WidgetTester tester, String text) {
return tester.element<StatelessElement>(find.text(text)).renderObject as RenderParagraph; return tester.element<StatelessElement>(find.text(text)).renderObject! as RenderParagraph;
} }
void main() { void main() {
...@@ -184,7 +182,7 @@ void main() { ...@@ -184,7 +182,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
final RenderParagraph title = _getTextRenderObject(tester, titleText); final RenderParagraph title = _getTextRenderObject(tester, titleText);
expect(title.text.style.color, titleTextStyle.color); expect(title.text.style!.color, titleTextStyle.color);
}); });
testWidgets('Simple Dialog - Custom Title Text Style - Constructor Param', (WidgetTester tester) async { testWidgets('Simple Dialog - Custom Title Text Style - Constructor Param', (WidgetTester tester) async {
...@@ -232,7 +230,7 @@ void main() { ...@@ -232,7 +230,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
final RenderParagraph title = _getTextRenderObject(tester, titleText); final RenderParagraph title = _getTextRenderObject(tester, titleText);
expect(title.text.style.color, titleTextStyle.color); expect(title.text.style!.color, titleTextStyle.color);
}); });
testWidgets('Custom Content Text Style - Constructor Param', (WidgetTester tester) async { testWidgets('Custom Content Text Style - Constructor Param', (WidgetTester tester) async {
...@@ -283,6 +281,6 @@ void main() { ...@@ -283,6 +281,6 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
final RenderParagraph content = _getTextRenderObject(tester, contentText); final RenderParagraph content = _getTextRenderObject(tester, contentText);
expect(content.text.style.color, contentTextStyle.color); expect(content.text.style!.color, contentTextStyle.color);
}); });
} }
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/painting.dart'; import 'package:flutter/painting.dart';
...@@ -22,8 +20,8 @@ void main() { ...@@ -22,8 +20,8 @@ void main() {
final RenderBox box = tester.firstRenderObject(find.byType(Divider)); final RenderBox box = tester.firstRenderObject(find.byType(Divider));
expect(box.size.height, 16.0); expect(box.size.height, 16.0);
final Container container = tester.widget(find.byType(Container)); final Container container = tester.widget(find.byType(Container));
final BoxDecoration decoration = container.decoration as BoxDecoration; final BoxDecoration decoration = container.decoration! as BoxDecoration;
expect(decoration.border.bottom.width, 0.0); expect(decoration.border!.bottom.width, 0.0);
}); });
testWidgets('Divider custom thickness', (WidgetTester tester) async { testWidgets('Divider custom thickness', (WidgetTester tester) async {
...@@ -38,8 +36,8 @@ void main() { ...@@ -38,8 +36,8 @@ void main() {
), ),
); );
final Container container = tester.widget(find.byType(Container)); final Container container = tester.widget(find.byType(Container));
final BoxDecoration decoration = container.decoration as BoxDecoration; final BoxDecoration decoration = container.decoration! as BoxDecoration;
expect(decoration.border.bottom.width, 5.0); expect(decoration.border!.bottom.width, 5.0);
}); });
testWidgets('Horizontal divider custom indentation', (WidgetTester tester) async { testWidgets('Horizontal divider custom indentation', (WidgetTester tester) async {
...@@ -107,8 +105,8 @@ void main() { ...@@ -107,8 +105,8 @@ void main() {
final RenderBox box = tester.firstRenderObject(find.byType(VerticalDivider)); final RenderBox box = tester.firstRenderObject(find.byType(VerticalDivider));
expect(box.size.width, 16.0); expect(box.size.width, 16.0);
final Container container = tester.widget(find.byType(Container)); final Container container = tester.widget(find.byType(Container));
final BoxDecoration decoration = container.decoration as BoxDecoration; final BoxDecoration decoration = container.decoration! as BoxDecoration;
final Border border = decoration.border as Border; final Border border = decoration.border! as Border;
expect(border.left.width, 0.0); expect(border.left.width, 0.0);
}); });
...@@ -124,8 +122,8 @@ void main() { ...@@ -124,8 +122,8 @@ void main() {
), ),
); );
final Container container = tester.widget(find.byType(Container)); final Container container = tester.widget(find.byType(Container));
final BoxDecoration decoration = container.decoration as BoxDecoration; final BoxDecoration decoration = container.decoration! as BoxDecoration;
final Border border = decoration.border as Border; final Border border = decoration.border! as Border;
expect(border.left.width, 5.0); expect(border.left.width, 5.0);
}); });
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -71,11 +69,11 @@ void main() { ...@@ -71,11 +69,11 @@ void main() {
expect(box.size.height, 16.0); expect(box.size.height, 16.0);
final Container container = tester.widget(find.byType(Container)); final Container container = tester.widget(find.byType(Container));
final BoxDecoration decoration = container.decoration as BoxDecoration; final BoxDecoration decoration = container.decoration! as BoxDecoration;
expect(decoration.border.bottom.width, 0.0); expect(decoration.border!.bottom.width, 0.0);
final ThemeData theme = ThemeData(); final ThemeData theme = ThemeData();
expect(decoration.border.bottom.color, theme.dividerColor); expect(decoration.border!.bottom.color, theme.dividerColor);
final Rect dividerRect = tester.getRect(find.byType(Divider)); final Rect dividerRect = tester.getRect(find.byType(Divider));
final Rect lineRect = tester.getRect(find.byType(DecoratedBox)); final Rect lineRect = tester.getRect(find.byType(DecoratedBox));
...@@ -96,14 +94,14 @@ void main() { ...@@ -96,14 +94,14 @@ void main() {
expect(box.size.height, dividerTheme.space); expect(box.size.height, dividerTheme.space);
final Container container = tester.widget(find.byType(Container)); final Container container = tester.widget(find.byType(Container));
final BoxDecoration decoration = container.decoration as BoxDecoration; final BoxDecoration decoration = container.decoration! as BoxDecoration;
expect(decoration.border.bottom.width, dividerTheme.thickness); expect(decoration.border!.bottom.width, dividerTheme.thickness);
expect(decoration.border.bottom.color, dividerTheme.color); expect(decoration.border!.bottom.color, dividerTheme.color);
final Rect dividerRect = tester.getRect(find.byType(Divider)); final Rect dividerRect = tester.getRect(find.byType(Divider));
final Rect lineRect = tester.getRect(find.byType(DecoratedBox)); final Rect lineRect = tester.getRect(find.byType(DecoratedBox));
expect(lineRect.left, dividerRect.left + dividerTheme.indent); expect(lineRect.left, dividerRect.left + dividerTheme.indent!);
expect(lineRect.right, dividerRect.right - dividerTheme.endIndent); expect(lineRect.right, dividerRect.right - dividerTheme.endIndent!);
}); });
testWidgets('Widget properties take priority over theme', (WidgetTester tester) async { testWidgets('Widget properties take priority over theme', (WidgetTester tester) async {
...@@ -131,9 +129,9 @@ void main() { ...@@ -131,9 +129,9 @@ void main() {
expect(box.size.height, height); expect(box.size.height, height);
final Container container = tester.widget(find.byType(Container)); final Container container = tester.widget(find.byType(Container));
final BoxDecoration decoration = container.decoration as BoxDecoration; final BoxDecoration decoration = container.decoration! as BoxDecoration;
expect(decoration.border.bottom.width, thickness); expect(decoration.border!.bottom.width, thickness);
expect(decoration.border.bottom.color, color); expect(decoration.border!.bottom.color, color);
final Rect dividerRect = tester.getRect(find.byType(Divider)); final Rect dividerRect = tester.getRect(find.byType(Divider));
final Rect lineRect = tester.getRect(find.byType(DecoratedBox)); final Rect lineRect = tester.getRect(find.byType(DecoratedBox));
...@@ -154,8 +152,8 @@ void main() { ...@@ -154,8 +152,8 @@ void main() {
expect(box.size.width, 16.0); expect(box.size.width, 16.0);
final Container container = tester.widget(find.byType(Container)); final Container container = tester.widget(find.byType(Container));
final BoxDecoration decoration = container.decoration as BoxDecoration; final BoxDecoration decoration = container.decoration! as BoxDecoration;
final Border border = decoration.border as Border; final Border border = decoration.border! as Border;
expect(border.left.width, 0.0); expect(border.left.width, 0.0);
final ThemeData theme = ThemeData(); final ThemeData theme = ThemeData();
...@@ -180,15 +178,15 @@ void main() { ...@@ -180,15 +178,15 @@ void main() {
expect(box.size.width, dividerTheme.space); expect(box.size.width, dividerTheme.space);
final Container container = tester.widget(find.byType(Container)); final Container container = tester.widget(find.byType(Container));
final BoxDecoration decoration = container.decoration as BoxDecoration; final BoxDecoration decoration = container.decoration! as BoxDecoration;
final Border border = decoration.border as Border; final Border border = decoration.border! as Border;
expect(border.left.width, dividerTheme.thickness); expect(border.left.width, dividerTheme.thickness);
expect(border.left.color, dividerTheme.color); expect(border.left.color, dividerTheme.color);
final Rect dividerRect = tester.getRect(find.byType(VerticalDivider)); final Rect dividerRect = tester.getRect(find.byType(VerticalDivider));
final Rect lineRect = tester.getRect(find.byType(DecoratedBox)); final Rect lineRect = tester.getRect(find.byType(DecoratedBox));
expect(lineRect.top, dividerRect.top + dividerTheme.indent); expect(lineRect.top, dividerRect.top + dividerTheme.indent!);
expect(lineRect.bottom, dividerRect.bottom - dividerTheme.endIndent); expect(lineRect.bottom, dividerRect.bottom - dividerTheme.endIndent!);
}); });
testWidgets('Widget properties take priority over theme', (WidgetTester tester) async { testWidgets('Widget properties take priority over theme', (WidgetTester tester) async {
...@@ -216,8 +214,8 @@ void main() { ...@@ -216,8 +214,8 @@ void main() {
expect(box.size.width, width); expect(box.size.width, width);
final Container container = tester.widget(find.byType(Container)); final Container container = tester.widget(find.byType(Container));
final BoxDecoration decoration = container.decoration as BoxDecoration; final BoxDecoration decoration = container.decoration! as BoxDecoration;
final Border border = decoration.border as Border; final Border border = decoration.border! as Border;
expect(border.left.width, thickness); expect(border.left.width, thickness);
expect(border.left.color, color); expect(border.left.color, color);
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -126,7 +124,7 @@ void main() { ...@@ -126,7 +124,7 @@ void main() {
} }
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
Widget buildFrame({ Color drawerScrimColor }) { Widget buildFrame({ Color? drawerScrimColor }) {
return MaterialApp( return MaterialApp(
home: Scaffold( home: Scaffold(
key: scaffoldKey, key: scaffoldKey,
...@@ -147,7 +145,7 @@ void main() { ...@@ -147,7 +145,7 @@ void main() {
// Default drawerScrimColor // Default drawerScrimColor
await tester.pumpWidget(buildFrame(drawerScrimColor: null)); await tester.pumpWidget(buildFrame(drawerScrimColor: null));
scaffoldKey.currentState.openDrawer(); scaffoldKey.currentState!.openDrawer();
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(getScrim().color, Colors.black54); expect(getScrim().color, Colors.black54);
...@@ -159,7 +157,7 @@ void main() { ...@@ -159,7 +157,7 @@ void main() {
// Specific drawerScrimColor // Specific drawerScrimColor
await tester.pumpWidget(buildFrame(drawerScrimColor: const Color(0xFF323232))); await tester.pumpWidget(buildFrame(drawerScrimColor: const Color(0xFF323232)));
scaffoldKey.currentState.openDrawer(); scaffoldKey.currentState!.openDrawer();
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(getScrim().color, const Color(0xFF323232)); expect(getScrim().color, const Color(0xFF323232));
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'dart:math' as math; import 'dart:math' as math;
import 'dart:ui' show window; import 'dart:ui' show window;
...@@ -14,7 +12,7 @@ import 'package:flutter/rendering.dart'; ...@@ -14,7 +12,7 @@ import 'package:flutter/rendering.dart';
import '../rendering/mock_canvas.dart'; import '../rendering/mock_canvas.dart';
const List<String> menuItems = <String>['one', 'two', 'three', 'four']; const List<String> menuItems = <String>['one', 'two', 'three', 'four'];
final ValueChanged<String> onChanged = (_) { }; final ValueChanged<String?> onChanged = (_) { };
final Type dropdownButtonType = DropdownButton<String>( final Type dropdownButtonType = DropdownButton<String>(
onChanged: (_) { }, onChanged: (_) { },
items: const <DropdownMenuItem<String>>[], items: const <DropdownMenuItem<String>>[],
...@@ -28,22 +26,22 @@ Finder _iconRichText(Key iconKey) { ...@@ -28,22 +26,22 @@ Finder _iconRichText(Key iconKey) {
} }
Widget buildFormFrame({ Widget buildFormFrame({
Key buttonKey, Key? buttonKey,
AutovalidateMode autovalidateMode = AutovalidateMode.disabled, AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
int elevation = 8, int elevation = 8,
String value = 'two', String? value = 'two',
ValueChanged<String> onChanged, ValueChanged<String?>? onChanged,
VoidCallback onTap, VoidCallback? onTap,
Widget icon, Widget? icon,
Color iconDisabledColor, Color? iconDisabledColor,
Color iconEnabledColor, Color? iconEnabledColor,
double iconSize = 24.0, double iconSize = 24.0,
bool isDense = true, bool isDense = true,
bool isExpanded = false, bool isExpanded = false,
Widget hint, Widget? hint,
Widget disabledHint, Widget? disabledHint,
Widget underline, Widget? underline,
List<String> items = menuItems, List<String>? items = menuItems,
Alignment alignment = Alignment.center, Alignment alignment = Alignment.center,
TextDirection textDirection = TextDirection.ltr, TextDirection textDirection = TextDirection.ltr,
}) { }) {
...@@ -112,15 +110,15 @@ class _TestAppState extends State<TestApp> { ...@@ -112,15 +110,15 @@ class _TestAppState extends State<TestApp> {
class TestApp extends StatefulWidget { class TestApp extends StatefulWidget {
const TestApp({ const TestApp({
Key key, Key? key,
this.textDirection, required this.textDirection,
this.child, required this.child,
this.mediaSize, this.mediaSize,
}) : super(key: key); }) : super(key: key);
final TextDirection textDirection; final TextDirection textDirection;
final Widget child; final Widget child;
final Size mediaSize; final Size? mediaSize;
@override @override
_TestAppState createState() => _TestAppState(); _TestAppState createState() => _TestAppState();
...@@ -129,7 +127,7 @@ class TestApp extends StatefulWidget { ...@@ -129,7 +127,7 @@ class TestApp extends StatefulWidget {
void verifyPaintedShadow(Finder customPaint, int elevation) { void verifyPaintedShadow(Finder customPaint, int elevation) {
const Rect originalRectangle = Rect.fromLTRB(0.0, 0.0, 800, 208.0); const Rect originalRectangle = Rect.fromLTRB(0.0, 0.0, 800, 208.0);
final List<BoxShadow> boxShadows = List<BoxShadow>.generate(3, (int index) => kElevationToShadow[elevation][index]); final List<BoxShadow> boxShadows = List<BoxShadow>.generate(3, (int index) => kElevationToShadow[elevation]![index]);
final List<RRect> rrects = List<RRect>.generate(3, (int index) { final List<RRect> rrects = List<RRect>.generate(3, (int index) {
return RRect.fromRectAndRadius( return RRect.fromRectAndRadius(
originalRectangle.shift( originalRectangle.shift(
...@@ -151,7 +149,7 @@ void verifyPaintedShadow(Finder customPaint, int elevation) { ...@@ -151,7 +149,7 @@ void verifyPaintedShadow(Finder customPaint, int elevation) {
void main() { void main() {
testWidgets('DropdownButtonFormField with autovalidation test', (WidgetTester tester) async { testWidgets('DropdownButtonFormField with autovalidation test', (WidgetTester tester) async {
String value = 'one'; String? value = 'one';
int _validateCalled = 0; int _validateCalled = 0;
await tester.pumpWidget( await tester.pumpWidget(
...@@ -171,12 +169,12 @@ void main() { ...@@ -171,12 +169,12 @@ void main() {
child: Text(value), child: Text(value),
); );
}).toList(), }).toList(),
onChanged: (String newValue) { onChanged: (String? newValue) {
setState(() { setState(() {
value = newValue; value = newValue;
}); });
}, },
validator: (String currentValue) { validator: (String? currentValue) {
_validateCalled++; _validateCalled++;
return currentValue == null ? 'Must select value' : null; return currentValue == null ? 'Must select value' : null;
}, },
...@@ -340,14 +338,14 @@ void main() { ...@@ -340,14 +338,14 @@ void main() {
), ),
); );
expect(richText.text.style.color, Colors.amber); expect(richText.text.style!.color, Colors.amber);
expect(richText.text.style.fontSize, 20.0); expect(richText.text.style!.fontSize, 20.0);
}); });
testWidgets('DropdownButtonFormField - disabledHint displays when the items list is empty, when items is null', (WidgetTester tester) async { testWidgets('DropdownButtonFormField - disabledHint displays when the items list is empty, when items is null', (WidgetTester tester) async {
final Key buttonKey = UniqueKey(); final Key buttonKey = UniqueKey();
Widget build({ List<String> items }){ Widget build({ List<String>? items }){
return buildFormFrame( return buildFormFrame(
items: items, items: items,
buttonKey: buttonKey, buttonKey: buttonKey,
...@@ -373,7 +371,7 @@ void main() { ...@@ -373,7 +371,7 @@ void main() {
(WidgetTester tester) async { (WidgetTester tester) async {
final Key buttonKey = UniqueKey(); final Key buttonKey = UniqueKey();
Widget build({ List<String> items }){ Widget build({ List<String>? items }){
return buildFormFrame( return buildFormFrame(
items: items, items: items,
buttonKey: buttonKey, buttonKey: buttonKey,
...@@ -395,7 +393,7 @@ void main() { ...@@ -395,7 +393,7 @@ void main() {
testWidgets('DropdownButtonFormField - disabledHint is null by default', (WidgetTester tester) async { testWidgets('DropdownButtonFormField - disabledHint is null by default', (WidgetTester tester) async {
final Key buttonKey = UniqueKey(); final Key buttonKey = UniqueKey();
Widget build({ List<String> items }){ Widget build({ List<String>? items }){
return buildFormFrame( return buildFormFrame(
items: items, items: items,
buttonKey: buttonKey, buttonKey: buttonKey,
...@@ -415,7 +413,7 @@ void main() { ...@@ -415,7 +413,7 @@ void main() {
testWidgets('DropdownButtonFormField - disabledHint is null by default', (WidgetTester tester) async { testWidgets('DropdownButtonFormField - disabledHint is null by default', (WidgetTester tester) async {
final Key buttonKey = UniqueKey(); final Key buttonKey = UniqueKey();
Widget build({ List<String> items }){ Widget build({ List<String>? items }){
return buildFormFrame( return buildFormFrame(
items: items, items: items,
buttonKey: buttonKey, buttonKey: buttonKey,
...@@ -435,7 +433,7 @@ void main() { ...@@ -435,7 +433,7 @@ void main() {
testWidgets('DropdownButtonFormField - disabledHint displays when onChanged is null', (WidgetTester tester) async { testWidgets('DropdownButtonFormField - disabledHint displays when onChanged is null', (WidgetTester tester) async {
final Key buttonKey = UniqueKey(); final Key buttonKey = UniqueKey();
Widget build({ List<String> items, ValueChanged<String> onChanged }){ Widget build({ List<String>? items, ValueChanged<String?>? onChanged }){
return buildFormFrame( return buildFormFrame(
items: items, items: items,
buttonKey: buttonKey, buttonKey: buttonKey,
...@@ -453,7 +451,7 @@ void main() { ...@@ -453,7 +451,7 @@ void main() {
testWidgets('DropdownButtonFormField - disabled hint should be of same size as enabled hint', (WidgetTester tester) async { testWidgets('DropdownButtonFormField - disabled hint should be of same size as enabled hint', (WidgetTester tester) async {
final Key buttonKey = UniqueKey(); final Key buttonKey = UniqueKey();
Widget build({ List<String> items}){ Widget build({ List<String>? items}){
return buildFormFrame( return buildFormFrame(
items: items, items: items,
buttonKey: buttonKey, buttonKey: buttonKey,
...@@ -493,7 +491,7 @@ void main() { ...@@ -493,7 +491,7 @@ void main() {
// test for enabled color // test for enabled color
final RichText enabledRichText = tester.widget<RichText>(_iconRichText(iconKey)); final RichText enabledRichText = tester.widget<RichText>(_iconRichText(iconKey));
expect(enabledRichText.text.style.color, Colors.pink); expect(enabledRichText.text.style!.color, Colors.pink);
// test for disabled color // test for disabled color
await tester.pumpWidget(buildFormFrame( await tester.pumpWidget(buildFormFrame(
...@@ -505,7 +503,7 @@ void main() { ...@@ -505,7 +503,7 @@ void main() {
)); ));
final RichText disabledRichText = tester.widget<RichText>(_iconRichText(iconKey)); final RichText disabledRichText = tester.widget<RichText>(_iconRichText(iconKey));
expect(disabledRichText.text.style.color, Colors.orange); expect(disabledRichText.text.style!.color, Colors.orange);
}); });
testWidgets('DropdownButtonFormField - default elevation', (WidgetTester tester) async { testWidgets('DropdownButtonFormField - default elevation', (WidgetTester tester) async {
...@@ -583,7 +581,7 @@ void main() { ...@@ -583,7 +581,7 @@ void main() {
home: Scaffold( home: Scaffold(
body: DropdownButtonFormField<String>( body: DropdownButtonFormField<String>(
value: 'c', value: 'c',
onChanged: (String newValue) {}, onChanged: (String? newValue) {},
items: itemsWithDuplicateValues, items: itemsWithDuplicateValues,
), ),
), ),
...@@ -614,7 +612,7 @@ void main() { ...@@ -614,7 +612,7 @@ void main() {
home: Scaffold( home: Scaffold(
body: DropdownButton<String>( body: DropdownButton<String>(
value: 'e', value: 'e',
onChanged: (String newValue) {}, onChanged: (String? newValue) {},
items: itemsWithDuplicateValues, items: itemsWithDuplicateValues,
), ),
), ),
...@@ -636,7 +634,7 @@ void main() { ...@@ -636,7 +634,7 @@ void main() {
'Two', 'Two',
'Three', 'Three',
]; ];
String selectedItem = items[0]; String? selectedItem = items[0];
await tester.pumpWidget( await tester.pumpWidget(
StatefulBuilder( StatefulBuilder(
...@@ -645,7 +643,7 @@ void main() { ...@@ -645,7 +643,7 @@ void main() {
home: Scaffold( home: Scaffold(
body: DropdownButtonFormField<String>( body: DropdownButtonFormField<String>(
value: selectedItem, value: selectedItem,
onChanged: (String string) => setState(() => selectedItem = string), onChanged: (String? string) => setState(() => selectedItem = string),
selectedItemBuilder: (BuildContext context) { selectedItemBuilder: (BuildContext context) {
int index = 0; int index = 0;
return items.map((String string) { return items.map((String string) {
...@@ -676,8 +674,10 @@ void main() { ...@@ -676,8 +674,10 @@ void main() {
testWidgets('DropdownButton onTap callback is called when defined', (WidgetTester tester) async { testWidgets('DropdownButton onTap callback is called when defined', (WidgetTester tester) async {
int dropdownButtonTapCounter = 0; int dropdownButtonTapCounter = 0;
String value = 'one'; String? value = 'one';
void onChanged(String newValue) { value = newValue; } void onChanged(String? newValue) {
value = newValue;
}
void onTap() { dropdownButtonTapCounter += 1; } void onTap() { dropdownButtonTapCounter += 1; }
Widget build() => buildFormFrame( Widget build() => buildFormFrame(
...@@ -780,7 +780,7 @@ void main() { ...@@ -780,7 +780,7 @@ void main() {
); );
}).toList(), }).toList(),
onChanged: onChanged, onChanged: onChanged,
validator: (String value) { validator: (String? value) {
_validateCalled++; _validateCalled++;
return null; return null;
}, },
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -37,10 +35,10 @@ void main() { ...@@ -37,10 +35,10 @@ void main() {
expect(material.elevation, 2); expect(material.elevation, 2);
expect(material.shadowColor, const Color(0xff000000)); expect(material.shadowColor, const Color(0xff000000));
expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(4.0))); expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(4.0)));
expect(material.textStyle.color, colorScheme.onPrimary); expect(material.textStyle!.color, colorScheme.onPrimary);
expect(material.textStyle.fontFamily, 'Roboto'); expect(material.textStyle!.fontFamily, 'Roboto');
expect(material.textStyle.fontSize, 14); expect(material.textStyle!.fontSize, 14);
expect(material.textStyle.fontWeight, FontWeight.w500); expect(material.textStyle!.fontWeight, FontWeight.w500);
}); });
group('[Theme, TextTheme, ElevatedButton style overrides]', () { group('[Theme, TextTheme, ElevatedButton style overrides]', () {
...@@ -78,7 +76,7 @@ void main() { ...@@ -78,7 +76,7 @@ void main() {
enableFeedback: enableFeedback, enableFeedback: enableFeedback,
); );
Widget buildFrame({ ButtonStyle buttonStyle, ButtonStyle themeStyle, ButtonStyle overallStyle }) { Widget buildFrame({ ButtonStyle? buttonStyle, ButtonStyle? themeStyle, ButtonStyle? overallStyle }) {
final Widget child = Builder( final Widget child = Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
return ElevatedButton( return ElevatedButton(
...@@ -124,16 +122,16 @@ void main() { ...@@ -124,16 +122,16 @@ void main() {
void checkButton(WidgetTester tester) { void checkButton(WidgetTester tester) {
final Material material = tester.widget<Material>(findMaterial); final Material material = tester.widget<Material>(findMaterial);
final InkWell inkWell = tester.widget<InkWell>(findInkWell); final InkWell inkWell = tester.widget<InkWell>(findInkWell);
expect(material.textStyle.color, onPrimaryColor); expect(material.textStyle!.color, onPrimaryColor);
expect(material.textStyle.fontSize, 12); expect(material.textStyle!.fontSize, 12);
expect(material.color, primaryColor); expect(material.color, primaryColor);
expect(material.shadowColor, shadowColor); expect(material.shadowColor, shadowColor);
expect(material.elevation, elevation); expect(material.elevation, elevation);
expect(MaterialStateProperty.resolveAs<MouseCursor>(inkWell.mouseCursor, enabled), enabledMouseCursor); expect(MaterialStateProperty.resolveAs<MouseCursor>(inkWell.mouseCursor!, enabled), enabledMouseCursor);
expect(MaterialStateProperty.resolveAs<MouseCursor>(inkWell.mouseCursor, disabled), disabledMouseCursor); expect(MaterialStateProperty.resolveAs<MouseCursor>(inkWell.mouseCursor!, disabled), disabledMouseCursor);
expect(inkWell.overlayColor.resolve(hovered), onPrimaryColor.withOpacity(0.08)); expect(inkWell.overlayColor!.resolve(hovered), onPrimaryColor.withOpacity(0.08));
expect(inkWell.overlayColor.resolve(focused), onPrimaryColor.withOpacity(0.24)); expect(inkWell.overlayColor!.resolve(focused), onPrimaryColor.withOpacity(0.24));
expect(inkWell.overlayColor.resolve(pressed), onPrimaryColor.withOpacity(0.24)); expect(inkWell.overlayColor!.resolve(pressed), onPrimaryColor.withOpacity(0.24));
expect(inkWell.enableFeedback, enableFeedback); expect(inkWell.enableFeedback, enableFeedback);
expect(material.borderRadius, null); expect(material.borderRadius, null);
expect(material.shape, shape); expect(material.shape, shape);
...@@ -185,7 +183,7 @@ void main() { ...@@ -185,7 +183,7 @@ void main() {
const Color shadowColor = Color(0xff000001); const Color shadowColor = Color(0xff000001);
const Color overiddenColor = Color(0xff000002); const Color overiddenColor = Color(0xff000002);
Widget buildFrame({ Color overallShadowColor, Color themeShadowColor, Color shadowColor }) { Widget buildFrame({ Color? overallShadowColor, Color? themeShadowColor, Color? shadowColor }) {
return MaterialApp( return MaterialApp(
theme: ThemeData.from(colorScheme: colorScheme).copyWith( theme: ThemeData.from(colorScheme: colorScheme).copyWith(
shadowColor: overallShadowColor, shadowColor: overallShadowColor,
......
...@@ -2,12 +2,10 @@ ...@@ -2,12 +2,10 @@
// 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.
// @dart = 2.8
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
Widget wrap({ Widget child, ThemeData theme }) { Widget wrap({ required Widget child, ThemeData? theme }) {
return MaterialApp( return MaterialApp(
theme: theme, theme: theme,
home: Center( home: Center(
......
...@@ -2,14 +2,12 @@ ...@@ -2,14 +2,12 @@
// 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.
// @dart = 2.8
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
class SimpleExpansionPanelListTestWidget extends StatefulWidget { class SimpleExpansionPanelListTestWidget extends StatefulWidget {
const SimpleExpansionPanelListTestWidget({ const SimpleExpansionPanelListTestWidget({
Key key, Key? key,
this.firstPanelKey, this.firstPanelKey,
this.secondPanelKey, this.secondPanelKey,
this.canTapOnHeader = false, this.canTapOnHeader = false,
...@@ -18,14 +16,14 @@ class SimpleExpansionPanelListTestWidget extends StatefulWidget { ...@@ -18,14 +16,14 @@ class SimpleExpansionPanelListTestWidget extends StatefulWidget {
this.elevation = 2, this.elevation = 2,
}) : super(key: key); }) : super(key: key);
final Key firstPanelKey; final Key? firstPanelKey;
final Key secondPanelKey; final Key? secondPanelKey;
final bool canTapOnHeader; final bool canTapOnHeader;
final Color dividerColor; final Color? dividerColor;
final int elevation; final int elevation;
/// If null, the default [ExpansionPanelList]'s expanded header padding value is applied via [defaultExpandedHeaderPadding] /// If null, the default [ExpansionPanelList]'s expanded header padding value is applied via [defaultExpandedHeaderPadding]
final EdgeInsets expandedHeaderPadding; final EdgeInsets? expandedHeaderPadding;
/// Mirrors the default expanded header padding as its source constants are private. /// Mirrors the default expanded header padding as its source constants are private.
static EdgeInsets defaultExpandedHeaderPadding() static EdgeInsets defaultExpandedHeaderPadding()
...@@ -74,7 +72,7 @@ class _SimpleExpansionPanelListTestWidgetState extends State<SimpleExpansionPane ...@@ -74,7 +72,7 @@ class _SimpleExpansionPanelListTestWidgetState extends State<SimpleExpansionPane
} }
class ExpansionPanelListSemanticsTest extends StatefulWidget { class ExpansionPanelListSemanticsTest extends StatefulWidget {
const ExpansionPanelListSemanticsTest({ Key key, this.headerKey }) : super(key: key); const ExpansionPanelListSemanticsTest({ Key? key, required this.headerKey }) : super(key: key);
final Key headerKey; final Key headerKey;
...@@ -118,8 +116,8 @@ class ExpansionPanelListSemanticsTestState extends State<ExpansionPanelListSeman ...@@ -118,8 +116,8 @@ class ExpansionPanelListSemanticsTestState extends State<ExpansionPanelListSeman
void main() { void main() {
testWidgets('ExpansionPanelList test', (WidgetTester tester) async { testWidgets('ExpansionPanelList test', (WidgetTester tester) async {
int index; late int index;
bool isExpanded; late bool isExpanded;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -1364,7 +1362,7 @@ void main() { ...@@ -1364,7 +1362,7 @@ void main() {
final BoxDecoration decoration = decoratedBox.decoration as BoxDecoration; final BoxDecoration decoration = decoratedBox.decoration as BoxDecoration;
// For the last DecoratedBox, we will have a Border.top with the provided dividerColor. // For the last DecoratedBox, we will have a Border.top with the provided dividerColor.
expect(decoration.border.top.color, dividerColor); expect(decoration.border!.top.color, dividerColor);
}); });
testWidgets('ExpansionPanelList.radio respects DividerColor', (WidgetTester tester) async { testWidgets('ExpansionPanelList.radio respects DividerColor', (WidgetTester tester) async {
...@@ -1397,7 +1395,7 @@ void main() { ...@@ -1397,7 +1395,7 @@ void main() {
final BoxDecoration boxDecoration = decoratedBox.decoration as BoxDecoration; final BoxDecoration boxDecoration = decoratedBox.decoration as BoxDecoration;
// For the last DecoratedBox, we will have a Border.top with the provided dividerColor. // For the last DecoratedBox, we will have a Border.top with the provided dividerColor.
expect(boxDecoration.border.top.color, dividerColor); expect(boxDecoration.border!.top.color, dividerColor);
}); });
testWidgets('elevation is propagated properly to MergeableMaterial', (WidgetTester tester) async { testWidgets('elevation is propagated properly to MergeableMaterial', (WidgetTester tester) async {
......
...@@ -2,21 +2,19 @@ ...@@ -2,21 +2,19 @@
// 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.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class TestIcon extends StatefulWidget { class TestIcon extends StatefulWidget {
const TestIcon({Key key}) : super(key: key); const TestIcon({Key? key}) : super(key: key);
@override @override
TestIconState createState() => TestIconState(); TestIconState createState() => TestIconState();
} }
class TestIconState extends State<TestIcon> { class TestIconState extends State<TestIcon> {
IconThemeData iconTheme; late IconThemeData iconTheme;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -26,7 +24,7 @@ class TestIconState extends State<TestIcon> { ...@@ -26,7 +24,7 @@ class TestIconState extends State<TestIcon> {
} }
class TestText extends StatefulWidget { class TestText extends StatefulWidget {
const TestText(this.text, {Key key}) : super(key: key); const TestText(this.text, {Key? key}) : super(key: key);
final String text; final String text;
...@@ -35,7 +33,7 @@ class TestText extends StatefulWidget { ...@@ -35,7 +33,7 @@ class TestText extends StatefulWidget {
} }
class TestTextState extends State<TestText> { class TestTextState extends State<TestText> {
TextStyle textStyle; late TextStyle textStyle;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -113,15 +111,15 @@ void main() { ...@@ -113,15 +111,15 @@ void main() {
expect(getHeight(topKey), getHeight(collapsedKey) - 2.0); expect(getHeight(topKey), getHeight(collapsedKey) - 2.0);
expect(getHeight(topKey), getHeight(defaultKey) - 2.0); expect(getHeight(topKey), getHeight(defaultKey) - 2.0);
BoxDecoration expandedContainerDecoration = getContainer(expandedKey).decoration as BoxDecoration; BoxDecoration expandedContainerDecoration = getContainer(expandedKey).decoration! as BoxDecoration;
expect(expandedContainerDecoration.color, Colors.red); expect(expandedContainerDecoration.color, Colors.red);
expect(expandedContainerDecoration.border.top.color, _dividerColor); expect(expandedContainerDecoration.border!.top.color, _dividerColor);
expect(expandedContainerDecoration.border.bottom.color, _dividerColor); expect(expandedContainerDecoration.border!.bottom.color, _dividerColor);
BoxDecoration collapsedContainerDecoration = getContainer(collapsedKey).decoration as BoxDecoration; BoxDecoration collapsedContainerDecoration = getContainer(collapsedKey).decoration! as BoxDecoration;
expect(collapsedContainerDecoration.color, Colors.transparent); expect(collapsedContainerDecoration.color, Colors.transparent);
expect(collapsedContainerDecoration.border.top.color, Colors.transparent); expect(collapsedContainerDecoration.border!.top.color, Colors.transparent);
expect(collapsedContainerDecoration.border.bottom.color, Colors.transparent); expect(collapsedContainerDecoration.border!.bottom.color, Colors.transparent);
await tester.tap(find.text('Expanded')); await tester.tap(find.text('Expanded'));
await tester.tap(find.text('Collapsed')); await tester.tap(find.text('Collapsed'));
...@@ -131,11 +129,11 @@ void main() { ...@@ -131,11 +129,11 @@ void main() {
// Pump to the middle of the animation for expansion. // Pump to the middle of the animation for expansion.
await tester.pump(const Duration(milliseconds: 100)); await tester.pump(const Duration(milliseconds: 100));
final BoxDecoration collapsingContainerDecoration = getContainer(collapsedKey).decoration as BoxDecoration; final BoxDecoration collapsingContainerDecoration = getContainer(collapsedKey).decoration! as BoxDecoration;
expect(collapsingContainerDecoration.color, Colors.transparent); expect(collapsingContainerDecoration.color, Colors.transparent);
// Opacity should change but color component should remain the same. // Opacity should change but color component should remain the same.
expect(collapsingContainerDecoration.border.top.color, const Color(0x15333333)); expect(collapsingContainerDecoration.border!.top.color, const Color(0x15333333));
expect(collapsingContainerDecoration.border.bottom.color, const Color(0x15333333)); expect(collapsingContainerDecoration.border!.bottom.color, const Color(0x15333333));
// Pump all the way to the end now. // Pump all the way to the end now.
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
...@@ -145,16 +143,16 @@ void main() { ...@@ -145,16 +143,16 @@ void main() {
expect(getHeight(topKey), getHeight(defaultKey) - getHeight(tileKey) - 2.0); expect(getHeight(topKey), getHeight(defaultKey) - getHeight(tileKey) - 2.0);
// Expanded should be collapsed now. // Expanded should be collapsed now.
expandedContainerDecoration = getContainer(expandedKey).decoration as BoxDecoration; expandedContainerDecoration = getContainer(expandedKey).decoration! as BoxDecoration;
expect(expandedContainerDecoration.color, Colors.transparent); expect(expandedContainerDecoration.color, Colors.transparent);
expect(expandedContainerDecoration.border.top.color, Colors.transparent); expect(expandedContainerDecoration.border!.top.color, Colors.transparent);
expect(expandedContainerDecoration.border.bottom.color, Colors.transparent); expect(expandedContainerDecoration.border!.bottom.color, Colors.transparent);
// Collapsed should be expanded now. // Collapsed should be expanded now.
collapsedContainerDecoration = getContainer(collapsedKey).decoration as BoxDecoration; collapsedContainerDecoration = getContainer(collapsedKey).decoration! as BoxDecoration;
expect(collapsedContainerDecoration.color, Colors.transparent); expect(collapsedContainerDecoration.color, Colors.transparent);
expect(collapsedContainerDecoration.border.top.color, _dividerColor); expect(collapsedContainerDecoration.border!.top.color, _dividerColor);
expect(collapsedContainerDecoration.border.bottom.color, _dividerColor); expect(collapsedContainerDecoration.border!.bottom.color, _dividerColor);
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets('ListTileTheme', (WidgetTester tester) async { testWidgets('ListTileTheme', (WidgetTester tester) async {
...@@ -195,8 +193,8 @@ void main() { ...@@ -195,8 +193,8 @@ void main() {
), ),
); );
Color iconColor(Key key) => tester.state<TestIconState>(find.byKey(key)).iconTheme.color; Color iconColor(Key key) => tester.state<TestIconState>(find.byKey(key)).iconTheme.color!;
Color textColor(Key key) => tester.state<TestTextState>(find.byKey(key)).textStyle.color; Color textColor(Key key) => tester.state<TestTextState>(find.byKey(key)).textStyle.color!;
expect(textColor(expandedTitleKey), _accentColor); expect(textColor(expandedTitleKey), _accentColor);
expect(textColor(collapsedTitleKey), _headerColor); expect(textColor(collapsedTitleKey), _headerColor);
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -14,18 +12,18 @@ import 'feedback_tester.dart'; ...@@ -14,18 +12,18 @@ import 'feedback_tester.dart';
void main () { void main () {
const Duration kWaitDuration = Duration(seconds: 1); const Duration kWaitDuration = Duration(seconds: 1);
FeedbackTester feedback; late FeedbackTester feedback;
setUp(() { setUp(() {
feedback = FeedbackTester(); feedback = FeedbackTester();
}); });
tearDown(() { tearDown(() {
feedback?.dispose(); feedback.dispose();
}); });
group('Feedback on Android', () { group('Feedback on Android', () {
List<Map<String, Object>> semanticEvents; late List<Map<String, Object>> semanticEvents;
setUp(() { setUp(() {
semanticEvents = <Map<String, Object>>[]; semanticEvents = <Map<String, Object>>[];
...@@ -60,10 +58,10 @@ void main () { ...@@ -60,10 +58,10 @@ void main () {
expect(feedback.clickSoundCount, 1); expect(feedback.clickSoundCount, 1);
expect(semanticEvents.single, <String, dynamic>{ expect(semanticEvents.single, <String, dynamic>{
'type': 'tap', 'type': 'tap',
'nodeId': object.debugSemantics.id, 'nodeId': object.debugSemantics!.id,
'data': <String, dynamic>{}, 'data': <String, dynamic>{},
}); });
expect(object.debugSemantics.getSemanticsData().hasAction(SemanticsAction.tap), true); expect(object.debugSemantics!.getSemanticsData().hasAction(SemanticsAction.tap), true);
semanticsTester.dispose(); semanticsTester.dispose();
}); });
...@@ -78,7 +76,7 @@ void main () { ...@@ -78,7 +76,7 @@ void main () {
await tester.pumpWidget(TestWidget( await tester.pumpWidget(TestWidget(
tapHandler: (BuildContext context) { tapHandler: (BuildContext context) {
return Feedback.wrapForTap(callback, context); return Feedback.wrapForTap(callback, context)!;
}, },
)); ));
await tester.pumpAndSettle(kWaitDuration); await tester.pumpAndSettle(kWaitDuration);
...@@ -95,10 +93,10 @@ void main () { ...@@ -95,10 +93,10 @@ void main () {
expect(callbackCount, 1); expect(callbackCount, 1);
expect(semanticEvents.single, <String, dynamic>{ expect(semanticEvents.single, <String, dynamic>{
'type': 'tap', 'type': 'tap',
'nodeId': object.debugSemantics.id, 'nodeId': object.debugSemantics!.id,
'data': <String, dynamic>{}, 'data': <String, dynamic>{},
}); });
expect(object.debugSemantics.getSemanticsData().hasAction(SemanticsAction.tap), true); expect(object.debugSemantics!.getSemanticsData().hasAction(SemanticsAction.tap), true);
semanticsTester.dispose(); semanticsTester.dispose();
}); });
...@@ -123,10 +121,10 @@ void main () { ...@@ -123,10 +121,10 @@ void main () {
expect(feedback.clickSoundCount, 0); expect(feedback.clickSoundCount, 0);
expect(semanticEvents.single, <String, dynamic>{ expect(semanticEvents.single, <String, dynamic>{
'type': 'longPress', 'type': 'longPress',
'nodeId': object.debugSemantics.id, 'nodeId': object.debugSemantics!.id,
'data': <String, dynamic>{}, 'data': <String, dynamic>{},
}); });
expect(object.debugSemantics.getSemanticsData().hasAction(SemanticsAction.longPress), true); expect(object.debugSemantics!.getSemanticsData().hasAction(SemanticsAction.longPress), true);
semanticsTester.dispose(); semanticsTester.dispose();
}); });
...@@ -140,7 +138,7 @@ void main () { ...@@ -140,7 +138,7 @@ void main () {
await tester.pumpWidget(TestWidget( await tester.pumpWidget(TestWidget(
longPressHandler: (BuildContext context) { longPressHandler: (BuildContext context) {
return Feedback.wrapForLongPress(callback, context); return Feedback.wrapForLongPress(callback, context)!;
}, },
)); ));
await tester.pumpAndSettle(kWaitDuration); await tester.pumpAndSettle(kWaitDuration);
...@@ -157,10 +155,10 @@ void main () { ...@@ -157,10 +155,10 @@ void main () {
expect(callbackCount, 1); expect(callbackCount, 1);
expect(semanticEvents.single, <String, dynamic>{ expect(semanticEvents.single, <String, dynamic>{
'type': 'longPress', 'type': 'longPress',
'nodeId': object.debugSemantics.id, 'nodeId': object.debugSemantics!.id,
'data': <String, dynamic>{}, 'data': <String, dynamic>{},
}); });
expect(object.debugSemantics.getSemanticsData().hasAction(SemanticsAction.longPress), true); expect(object.debugSemantics!.getSemanticsData().hasAction(SemanticsAction.longPress), true);
semanticsTester.dispose(); semanticsTester.dispose();
}); });
...@@ -204,7 +202,7 @@ void main () { ...@@ -204,7 +202,7 @@ void main () {
class TestWidget extends StatelessWidget { class TestWidget extends StatelessWidget {
const TestWidget({ const TestWidget({
Key key, Key? key,
this.tapHandler = nullHandler, this.tapHandler = nullHandler,
this.longPressHandler = nullHandler, this.longPressHandler = nullHandler,
}) : super(key: key); }) : super(key: key);
...@@ -212,7 +210,7 @@ class TestWidget extends StatelessWidget { ...@@ -212,7 +210,7 @@ class TestWidget extends StatelessWidget {
final HandlerCreator tapHandler; final HandlerCreator tapHandler;
final HandlerCreator longPressHandler; final HandlerCreator longPressHandler;
static VoidCallback nullHandler(BuildContext context) => null; static VoidCallback? nullHandler(BuildContext context) => null;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -224,4 +222,4 @@ class TestWidget extends StatelessWidget { ...@@ -224,4 +222,4 @@ class TestWidget extends StatelessWidget {
} }
} }
typedef HandlerCreator = VoidCallback Function(BuildContext context); typedef HandlerCreator = VoidCallback? Function(BuildContext context);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment