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

[NNBD] Migrating some Material tests (#67689)

parent d6d06ed9
...@@ -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:ui'; import 'dart:ui';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -13,7 +11,7 @@ import 'package:matcher/matcher.dart'; ...@@ -13,7 +11,7 @@ import 'package:matcher/matcher.dart';
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
MaterialApp _buildAppWithDialog(Widget dialog, { ThemeData theme, double textScaleFactor = 1.0 }) { MaterialApp _buildAppWithDialog(Widget dialog, { ThemeData? theme, double textScaleFactor = 1.0 }) {
return MaterialApp( return MaterialApp(
theme: theme, theme: theme,
home: Material( home: Material(
...@@ -27,7 +25,7 @@ MaterialApp _buildAppWithDialog(Widget dialog, { ThemeData theme, double textSca ...@@ -27,7 +25,7 @@ MaterialApp _buildAppWithDialog(Widget dialog, { ThemeData theme, double textSca
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return MediaQuery( return MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: textScaleFactor), data: MediaQuery.of(context)!.copyWith(textScaleFactor: textScaleFactor),
child: dialog, child: dialog,
); );
}, },
...@@ -46,7 +44,7 @@ Material _getMaterialFromDialog(WidgetTester tester) { ...@@ -46,7 +44,7 @@ Material _getMaterialFromDialog(WidgetTester tester) {
} }
RenderParagraph _getTextRenderObjectFromDialog(WidgetTester tester, String text) { RenderParagraph _getTextRenderObjectFromDialog(WidgetTester tester, String text) {
return tester.element<StatelessElement>(find.descendant(of: find.byType(AlertDialog), matching: find.text(text))).renderObject as RenderParagraph; return tester.element<StatelessElement>(find.descendant(of: find.byType(AlertDialog), matching: find.text(text))).renderObject! as RenderParagraph;
} }
const ShapeBorder _defaultDialogShape = RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(4.0))); const ShapeBorder _defaultDialogShape = RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(4.0)));
...@@ -276,7 +274,7 @@ void main() { ...@@ -276,7 +274,7 @@ void main() {
); );
final Future<int> result = showDialog<int>( final Future<int> result = showDialog<int>(
context: navigator.currentContext, context: navigator.currentContext!,
builder: (BuildContext context) { builder: (BuildContext context) {
return SimpleDialog( return SimpleDialog(
title: const Text('Title'), title: const Text('Title'),
...@@ -678,73 +676,73 @@ void main() { ...@@ -678,73 +676,73 @@ void main() {
void expectLeftEdgePadding( void expectLeftEdgePadding(
WidgetTester tester, { WidgetTester tester, {
Finder finder, required Finder finder,
double textScaleFactor, required double textScaleFactor,
double unscaledValue, required double unscaledValue,
}) { }) {
expect( expect(
tester.getTopLeft(dialogFinder).dx, tester.getTopLeft(dialogFinder).dx,
moreOrLessEquals(tester.getTopLeft(finder).dx - unscaledValue * paddingScaleFactors[textScaleFactor]), moreOrLessEquals(tester.getTopLeft(finder).dx - unscaledValue * paddingScaleFactors[textScaleFactor]!),
); );
expect( expect(
tester.getBottomLeft(dialogFinder).dx, tester.getBottomLeft(dialogFinder).dx,
moreOrLessEquals(tester.getBottomLeft(finder).dx - unscaledValue * paddingScaleFactors[textScaleFactor]), moreOrLessEquals(tester.getBottomLeft(finder).dx - unscaledValue * paddingScaleFactors[textScaleFactor]!),
); );
} }
void expectRightEdgePadding( void expectRightEdgePadding(
WidgetTester tester, { WidgetTester tester, {
Finder finder, required Finder finder,
double textScaleFactor, required double textScaleFactor,
double unscaledValue, required double unscaledValue,
}) { }) {
expect( expect(
tester.getTopRight(dialogFinder).dx, tester.getTopRight(dialogFinder).dx,
moreOrLessEquals(tester.getTopRight(finder).dx + unscaledValue * paddingScaleFactors[textScaleFactor]), moreOrLessEquals(tester.getTopRight(finder).dx + unscaledValue * paddingScaleFactors[textScaleFactor]!),
); );
expect( expect(
tester.getBottomRight(dialogFinder).dx, tester.getBottomRight(dialogFinder).dx,
moreOrLessEquals(tester.getBottomRight(finder).dx + unscaledValue * paddingScaleFactors[textScaleFactor]), moreOrLessEquals(tester.getBottomRight(finder).dx + unscaledValue * paddingScaleFactors[textScaleFactor]!),
); );
} }
void expectTopEdgePadding( void expectTopEdgePadding(
WidgetTester tester, { WidgetTester tester, {
Finder finder, required Finder finder,
double textScaleFactor, required double textScaleFactor,
double unscaledValue, required double unscaledValue,
}) { }) {
expect( expect(
tester.getTopLeft(dialogFinder).dy, tester.getTopLeft(dialogFinder).dy,
moreOrLessEquals(tester.getTopLeft(finder).dy - unscaledValue * paddingScaleFactors[textScaleFactor]), moreOrLessEquals(tester.getTopLeft(finder).dy - unscaledValue * paddingScaleFactors[textScaleFactor]!),
); );
expect( expect(
tester.getTopRight(dialogFinder).dy, tester.getTopRight(dialogFinder).dy,
moreOrLessEquals(tester.getTopRight(finder).dy - unscaledValue * paddingScaleFactors[textScaleFactor]), moreOrLessEquals(tester.getTopRight(finder).dy - unscaledValue * paddingScaleFactors[textScaleFactor]!),
); );
} }
void expectBottomEdgePadding( void expectBottomEdgePadding(
WidgetTester tester, { WidgetTester tester, {
Finder finder, required Finder finder,
double textScaleFactor, required double textScaleFactor,
double unscaledValue, required double unscaledValue,
}) { }) {
expect( expect(
tester.getBottomLeft(dialogFinder).dy, tester.getBottomLeft(dialogFinder).dy,
moreOrLessEquals(tester.getBottomRight(finder).dy + unscaledValue * paddingScaleFactors[textScaleFactor]), moreOrLessEquals(tester.getBottomRight(finder).dy + unscaledValue * paddingScaleFactors[textScaleFactor]!),
); );
expect( expect(
tester.getBottomRight(dialogFinder).dy, tester.getBottomRight(dialogFinder).dy,
moreOrLessEquals(tester.getBottomRight(finder).dy + unscaledValue * paddingScaleFactors[textScaleFactor]), moreOrLessEquals(tester.getBottomRight(finder).dy + unscaledValue * paddingScaleFactors[textScaleFactor]!),
); );
} }
void expectVerticalInnerPadding( void expectVerticalInnerPadding(
WidgetTester tester, { WidgetTester tester, {
Finder top, required Finder top,
Finder bottom, required Finder bottom,
double value, required double value,
}) { }) {
expect( expect(
tester.getBottomLeft(top).dy, tester.getBottomLeft(top).dy,
...@@ -1144,9 +1142,9 @@ void main() { ...@@ -1144,9 +1142,9 @@ void main() {
}); });
testWidgets('Dialogs removes MediaQuery padding and view insets', (WidgetTester tester) async { testWidgets('Dialogs removes MediaQuery padding and view insets', (WidgetTester tester) async {
BuildContext outerContext; late BuildContext outerContext;
BuildContext routeContext; late BuildContext routeContext;
BuildContext dialogContext; late BuildContext dialogContext;
await tester.pumpWidget(Localizations( await tester.pumpWidget(Localizations(
locale: const Locale('en', 'US'), locale: const Locale('en', 'US'),
...@@ -1190,12 +1188,12 @@ void main() { ...@@ -1190,12 +1188,12 @@ void main() {
await tester.pump(); await tester.pump();
expect(MediaQuery.of(outerContext).padding, const EdgeInsets.all(50.0)); expect(MediaQuery.of(outerContext)!.padding, const EdgeInsets.all(50.0));
expect(MediaQuery.of(routeContext).padding, EdgeInsets.zero); expect(MediaQuery.of(routeContext)!.padding, EdgeInsets.zero);
expect(MediaQuery.of(dialogContext).padding, EdgeInsets.zero); expect(MediaQuery.of(dialogContext)!.padding, EdgeInsets.zero);
expect(MediaQuery.of(outerContext).viewInsets, const EdgeInsets.only(left: 25.0, bottom: 75.0)); expect(MediaQuery.of(outerContext)!.viewInsets, const EdgeInsets.only(left: 25.0, bottom: 75.0));
expect(MediaQuery.of(routeContext).viewInsets, const EdgeInsets.only(left: 25.0, bottom: 75.0)); expect(MediaQuery.of(routeContext)!.viewInsets, const EdgeInsets.only(left: 25.0, bottom: 75.0));
expect(MediaQuery.of(dialogContext).viewInsets, EdgeInsets.zero); expect(MediaQuery.of(dialogContext)!.viewInsets, EdgeInsets.zero);
}); });
testWidgets('Dialog widget insets by viewInsets', (WidgetTester tester) async { testWidgets('Dialog widget insets by viewInsets', (WidgetTester tester) async {
...@@ -1386,7 +1384,7 @@ void main() { ...@@ -1386,7 +1384,7 @@ void main() {
// Dismiss is confirmed IFF confirmDismiss() returns true. // Dismiss is confirmed IFF confirmDismiss() returns true.
Future<bool> confirmDismiss (DismissDirection dismissDirection) { Future<bool> confirmDismiss (DismissDirection dismissDirection) {
return showDialog<bool>( return showDialog<bool>(
context: _scaffoldKey.currentContext, context: _scaffoldKey.currentContext!,
barrierDismissible: true, // showDialog() returns null if tapped outside the dialog barrierDismissible: true, // showDialog() returns null if tapped outside the dialog
builder: (BuildContext context) { builder: (BuildContext context) {
return AlertDialog( return AlertDialog(
...@@ -1551,11 +1549,11 @@ void main() { ...@@ -1551,11 +1549,11 @@ void main() {
testWidgets('showDialog safe area', (WidgetTester tester) async { testWidgets('showDialog safe area', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
builder: (BuildContext context, Widget child) { builder: (BuildContext context, Widget? child) {
return MediaQuery( return MediaQuery(
// Set up the safe area to be 20 pixels in from each side // Set up the safe area to be 20 pixels in from each side
data: const MediaQueryData(padding: EdgeInsets.all(20.0)), data: const MediaQueryData(padding: EdgeInsets.all(20.0)),
child: child, child: child!,
); );
}, },
home: const Center(child: Text('Test')), home: const Center(child: Text('Test')),
...@@ -1741,13 +1739,13 @@ void main() { ...@@ -1741,13 +1739,13 @@ void main() {
}); });
testWidgets('Dialog with RouteSettings', (WidgetTester tester) async { testWidgets('Dialog with RouteSettings', (WidgetTester tester) async {
RouteSettings currentRouteSetting; late RouteSettings currentRouteSetting;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
navigatorObservers: <NavigatorObserver>[ navigatorObservers: <NavigatorObserver>[
_ClosureNavigatorObserver(onDidChange: (Route<dynamic> newRoute) { _ClosureNavigatorObserver(onDidChange: (Route<dynamic> newRoute) {
currentRouteSetting = newRoute?.settings; currentRouteSetting = newRoute.settings;
}) })
], ],
home: const Material( home: const Material(
...@@ -1773,7 +1771,7 @@ void main() { ...@@ -1773,7 +1771,7 @@ void main() {
SimpleDialogOption( SimpleDialogOption(
child: const Text('X'), child: const Text('X'),
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context)!.pop();
}, },
), ),
], ],
...@@ -1791,7 +1789,7 @@ void main() { ...@@ -1791,7 +1789,7 @@ void main() {
expect(await result, isNull); expect(await result, isNull);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(currentRouteSetting?.name, '/'); expect(currentRouteSetting.name, '/');
}); });
} }
...@@ -1799,7 +1797,7 @@ class DialogObserver extends NavigatorObserver { ...@@ -1799,7 +1797,7 @@ class DialogObserver extends NavigatorObserver {
int dialogCount = 0; int dialogCount = 0;
@override @override
void didPush(Route<dynamic> route, Route<dynamic> previousRoute) { void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {
if (route.toString().contains('_DialogRoute')) { if (route.toString().contains('_DialogRoute')) {
dialogCount++; dialogCount++;
} }
...@@ -1808,19 +1806,19 @@ class DialogObserver extends NavigatorObserver { ...@@ -1808,19 +1806,19 @@ class DialogObserver extends NavigatorObserver {
} }
class _ClosureNavigatorObserver extends NavigatorObserver { class _ClosureNavigatorObserver extends NavigatorObserver {
_ClosureNavigatorObserver({@required this.onDidChange}); _ClosureNavigatorObserver({required this.onDidChange});
final void Function(Route<dynamic> newRoute) onDidChange; final void Function(Route<dynamic> newRoute) onDidChange;
@override @override
void didPush(Route<dynamic> route, Route<dynamic> previousRoute) => onDidChange(route); void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) => onDidChange(route);
@override @override
void didPop(Route<dynamic> route, Route<dynamic> previousRoute) => onDidChange(previousRoute); void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) => onDidChange(previousRoute!);
@override @override
void didRemove(Route<dynamic> route, Route<dynamic> previousRoute) => onDidChange(previousRoute); void didRemove(Route<dynamic> route, Route<dynamic>? previousRoute) => onDidChange(previousRoute!);
@override @override
void didReplace({Route<dynamic> newRoute, Route<dynamic> oldRoute}) => onDidChange(newRoute); void didReplace({Route<dynamic>? newRoute, Route<dynamic>? oldRoute}) => onDidChange(newRoute!);
} }
...@@ -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 'dart:math' as math; import 'dart:math' as math;
import 'dart:ui' show window; import 'dart:ui' show window;
...@@ -18,7 +16,7 @@ import '../rendering/mock_canvas.dart'; ...@@ -18,7 +16,7 @@ import '../rendering/mock_canvas.dart';
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.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: (_) { },
...@@ -33,32 +31,32 @@ Finder _iconRichText(Key iconKey) { ...@@ -33,32 +31,32 @@ Finder _iconRichText(Key iconKey) {
} }
Widget buildDropdown({ Widget buildDropdown({
bool isFormField, required bool isFormField,
Key buttonKey, Key? buttonKey,
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 = false, bool isDense = false,
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,
List<Widget> Function(BuildContext) selectedItemBuilder, List<Widget> Function(BuildContext)? selectedItemBuilder,
double itemHeight = kMinInteractiveDimension, double? itemHeight = kMinInteractiveDimension,
Alignment alignment = Alignment.center, Alignment alignment = Alignment.center,
TextDirection textDirection = TextDirection.ltr, TextDirection textDirection = TextDirection.ltr,
Size mediaSize, Size? mediaSize,
FocusNode focusNode, FocusNode? focusNode,
bool autofocus = false, bool autofocus = false,
Color focusColor, Color? focusColor,
Color dropdownColor, Color? dropdownColor,
}) { }) {
final List<DropdownMenuItem<String>> listItems = items == null final List<DropdownMenuItem<String>>? listItems = items == null
? null ? null
: items.map<DropdownMenuItem<String>>((String item) { : items.map<DropdownMenuItem<String>>((String item) {
return DropdownMenuItem<String>( return DropdownMenuItem<String>(
...@@ -119,29 +117,29 @@ Widget buildDropdown({ ...@@ -119,29 +117,29 @@ Widget buildDropdown({
} }
Widget buildFrame({ Widget buildFrame({
Key buttonKey, Key? buttonKey,
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 = false, bool isDense = false,
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,
List<Widget> Function(BuildContext) selectedItemBuilder, List<Widget> Function(BuildContext)? selectedItemBuilder,
double itemHeight = kMinInteractiveDimension, double? itemHeight = kMinInteractiveDimension,
Alignment alignment = Alignment.center, Alignment alignment = Alignment.center,
TextDirection textDirection = TextDirection.ltr, TextDirection textDirection = TextDirection.ltr,
Size mediaSize, Size? mediaSize,
FocusNode focusNode, FocusNode? focusNode,
bool autofocus = false, bool autofocus = false,
Color focusColor, Color? focusColor,
Color dropdownColor, Color? dropdownColor,
bool isFormField = false, bool isFormField = false,
}) { }) {
return TestApp( return TestApp(
...@@ -181,15 +179,15 @@ Widget buildFrame({ ...@@ -181,15 +179,15 @@ Widget buildFrame({
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();
...@@ -239,7 +237,7 @@ void checkSelectedItemTextGeometry(WidgetTester tester, String value) { ...@@ -239,7 +237,7 @@ void checkSelectedItemTextGeometry(WidgetTester tester, String value) {
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(
...@@ -259,7 +257,7 @@ void verifyPaintedShadow(Finder customPaint, int elevation) { ...@@ -259,7 +257,7 @@ void verifyPaintedShadow(Finder customPaint, int elevation) {
); );
} }
Future<void> checkDropdownColor(WidgetTester tester, {Color color, bool isFormField = false }) async { Future<void> checkDropdownColor(WidgetTester tester, {Color? color, bool isFormField = false }) async {
const String text = 'foo'; const String text = 'foo';
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -340,8 +338,8 @@ void main() { ...@@ -340,8 +338,8 @@ void main() {
}); });
testWidgets('Dropdown button control test', (WidgetTester tester) async { testWidgets('Dropdown button control test', (WidgetTester tester) async {
String value = 'one'; String? value = 'one';
void didChangeValue(String newValue) { void didChangeValue(String? newValue) {
value = newValue; value = newValue;
} }
...@@ -379,8 +377,8 @@ void main() { ...@@ -379,8 +377,8 @@ void main() {
}); });
testWidgets('Dropdown button with no app', (WidgetTester tester) async { testWidgets('Dropdown button with no app', (WidgetTester tester) async {
String value = 'one'; String? value = 'one';
void didChangeValue(String newValue) { void didChangeValue(String? newValue) {
value = newValue; value = newValue;
} }
...@@ -449,7 +447,7 @@ void main() { ...@@ -449,7 +447,7 @@ void main() {
home: Scaffold( home: Scaffold(
body: DropdownButton<String>( body: DropdownButton<String>(
value: 'c', value: 'c',
onChanged: (String newValue) {}, onChanged: (String? newValue) {},
items: itemsWithDuplicateValues, items: itemsWithDuplicateValues,
), ),
), ),
...@@ -480,7 +478,7 @@ void main() { ...@@ -480,7 +478,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,
), ),
), ),
...@@ -499,7 +497,7 @@ void main() { ...@@ -499,7 +497,7 @@ void main() {
testWidgets('Dropdown form field uses form field state', (WidgetTester tester) async { testWidgets('Dropdown form field uses form field state', (WidgetTester tester) async {
final Key buttonKey = UniqueKey(); final Key buttonKey = UniqueKey();
final GlobalKey<FormState> formKey = GlobalKey<FormState>(); final GlobalKey<FormState> formKey = GlobalKey<FormState>();
String value; String? value;
await tester.pumpWidget( await tester.pumpWidget(
StatefulBuilder( StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
...@@ -520,9 +518,9 @@ void main() { ...@@ -520,9 +518,9 @@ void main() {
child: Text(val) child: Text(val)
); );
}).toList(), }).toList(),
validator: (String v) => v == null ? 'Must select value' : null, validator: (String? v) => v == null ? 'Must select value' : null,
onChanged: (String newValue) {}, onChanged: (String? newValue) {},
onSaved: (String v) { onSaved: (String? v) {
setState(() { setState(() {
value = v; value = v;
}); });
...@@ -536,7 +534,7 @@ void main() { ...@@ -536,7 +534,7 @@ void main() {
); );
int getIndex() { int getIndex() {
final IndexedStack stack = tester.element(find.byType(IndexedStack)).widget as IndexedStack; final IndexedStack stack = tester.element(find.byType(IndexedStack)).widget as IndexedStack;
return stack.index; return stack.index!;
} }
// Initial value of null displays hint // Initial value of null displays hint
expect(value, equals(null)); expect(value, equals(null));
...@@ -548,7 +546,7 @@ void main() { ...@@ -548,7 +546,7 @@ void main() {
expect(getIndex(), 2); expect(getIndex(), 2);
// Changes only made to FormField state until form saved // Changes only made to FormField state until form saved
expect(value, equals(null)); expect(value, equals(null));
final FormState form = formKey.currentState; final FormState form = formKey.currentState!;
form.save(); form.save();
expect(value, equals('three')); expect(value, equals('three'));
}); });
...@@ -589,12 +587,12 @@ void main() { ...@@ -589,12 +587,12 @@ void main() {
}); });
testWidgets('Dropdown screen edges', (WidgetTester tester) async { testWidgets('Dropdown screen edges', (WidgetTester tester) async {
int value = 4; int? value = 4;
final List<DropdownMenuItem<int>> items = <DropdownMenuItem<int>>[ final List<DropdownMenuItem<int>> items = <DropdownMenuItem<int>>[
for (int i = 0; i < 20; ++i) DropdownMenuItem<int>(value: i, child: Text('$i')), for (int i = 0; i < 20; ++i) DropdownMenuItem<int>(value: i, child: Text('$i')),
]; ];
void handleChanged(int newValue) { void handleChanged(int? newValue) {
value = newValue; value = newValue;
} }
...@@ -748,7 +746,7 @@ void main() { ...@@ -748,7 +746,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.grey.shade700); expect(enabledRichText.text.style!.color, Colors.grey.shade700);
// test for disabled color // test for disabled color
await tester.pumpWidget(buildFrame( await tester.pumpWidget(buildFrame(
...@@ -757,7 +755,7 @@ void main() { ...@@ -757,7 +755,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.grey.shade400); expect(disabledRichText.text.style!.color, Colors.grey.shade400);
}); });
testWidgets('Dropdown button icon should have the passed in size and color instead of defaults', (WidgetTester tester) async { testWidgets('Dropdown button icon should have the passed in size and color instead of defaults', (WidgetTester tester) async {
...@@ -778,7 +776,7 @@ void main() { ...@@ -778,7 +776,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(buildFrame( await tester.pumpWidget(buildFrame(
...@@ -790,7 +788,7 @@ void main() { ...@@ -790,7 +788,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('Dropdown button should use its own size and color properties over those defined by the theme', (WidgetTester tester) async { testWidgets('Dropdown button should use its own size and color properties over those defined by the theme', (WidgetTester tester) async {
...@@ -817,7 +815,7 @@ void main() { ...@@ -817,7 +815,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.yellow); expect(enabledRichText.text.style!.color, Colors.yellow);
// test for disabled color // test for disabled color
await tester.pumpWidget(buildFrame( await tester.pumpWidget(buildFrame(
...@@ -829,7 +827,7 @@ void main() { ...@@ -829,7 +827,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.yellow); expect(disabledRichText.text.style!.color, Colors.yellow);
}); });
testWidgets('Dropdown button with isDense:true aligns selected menu item', (WidgetTester tester) async { testWidgets('Dropdown button with isDense:true aligns selected menu item', (WidgetTester tester) async {
...@@ -950,7 +948,7 @@ void main() { ...@@ -950,7 +948,7 @@ void main() {
testWidgets('Size of DropdownButton with null value', (WidgetTester tester) async { testWidgets('Size of DropdownButton with null value', (WidgetTester tester) async {
final Key buttonKey = UniqueKey(); final Key buttonKey = UniqueKey();
String value; String? value;
Widget build() => buildFrame(buttonKey: buttonKey, value: value, onChanged: onChanged); Widget build() => buildFrame(buttonKey: buttonKey, value: value, onChanged: onChanged);
...@@ -972,7 +970,7 @@ void main() { ...@@ -972,7 +970,7 @@ void main() {
testWidgets('Size of DropdownButton with no items', (WidgetTester tester) async { testWidgets('Size of DropdownButton with no items', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/26419 // Regression test for https://github.com/flutter/flutter/issues/26419
final Key buttonKey = UniqueKey(); final Key buttonKey = UniqueKey();
List<String> items; List<String>? items;
Widget build() => buildFrame(buttonKey: buttonKey, items: items, onChanged: onChanged); Widget build() => buildFrame(buttonKey: buttonKey, items: items, onChanged: onChanged);
...@@ -998,9 +996,9 @@ void main() { ...@@ -998,9 +996,9 @@ void main() {
testWidgets('Layout of a DropdownButton with null value', (WidgetTester tester) async { testWidgets('Layout of a DropdownButton with null value', (WidgetTester tester) async {
final Key buttonKey = UniqueKey(); final Key buttonKey = UniqueKey();
String value; String? value;
void onChanged(String newValue) { void onChanged(String? newValue) {
value = newValue; value = newValue;
} }
...@@ -1026,7 +1024,7 @@ void main() { ...@@ -1026,7 +1024,7 @@ void main() {
testWidgets('Size of DropdownButton with null value and a hint', (WidgetTester tester) async { testWidgets('Size of DropdownButton with null value and a hint', (WidgetTester tester) async {
final Key buttonKey = UniqueKey(); final Key buttonKey = UniqueKey();
String value; String? value;
// The hint will define the dropdown's width // The hint will define the dropdown's width
Widget build() => buildFrame(buttonKey: buttonKey, value: value, hint: const Text('onetwothree')); Widget build() => buildFrame(buttonKey: buttonKey, value: value, hint: const Text('onetwothree'));
...@@ -1052,10 +1050,10 @@ void main() { ...@@ -1052,10 +1050,10 @@ void main() {
// The dropdown menu isn't readily accessible. To find it we're assuming that it // The dropdown menu isn't readily accessible. To find it we're assuming that it
// contains a ListView and that it's an instance of _DropdownMenu. // contains a ListView and that it's an instance of _DropdownMenu.
Rect getMenuRect() { Rect getMenuRect() {
Rect menuRect; late Rect menuRect;
tester.element(find.byType(ListView)).visitAncestorElements((Element element) { tester.element(find.byType(ListView)).visitAncestorElements((Element element) {
if (element.toString().startsWith('_DropdownMenu')) { if (element.toString().startsWith('_DropdownMenu')) {
final RenderBox box = element.findRenderObject() as RenderBox; final RenderBox box = element.findRenderObject()! as RenderBox;
assert(box != null); assert(box != null);
menuRect = box.localToGlobal(Offset.zero) & box.size; menuRect = box.localToGlobal(Offset.zero) & box.size;
return false; return false;
...@@ -1077,8 +1075,8 @@ void main() { ...@@ -1077,8 +1075,8 @@ void main() {
return buttonPadding.inflateRect(buttonRect); return buttonPadding.inflateRect(buttonRect);
} }
Rect buttonRect; late Rect buttonRect;
Rect menuRect; late Rect menuRect;
Future<void> popUpAndDown(Widget frame) async { Future<void> popUpAndDown(Widget frame) async {
await tester.pumpWidget(frame); await tester.pumpWidget(frame);
...@@ -1197,7 +1195,7 @@ void main() { ...@@ -1197,7 +1195,7 @@ void main() {
buttonKey: key, buttonKey: key,
value: null, value: null,
items: menuItems, items: menuItems,
onChanged: (String _) { }, onChanged: (String? _) { },
hint: const Text('test'), hint: const Text('test'),
)); ));
...@@ -1309,7 +1307,7 @@ void main() { ...@@ -1309,7 +1307,7 @@ void main() {
testWidgets('disabledHint displays on empty items or onChanged', (WidgetTester tester) async { testWidgets('disabledHint displays on empty items or onChanged', (WidgetTester tester) async {
final Key buttonKey = UniqueKey(); final Key buttonKey = UniqueKey();
Widget build({ List<String> items, ValueChanged<String> onChanged }) => buildFrame( Widget build({ List<String>? items, ValueChanged<String?>? onChanged }) => buildFrame(
items: items, items: items,
onChanged: onChanged, onChanged: onChanged,
buttonKey: buttonKey, buttonKey: buttonKey,
...@@ -1349,7 +1347,7 @@ void main() { ...@@ -1349,7 +1347,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 buildFrame( return buildFrame(
items: items, items: items,
buttonKey: buttonKey, buttonKey: buttonKey,
...@@ -1371,7 +1369,7 @@ void main() { ...@@ -1371,7 +1369,7 @@ void main() {
testWidgets('DropdownButton disabledHint is null by default', (WidgetTester tester) async { testWidgets('DropdownButton 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 buildFrame( return buildFrame(
items: items, items: items,
buttonKey: buttonKey, buttonKey: buttonKey,
...@@ -1408,7 +1406,7 @@ void main() { ...@@ -1408,7 +1406,7 @@ void main() {
); );
}).toList(); }).toList();
}, },
onChanged: (String newValue) {}, onChanged: (String? newValue) {},
)); ));
final RenderBox dropdownButtonRenderBox = tester.renderObject<RenderBox>( final RenderBox dropdownButtonRenderBox = tester.renderObject<RenderBox>(
...@@ -1445,7 +1443,7 @@ void main() { ...@@ -1445,7 +1443,7 @@ void main() {
); );
}).toList(); }).toList();
}, },
onChanged: (String newValue) {}, onChanged: (String? newValue) {},
)); ));
final RenderBox dropdownButtonRenderBox = tester.renderObject<RenderBox>( final RenderBox dropdownButtonRenderBox = tester.renderObject<RenderBox>(
...@@ -1487,7 +1485,7 @@ void main() { ...@@ -1487,7 +1485,7 @@ void main() {
); );
}).toList(); }).toList();
}, },
onChanged: (String newValue) {}, onChanged: (String? newValue) {},
)); ));
final RenderBox dropdownButtonRenderBox = tester.renderObject<RenderBox>( final RenderBox dropdownButtonRenderBox = tester.renderObject<RenderBox>(
...@@ -1659,14 +1657,14 @@ void main() { ...@@ -1659,14 +1657,14 @@ void main() {
final DropdownButton<int> button = DropdownButton<int>( final DropdownButton<int> button = DropdownButton<int>(
value: 50, value: 50,
onChanged: (int newValue) { }, onChanged: (int? newValue) { },
items: items, items: items,
); );
double getMenuScroll() { double getMenuScroll() {
double scrollPosition; double scrollPosition;
final ListView listView = tester.element(find.byType(ListView)).widget as ListView; final ListView listView = tester.element(find.byType(ListView)).widget as ListView;
final ScrollController scrollController = listView.controller; final ScrollController scrollController = listView.controller!;
assert(scrollController != null); assert(scrollController != null);
scrollPosition = scrollController.position.pixels; scrollPosition = scrollController.position.pixels;
assert(scrollPosition != null); assert(scrollPosition != null);
...@@ -1696,14 +1694,14 @@ void main() { ...@@ -1696,14 +1694,14 @@ void main() {
final DropdownButton<int> button = DropdownButton<int>( final DropdownButton<int> button = DropdownButton<int>(
value: 99, value: 99,
onChanged: (int newValue) { }, onChanged: (int? newValue) { },
items: items, items: items,
); );
double getMenuScroll() { double getMenuScroll() {
double scrollPosition; double scrollPosition;
final ListView listView = tester.element(find.byType(ListView)).widget as ListView; final ListView listView = tester.element(find.byType(ListView)).widget as ListView;
final ScrollController scrollController = listView.controller; final ScrollController scrollController = listView.controller!;
assert(scrollController != null); assert(scrollController != null);
scrollPosition = scrollController.position.pixels; scrollPosition = scrollController.position.pixels;
assert(scrollPosition != null); assert(scrollPosition != null);
...@@ -1733,14 +1731,14 @@ void main() { ...@@ -1733,14 +1731,14 @@ void main() {
final DropdownButton<int> button = DropdownButton<int>( final DropdownButton<int> button = DropdownButton<int>(
value: 0, value: 0,
onChanged: (int newValue) { }, onChanged: (int? newValue) { },
items: items, items: items,
); );
double getMenuScroll() { double getMenuScroll() {
double scrollPosition; double scrollPosition;
final ListView listView = tester.element(find.byType(ListView)).widget as ListView; final ListView listView = tester.element(find.byType(ListView)).widget as ListView;
final ScrollController scrollController = listView.controller; final ScrollController scrollController = listView.controller!;
assert(scrollController != null); assert(scrollController != null);
scrollPosition = scrollController.position.pixels; scrollPosition = scrollController.position.pixels;
assert(scrollPosition != null); assert(scrollPosition != null);
...@@ -1770,14 +1768,14 @@ void main() { ...@@ -1770,14 +1768,14 @@ void main() {
final DropdownButton<int> button = DropdownButton<int>( final DropdownButton<int> button = DropdownButton<int>(
value: 99, value: 99,
onChanged: (int newValue) { }, onChanged: (int? newValue) { },
items: items, items: items,
); );
double getMenuScroll() { double getMenuScroll() {
double scrollPosition; double scrollPosition;
final ListView listView = tester.element(find.byType(ListView)).widget as ListView; final ListView listView = tester.element(find.byType(ListView)).widget as ListView;
final ScrollController scrollController = listView.controller; final ScrollController scrollController = listView.controller!;
assert(scrollController != null); assert(scrollController != null);
scrollPosition = scrollController.position.pixels; scrollPosition = scrollController.position.pixels;
assert(scrollPosition != null); assert(scrollPosition != null);
...@@ -1802,8 +1800,7 @@ void main() { ...@@ -1802,8 +1800,7 @@ void main() {
testWidgets('Dropdown menu respects parent size limits', (WidgetTester tester) async { testWidgets('Dropdown menu respects parent size limits', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/24417 // Regression test for https://github.com/flutter/flutter/issues/24417
int? selectedIndex;
int selectedIndex;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
...@@ -1821,7 +1818,9 @@ void main() { ...@@ -1821,7 +1818,9 @@ void main() {
padding: const EdgeInsetsDirectional.only(start: 16.0, end: 24.0), padding: const EdgeInsetsDirectional.only(start: 16.0, end: 24.0),
child: DropdownButton<int>( child: DropdownButton<int>(
value: 12, value: 12,
onChanged: (int i) { selectedIndex = i; }, onChanged: (int? i) {
selectedIndex = i;
},
items: List<DropdownMenuItem<int>>.generate(100, (int i) { items: List<DropdownMenuItem<int>>.generate(100, (int i) {
return DropdownMenuItem<int>(value: i, child: Text('$i')); return DropdownMenuItem<int>(value: i, child: Text('$i'));
}), }),
...@@ -1875,7 +1874,7 @@ void main() { ...@@ -1875,7 +1874,7 @@ void main() {
'Two', 'Two',
'Three', 'Three',
]; ];
String selectedItem = items[0]; String? selectedItem = items[0];
await tester.pumpWidget( await tester.pumpWidget(
StatefulBuilder( StatefulBuilder(
...@@ -1884,7 +1883,9 @@ void main() { ...@@ -1884,7 +1883,9 @@ void main() {
home: Scaffold( home: Scaffold(
body: DropdownButton<String>( body: DropdownButton<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) {
...@@ -1928,7 +1929,7 @@ void main() { ...@@ -1928,7 +1929,7 @@ void main() {
testWidgets('DropdownButton hint displays properly when selectedItemBuilder is defined', (WidgetTester tester) async { testWidgets('DropdownButton hint displays properly when selectedItemBuilder is defined', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/42340 // Regression test for https://github.com/flutter/flutter/issues/42340
final List<String> items = <String>['1', '2', '3']; final List<String> items = <String>['1', '2', '3'];
String selectedItem; String? selectedItem;
await tester.pumpWidget( await tester.pumpWidget(
StatefulBuilder( StatefulBuilder(
...@@ -1938,9 +1939,11 @@ void main() { ...@@ -1938,9 +1939,11 @@ void main() {
body: DropdownButton<String>( body: DropdownButton<String>(
hint: const Text('Please select an item'), hint: const Text('Please select an item'),
value: selectedItem, value: selectedItem,
onChanged: (String string) => setState(() { onChanged: (String? string) {
setState(() {
selectedItem = string; selectedItem = string;
}), });
},
selectedItemBuilder: (BuildContext context) { selectedItemBuilder: (BuildContext context) {
return items.map<Widget>((String item) { return items.map<Widget>((String item) {
return Text('You have selected: $item'); return Text('You have selected: $item');
...@@ -1971,7 +1974,7 @@ void main() { ...@@ -1971,7 +1974,7 @@ void main() {
testWidgets('Variable size and oversized menu items', (WidgetTester tester) async { testWidgets('Variable size and oversized menu items', (WidgetTester tester) async {
final List<double> itemHeights = <double>[30, 40, 50, 60]; final List<double> itemHeights = <double>[30, 40, 50, 60];
double dropdownValue = itemHeights[0]; double? dropdownValue = itemHeights[0];
Widget buildFrame() { Widget buildFrame() {
return MaterialApp( return MaterialApp(
...@@ -1980,7 +1983,7 @@ void main() { ...@@ -1980,7 +1983,7 @@ void main() {
child: StatefulBuilder( child: StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return DropdownButton<double>( return DropdownButton<double>(
onChanged: (double value) { onChanged: (double? value) {
setState(() { dropdownValue = value; }); setState(() { dropdownValue = value; });
}, },
value: dropdownValue, value: dropdownValue,
...@@ -2075,18 +2078,18 @@ void main() { ...@@ -2075,18 +2078,18 @@ void main() {
'two', 'two',
'three', 'three',
]; ];
String item = items[0]; String? item = items[0];
MediaQueryData mediaQuery; late MediaQueryData mediaQuery;
await tester.pumpWidget( await tester.pumpWidget(
StatefulBuilder( StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return MaterialApp( return MaterialApp(
builder: (BuildContext context, Widget child) { builder: (BuildContext context, Widget? child) {
mediaQuery ??= MediaQuery.of(context); mediaQuery = MediaQuery.of(context)!;
return MediaQuery( return MediaQuery(
data: mediaQuery, data: mediaQuery,
child: child, child: child!,
); );
}, },
home: Scaffold( home: Scaffold(
...@@ -2096,7 +2099,7 @@ void main() { ...@@ -2096,7 +2099,7 @@ void main() {
value: item, value: item,
child: Text(item), child: Text(item),
)).toList(), )).toList(),
onChanged: (String newItem) { onChanged: (String? newItem) {
setState(() { setState(() {
item = newItem; item = newItem;
mediaQuery = mediaQuery.copyWith( mediaQuery = mediaQuery.copyWith(
...@@ -2127,7 +2130,7 @@ void main() { ...@@ -2127,7 +2130,7 @@ void main() {
testWidgets('DropdownButton hint is selected item', (WidgetTester tester) async { testWidgets('DropdownButton hint is selected item', (WidgetTester tester) async {
const double hintPaddingOffset = 8; const double hintPaddingOffset = 8;
const List<String> itemValues = <String>['item0', 'item1', 'item2', 'item3']; const List<String> itemValues = <String>['item0', 'item1', 'item2', 'item3'];
String selectedItem = 'item0'; String? selectedItem = 'item0';
Widget buildFrame() { Widget buildFrame() {
return MaterialApp( return MaterialApp(
...@@ -2163,7 +2166,7 @@ void main() { ...@@ -2163,7 +2166,7 @@ void main() {
); );
}, },
), ),
onChanged: (String value) { onChanged: (String? value) {
setState(() { selectedItem = value; }); setState(() { selectedItem = value; });
}, },
icon: Container(), icon: Container(),
...@@ -2232,7 +2235,7 @@ void main() { ...@@ -2232,7 +2235,7 @@ void main() {
testWidgets('DropdownButton is activated with the enter/space key', (WidgetTester tester) async { testWidgets('DropdownButton is activated with the enter/space key', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'DropdownButton'); final FocusNode focusNode = FocusNode(debugLabel: 'DropdownButton');
String value = 'one'; String? value = 'one';
Widget buildFrame() { Widget buildFrame() {
return MaterialApp( return MaterialApp(
...@@ -2243,7 +2246,7 @@ void main() { ...@@ -2243,7 +2246,7 @@ void main() {
return DropdownButton<String>( return DropdownButton<String>(
focusNode: focusNode, focusNode: focusNode,
autofocus: true, autofocus: true,
onChanged: (String newValue) { onChanged: (String? newValue) {
setState(() { setState(() {
value = newValue; value = newValue;
}); });
...@@ -2288,7 +2291,7 @@ void main() { ...@@ -2288,7 +2291,7 @@ void main() {
testWidgets('Selected element is focused when dropdown is opened', (WidgetTester tester) async { testWidgets('Selected element is focused when dropdown is opened', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'DropdownButton'); final FocusNode focusNode = FocusNode(debugLabel: 'DropdownButton');
String value = 'one'; String? value = 'one';
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: Scaffold( home: Scaffold(
body: Center( body: Center(
...@@ -2297,7 +2300,7 @@ void main() { ...@@ -2297,7 +2300,7 @@ void main() {
return DropdownButton<String>( return DropdownButton<String>(
focusNode: focusNode, focusNode: focusNode,
autofocus: true, autofocus: true,
onChanged: (String newValue) { onChanged: (String? newValue) {
setState(() { setState(() {
value = newValue; value = newValue;
}); });
...@@ -2325,7 +2328,7 @@ void main() { ...@@ -2325,7 +2328,7 @@ void main() {
await tester.pump(); await tester.pump();
await tester.pump(const Duration(seconds: 1)); // finish the menu open animation await tester.pump(const Duration(seconds: 1)); // finish the menu open animation
expect(value, equals('one')); expect(value, equals('one'));
expect(Focus.of(tester.element(find.byKey(const ValueKey<String>('one')).last)).hasPrimaryFocus, isTrue); expect(Focus.of(tester.element(find.byKey(const ValueKey<String>('one')).last))!.hasPrimaryFocus, isTrue);
await tester.sendKeyEvent(LogicalKeyboardKey.tab); // Focus 'two' await tester.sendKeyEvent(LogicalKeyboardKey.tab); // Focus 'two'
await tester.pump(); await tester.pump();
...@@ -2342,13 +2345,13 @@ void main() { ...@@ -2342,13 +2345,13 @@ void main() {
await tester.pump(const Duration(seconds: 1)); // finish the menu open animation await tester.pump(const Duration(seconds: 1)); // finish the menu open animation
expect(value, equals('two')); expect(value, equals('two'));
final Element element = tester.element(find.byKey(const ValueKey<String>('two')).last); final Element element = tester.element(find.byKey(const ValueKey<String>('two')).last);
final FocusNode node = Focus.of(element); final FocusNode node = Focus.of(element)!;
expect(node.hasFocus, isTrue); expect(node.hasFocus, isTrue);
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/55320 }, skip: isBrowser); // https://github.com/flutter/flutter/issues/55320
testWidgets('Selected element is correctly focused with dropdown that more items than fit on the screen', (WidgetTester tester) async { testWidgets('Selected element is correctly focused with dropdown that more items than fit on the screen', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'DropdownButton'); final FocusNode focusNode = FocusNode(debugLabel: 'DropdownButton');
int value = 1; int? value = 1;
final List<int> hugeMenuItems = List<int>.generate(50, (int index) => index); final List<int> hugeMenuItems = List<int>.generate(50, (int index) => index);
await tester.pumpWidget( await tester.pumpWidget(
...@@ -2360,7 +2363,7 @@ void main() { ...@@ -2360,7 +2363,7 @@ void main() {
return DropdownButton<int>( return DropdownButton<int>(
focusNode: focusNode, focusNode: focusNode,
autofocus: true, autofocus: true,
onChanged: (int newValue) { onChanged: (int? newValue) {
setState(() { setState(() {
value = newValue; value = newValue;
}); });
...@@ -2389,7 +2392,7 @@ void main() { ...@@ -2389,7 +2392,7 @@ void main() {
await tester.pump(); await tester.pump();
await tester.pump(const Duration(seconds: 1)); // finish the menu open animation await tester.pump(const Duration(seconds: 1)); // finish the menu open animation
expect(value, equals(1)); expect(value, equals(1));
expect(Focus.of(tester.element(find.byKey(const ValueKey<int>(1)).last)).hasPrimaryFocus, isTrue); expect(Focus.of(tester.element(find.byKey(const ValueKey<int>(1)).last))!.hasPrimaryFocus, isTrue);
for (int i = 0; i < 41; ++i) { for (int i = 0; i < 41; ++i) {
await tester.sendKeyEvent(LogicalKeyboardKey.tab); // Move to the next one. await tester.sendKeyEvent(LogicalKeyboardKey.tab); // Move to the next one.
...@@ -2405,13 +2408,13 @@ void main() { ...@@ -2405,13 +2408,13 @@ void main() {
await tester.pump(const Duration(seconds: 1)); // finish the menu open animation await tester.pump(const Duration(seconds: 1)); // finish the menu open animation
expect(value, equals(42)); expect(value, equals(42));
final Element element = tester.element(find.byKey(const ValueKey<int>(42)).last); final Element element = tester.element(find.byKey(const ValueKey<int>(42)).last);
final FocusNode node = Focus.of(element); final FocusNode node = Focus.of(element)!;
expect(node.hasFocus, isTrue); expect(node.hasFocus, isTrue);
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/55320 }, skip: isBrowser); // https://github.com/flutter/flutter/issues/55320
testWidgets("Having a focused element doesn't interrupt scroll when flung by touch", (WidgetTester tester) async { testWidgets("Having a focused element doesn't interrupt scroll when flung by touch", (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'DropdownButton'); final FocusNode focusNode = FocusNode(debugLabel: 'DropdownButton');
int value = 1; int? value = 1;
final List<int> hugeMenuItems = List<int>.generate(100, (int index) => index); final List<int> hugeMenuItems = List<int>.generate(100, (int index) => index);
await tester.pumpWidget( await tester.pumpWidget(
...@@ -2423,7 +2426,7 @@ void main() { ...@@ -2423,7 +2426,7 @@ void main() {
return DropdownButton<int>( return DropdownButton<int>(
focusNode: focusNode, focusNode: focusNode,
autofocus: true, autofocus: true,
onChanged: (int newValue) { onChanged: (int? newValue) {
setState(() { setState(() {
value = newValue; value = newValue;
}); });
...@@ -2451,14 +2454,14 @@ void main() { ...@@ -2451,14 +2454,14 @@ void main() {
await tester.sendKeyEvent(LogicalKeyboardKey.enter); await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(value, equals(1)); expect(value, equals(1));
expect(Focus.of(tester.element(find.byKey(const ValueKey<int>(1)).last)).hasPrimaryFocus, isTrue); expect(Focus.of(tester.element(find.byKey(const ValueKey<int>(1)).last))!.hasPrimaryFocus, isTrue);
// Move to an item very far down the menu. // Move to an item very far down the menu.
for (int i = 0; i < 90; ++i) { for (int i = 0; i < 90; ++i) {
await tester.sendKeyEvent(LogicalKeyboardKey.tab); // Move to the next one. await tester.sendKeyEvent(LogicalKeyboardKey.tab); // Move to the next one.
await tester.pumpAndSettle(); // Wait for it to animate the menu. await tester.pumpAndSettle(); // Wait for it to animate the menu.
} }
expect(Focus.of(tester.element(find.byKey(const ValueKey<int>(91)).last)).hasPrimaryFocus, isTrue); expect(Focus.of(tester.element(find.byKey(const ValueKey<int>(91)).last))!.hasPrimaryFocus, isTrue);
// Scroll back to the top using touch, and make sure we end up there. // Scroll back to the top using touch, and make sure we end up there.
final Finder menu = find.byWidgetPredicate((Widget widget) { final Finder menu = find.byWidgetPredicate((Widget widget) {
...@@ -2480,14 +2483,14 @@ void main() { ...@@ -2480,14 +2483,14 @@ void main() {
// Scrolling to the top again has removed the one the focus was on from the // Scrolling to the top again has removed the one the focus was on from the
// tree, causing it to lose focus. // tree, causing it to lose focus.
expect(Focus.of(tester.element(find.byKey(const ValueKey<int>(91)).last)).hasPrimaryFocus, isFalse); expect(Focus.of(tester.element(find.byKey(const ValueKey<int>(91)).last))!.hasPrimaryFocus, isFalse);
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/55320 }, skip: isBrowser); // https://github.com/flutter/flutter/issues/55320
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() => buildFrame( Widget build() => buildFrame(
...@@ -2529,9 +2532,9 @@ void main() { ...@@ -2529,9 +2532,9 @@ void main() {
}); });
testWidgets('DropdownMenuItem onTap callback is called when defined', (WidgetTester tester) async { testWidgets('DropdownMenuItem onTap callback is called when defined', (WidgetTester tester) async {
String value = 'one'; String? value = 'one';
final List<int> menuItemTapCounters = <int>[0, 0, 0, 0]; final List<int> menuItemTapCounters = <int>[0, 0, 0, 0];
void onChanged(String newValue) { value = newValue; } void onChanged(String? newValue) { value = newValue; }
final List<VoidCallback> onTapCallbacks = <VoidCallback>[ final List<VoidCallback> onTapCallbacks = <VoidCallback>[
() { menuItemTapCounters[0] += 1; }, () { menuItemTapCounters[0] += 1; },
......
...@@ -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/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -44,10 +42,10 @@ void main() { ...@@ -44,10 +42,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))); expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)));
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);
expect(material.type, MaterialType.button); expect(material.type, MaterialType.button);
final Offset center = tester.getCenter(find.byType(ElevatedButton)); final Offset center = tester.getCenter(find.byType(ElevatedButton));
...@@ -67,10 +65,10 @@ void main() { ...@@ -67,10 +65,10 @@ void main() {
expect(material.elevation, 8); expect(material.elevation, 8);
expect(material.shadowColor, const Color(0xff000000)); expect(material.shadowColor, const Color(0xff000000));
expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(4))); expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)));
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);
expect(material.type, MaterialType.button); expect(material.type, MaterialType.button);
await gesture.up(); await gesture.up();
...@@ -101,10 +99,10 @@ void main() { ...@@ -101,10 +99,10 @@ void main() {
expect(material.elevation, 0.0); expect(material.elevation, 0.0);
expect(material.shadowColor, const Color(0xff000000)); expect(material.shadowColor, const Color(0xff000000));
expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(4))); expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)));
expect(material.textStyle.color, colorScheme.onSurface.withOpacity(0.38)); expect(material.textStyle!.color, colorScheme.onSurface.withOpacity(0.38));
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);
expect(material.type, MaterialType.button); expect(material.type, MaterialType.button);
}); });
...@@ -197,7 +195,7 @@ void main() { ...@@ -197,7 +195,7 @@ void main() {
); );
Color textColor() { Color textColor() {
return tester.renderObject<RenderParagraph>(find.text('ElevatedButton')).text.style.color; return tester.renderObject<RenderParagraph>(find.text('ElevatedButton')).text.style!.color!;
} }
// Default, not disabled. // Default, not disabled.
...@@ -276,7 +274,7 @@ void main() { ...@@ -276,7 +274,7 @@ void main() {
), ),
); );
Color iconColor() => _iconStyle(tester, Icons.add).color; Color iconColor() => _iconStyle(tester, Icons.add).color!;
// Default, not disabled. // Default, not disabled.
expect(iconColor(), equals(defaultColor)); expect(iconColor(), equals(defaultColor));
...@@ -307,7 +305,7 @@ void main() { ...@@ -307,7 +305,7 @@ void main() {
bool wasPressed; bool wasPressed;
Finder elevatedButton; Finder elevatedButton;
Widget buildFrame({ VoidCallback onPressed, VoidCallback onLongPress }) { Widget buildFrame({ VoidCallback? onPressed, VoidCallback? onLongPress }) {
return Directionality( return Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: ElevatedButton( child: ElevatedButton(
...@@ -385,7 +383,7 @@ void main() { ...@@ -385,7 +383,7 @@ void main() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: ElevatedButton( child: ElevatedButton(
style: ButtonStyle( style: ButtonStyle(
overlayColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) { overlayColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
return states.contains(MaterialState.hovered) ? hoverColor : null; return states.contains(MaterialState.hovered) ? hoverColor : null;
}), }),
), ),
...@@ -415,7 +413,7 @@ void main() { ...@@ -415,7 +413,7 @@ void main() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: ElevatedButton( child: ElevatedButton(
style: ButtonStyle( style: ButtonStyle(
overlayColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) { overlayColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
return states.contains(MaterialState.focused) ? focusColor : null; return states.contains(MaterialState.focused) ? focusColor : null;
}), }),
), ),
...@@ -437,7 +435,7 @@ void main() { ...@@ -437,7 +435,7 @@ void main() {
testWidgets('Does ElevatedButton work with autofocus', (WidgetTester tester) async { testWidgets('Does ElevatedButton work with autofocus', (WidgetTester tester) async {
const Color focusColor = Color(0xff001122); const Color focusColor = Color(0xff001122);
Color getOverlayColor(Set<MaterialState> states) { Color? getOverlayColor(Set<MaterialState> states) {
return states.contains(MaterialState.focused) ? focusColor : null; return states.contains(MaterialState.focused) ? focusColor : null;
} }
...@@ -448,7 +446,7 @@ void main() { ...@@ -448,7 +446,7 @@ void main() {
child: ElevatedButton( child: ElevatedButton(
autofocus: true, autofocus: true,
style: ButtonStyle( style: ButtonStyle(
overlayColor: MaterialStateProperty.resolveWith<Color>(getOverlayColor), overlayColor: MaterialStateProperty.resolveWith<Color?>(getOverlayColor),
), ),
focusNode: focusNode, focusNode: focusNode,
onPressed: () { }, onPressed: () { },
...@@ -683,7 +681,7 @@ void main() { ...@@ -683,7 +681,7 @@ void main() {
const List<double> textScaleFactorOptions = <double>[0.5, 1.0, 1.25, 1.5, 2.0, 2.5, 3.0, 4.0]; const List<double> textScaleFactorOptions = <double>[0.5, 1.0, 1.25, 1.5, 2.0, 2.5, 3.0, 4.0];
const List<TextDirection> textDirectionOptions = <TextDirection>[TextDirection.ltr, TextDirection.rtl]; const List<TextDirection> textDirectionOptions = <TextDirection>[TextDirection.ltr, TextDirection.rtl];
const List<Widget> iconOptions = <Widget>[null, Icon(Icons.add, size: 18, key: iconKey)]; const List<Widget?> iconOptions = <Widget?>[null, Icon(Icons.add, size: 18, key: iconKey)];
// Expected values for each textScaleFactor. // Expected values for each textScaleFactor.
final Map<double, double> paddingWithoutIconStart = <double, double>{ final Map<double, double> paddingWithoutIconStart = <double, double>{
...@@ -743,7 +741,7 @@ void main() { ...@@ -743,7 +741,7 @@ void main() {
} }
/// Computes the padding between two [Rect]s, one inside the other. /// Computes the padding between two [Rect]s, one inside the other.
EdgeInsets paddingBetween({ Rect parent, Rect child }) { EdgeInsets paddingBetween({ required Rect parent, required Rect child }) {
assert (parent.intersect(child) == child); assert (parent.intersect(child) == child);
return EdgeInsets.fromLTRB( return EdgeInsets.fromLTRB(
child.left - parent.left, child.left - parent.left,
...@@ -755,7 +753,7 @@ void main() { ...@@ -755,7 +753,7 @@ void main() {
for (final double textScaleFactor in textScaleFactorOptions) { for (final double textScaleFactor in textScaleFactorOptions) {
for (final TextDirection textDirection in textDirectionOptions) { for (final TextDirection textDirection in textDirectionOptions) {
for (final Widget icon in iconOptions) { for (final Widget? icon in iconOptions) {
final String testName = 'ElevatedButton' final String testName = 'ElevatedButton'
', text scale $textScaleFactor' ', text scale $textScaleFactor'
'${icon != null ? ", with icon" : ""}' '${icon != null ? ", with icon" : ""}'
...@@ -768,7 +766,7 @@ void main() { ...@@ -768,7 +766,7 @@ void main() {
home: Builder( home: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
return MediaQuery( return MediaQuery(
data: MediaQuery.of(context).copyWith( data: MediaQuery.of(context)!.copyWith(
textScaleFactor: textScaleFactor, textScaleFactor: textScaleFactor,
), ),
child: Directionality( child: Directionality(
...@@ -808,11 +806,11 @@ void main() { ...@@ -808,11 +806,11 @@ void main() {
// Compute expected padding, and check. // Compute expected padding, and check.
final double expectedStart = icon != null final double expectedStart = icon != null
? paddingWithIconStart[textScaleFactor] ? paddingWithIconStart[textScaleFactor]!
: paddingWithoutIconStart[textScaleFactor]; : paddingWithoutIconStart[textScaleFactor]!;
final double expectedEnd = icon != null final double expectedEnd = icon != null
? paddingWithIconEnd[textScaleFactor] ? paddingWithIconEnd[textScaleFactor]!
: paddingWithoutIconEnd[textScaleFactor]; : paddingWithoutIconEnd[textScaleFactor]!;
final EdgeInsets expectedPadding = EdgeInsetsDirectional.fromSTEB(expectedStart, 0, expectedEnd, 0) final EdgeInsets expectedPadding = EdgeInsetsDirectional.fromSTEB(expectedStart, 0, expectedEnd, 0)
.resolve(textDirection); .resolve(textDirection);
...@@ -823,9 +821,9 @@ void main() { ...@@ -823,9 +821,9 @@ void main() {
final RenderBox labelRenderBox = tester.renderObject<RenderBox>(find.byKey(labelKey)); final RenderBox labelRenderBox = tester.renderObject<RenderBox>(find.byKey(labelKey));
final Rect labelBounds = globalBounds(labelRenderBox); final Rect labelBounds = globalBounds(labelRenderBox);
final RenderBox iconRenderBox = icon == null ? null : tester.renderObject<RenderBox>(find.byKey(iconKey)); final RenderBox? iconRenderBox = icon == null ? null : tester.renderObject<RenderBox>(find.byKey(iconKey));
final Rect iconBounds = icon == null ? null : globalBounds(iconRenderBox); final Rect? iconBounds = icon == null ? null : globalBounds(iconRenderBox!);
final Rect childBounds = icon == null ? labelBounds : labelBounds.expandToInclude(iconBounds); final Rect childBounds = icon == null ? labelBounds : labelBounds.expandToInclude(iconBounds!);
// We measure the `InkResponse` descendant of the button // We measure the `InkResponse` descendant of the button
// element, because the button has a larger `RenderBox` // element, because the button has a larger `RenderBox`
...@@ -874,8 +872,8 @@ void main() { ...@@ -874,8 +872,8 @@ void main() {
// Check the gap between the icon and the label // Check the gap between the icon and the label
if (icon != null) { if (icon != null) {
final double gapWidth = textDirection == TextDirection.ltr final double gapWidth = textDirection == TextDirection.ltr
? labelBounds.left - iconBounds.right ? labelBounds.left - iconBounds!.right
: iconBounds.left - labelBounds.right; : iconBounds!.left - labelBounds.right;
expect(gapWidth, paddingWithIconGap[textScaleFactor]); expect(gapWidth, paddingWithIconGap[textScaleFactor]);
} }
...@@ -904,7 +902,7 @@ void main() { ...@@ -904,7 +902,7 @@ void main() {
home: Builder( home: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
return MediaQuery( return MediaQuery(
data: MediaQuery.of(context).copyWith( data: MediaQuery.of(context)!.copyWith(
textScaleFactor: 2, textScaleFactor: 2,
), ),
child: Scaffold( child: Scaffold(
...@@ -938,7 +936,7 @@ void main() { ...@@ -938,7 +936,7 @@ void main() {
final Color backgroundColor = colorScheme.primary; final Color backgroundColor = colorScheme.primary;
final Color disabledBackgroundColor = colorScheme.onSurface.withOpacity(0.12); final Color disabledBackgroundColor = colorScheme.onSurface.withOpacity(0.12);
Widget buildFrame({ bool enabled }) { Widget buildFrame({ required bool enabled }) {
return MaterialApp( return MaterialApp(
theme: ThemeData.from(colorScheme: colorScheme), theme: ThemeData.from(colorScheme: colorScheme),
home: Center( home: Center(
...@@ -983,5 +981,5 @@ TextStyle _iconStyle(WidgetTester tester, IconData icon) { ...@@ -983,5 +981,5 @@ TextStyle _iconStyle(WidgetTester tester, IconData icon) {
final RichText iconRichText = tester.widget<RichText>( final RichText iconRichText = tester.widget<RichText>(
find.descendant(of: find.byIcon(icon), matching: find.byType(RichText)), find.descendant(of: find.byIcon(icon), matching: find.byType(RichText)),
); );
return iconRichText.text.style; return iconRichText.text.style!;
} }
...@@ -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