Unverified Commit 3961a12a authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Migrate some material tests to nnbd (#67477)

parent af0c7aed
...@@ -96,8 +96,7 @@ abstract class PopupMenuEntry<T> extends StatefulWidget { ...@@ -96,8 +96,7 @@ abstract class PopupMenuEntry<T> extends StatefulWidget {
/// * [showMenu], a method to dynamically show a popup menu at a given location. /// * [showMenu], a method to dynamically show a popup menu at a given location.
/// * [PopupMenuButton], an [IconButton] that automatically shows a menu when /// * [PopupMenuButton], an [IconButton] that automatically shows a menu when
/// it is tapped. /// it is tapped.
// ignore: prefer_void_to_null, https://github.com/dart-lang/sdk/issues/34416 class PopupMenuDivider extends PopupMenuEntry<Never> {
class PopupMenuDivider extends PopupMenuEntry<Null> {
/// Creates a horizontal divider for a popup menu. /// Creates a horizontal divider for a popup menu.
/// ///
/// By default, the divider has a height of 16 logical pixels. /// By default, the divider has a height of 16 logical pixels.
......
...@@ -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';
...@@ -26,8 +24,8 @@ void main() { ...@@ -26,8 +24,8 @@ void main() {
), ),
); );
final TextStyle actualSelectedTextStyle = tester.renderObject<RenderParagraph>(find.text('Abc')).text.style; final TextStyle actualSelectedTextStyle = tester.renderObject<RenderParagraph>(find.text('Abc')).text.style!;
final TextStyle actualUnselectedTextStyle = tester.renderObject<RenderParagraph>(find.text('Def')).text.style; final TextStyle actualUnselectedTextStyle = tester.renderObject<RenderParagraph>(find.text('Def')).text.style!;
expect(actualSelectedTextStyle.fontSize, equals(selectedTextStyle.fontSize)); expect(actualSelectedTextStyle.fontSize, equals(selectedTextStyle.fontSize));
expect(actualSelectedTextStyle.fontWeight, equals(selectedTextStyle.fontWeight)); expect(actualSelectedTextStyle.fontWeight, equals(selectedTextStyle.fontWeight));
expect(actualUnselectedTextStyle.fontSize, equals(actualUnselectedTextStyle.fontSize)); expect(actualUnselectedTextStyle.fontSize, equals(actualUnselectedTextStyle.fontSize));
...@@ -1416,7 +1414,7 @@ void main() { ...@@ -1416,7 +1414,7 @@ void main() {
testWidgets('Extended rail animates the width and labels appear - [textDirection]=LTR', (WidgetTester tester) async { testWidgets('Extended rail animates the width and labels appear - [textDirection]=LTR', (WidgetTester tester) async {
bool extended = false; bool extended = false;
StateSetter stateSetter; late StateSetter stateSetter;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -1553,7 +1551,7 @@ void main() { ...@@ -1553,7 +1551,7 @@ void main() {
testWidgets('Extended rail animates the width and labels appear - [textDirection]=RTL', (WidgetTester tester) async { testWidgets('Extended rail animates the width and labels appear - [textDirection]=RTL', (WidgetTester tester) async {
bool extended = false; bool extended = false;
StateSetter stateSetter; late StateSetter stateSetter;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -1697,7 +1695,7 @@ void main() { ...@@ -1697,7 +1695,7 @@ void main() {
testWidgets('Extended rail gets wider with longer labels are larger text scale', (WidgetTester tester) async { testWidgets('Extended rail gets wider with longer labels are larger text scale', (WidgetTester tester) async {
bool extended = false; bool extended = false;
StateSetter stateSetter; late StateSetter stateSetter;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -1708,7 +1706,7 @@ void main() { ...@@ -1708,7 +1706,7 @@ void main() {
body: Row( body: Row(
children: <Widget>[ children: <Widget>[
MediaQuery( MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: 3.0), data: MediaQuery.of(context)!.copyWith(textScaleFactor: 3.0),
child: NavigationRail( child: NavigationRail(
selectedIndex: 0, selectedIndex: 0,
destinations: const <NavigationRailDestination>[ destinations: const <NavigationRailDestination>[
...@@ -1755,7 +1753,7 @@ void main() { ...@@ -1755,7 +1753,7 @@ void main() {
testWidgets('Extended rail final width can be changed', (WidgetTester tester) async { testWidgets('Extended rail final width can be changed', (WidgetTester tester) async {
bool extended = false; bool extended = false;
StateSetter stateSetter; late StateSetter stateSetter;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -1797,7 +1795,7 @@ void main() { ...@@ -1797,7 +1795,7 @@ void main() {
/// Regression test for https://github.com/flutter/flutter/issues/65657 /// Regression test for https://github.com/flutter/flutter/issues/65657
testWidgets('Extended rail transition does not jump from the beginning', (WidgetTester tester) async { testWidgets('Extended rail transition does not jump from the beginning', (WidgetTester tester) async {
bool extended = false; bool extended = false;
StateSetter stateSetter; late StateSetter stateSetter;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -1855,8 +1853,8 @@ void main() { ...@@ -1855,8 +1853,8 @@ void main() {
testWidgets('Extended rail animation can be consumed', (WidgetTester tester) async { testWidgets('Extended rail animation can be consumed', (WidgetTester tester) async {
bool extended = false; bool extended = false;
Animation<double> animation; late Animation<double> animation;
StateSetter stateSetter; late StateSetter stateSetter;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -1899,7 +1897,7 @@ void main() { ...@@ -1899,7 +1897,7 @@ void main() {
}); });
testWidgets('onDestinationSelected is called', (WidgetTester tester) async { testWidgets('onDestinationSelected is called', (WidgetTester tester) async {
int selectedIndex; late int selectedIndex;
await _pumpNavigationRail( await _pumpNavigationRail(
tester, tester,
...@@ -2106,14 +2104,14 @@ List<NavigationRailDestination> _destinations() { ...@@ -2106,14 +2104,14 @@ List<NavigationRailDestination> _destinations() {
Future<void> _pumpNavigationRail( Future<void> _pumpNavigationRail(
WidgetTester tester, { WidgetTester tester, {
double textScaleFactor = 1.0, double textScaleFactor = 1.0,
NavigationRail navigationRail, required NavigationRail navigationRail,
}) async { }) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Builder( home: Builder(
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: Scaffold( child: Scaffold(
body: Row( body: Row(
children: <Widget>[ children: <Widget>[
...@@ -2131,7 +2129,7 @@ Future<void> _pumpNavigationRail( ...@@ -2131,7 +2129,7 @@ Future<void> _pumpNavigationRail(
); );
} }
Future<void> _pumpLocalizedTestRail(WidgetTester tester, { NavigationRailLabelType labelType, bool extended = false }) async { Future<void> _pumpLocalizedTestRail(WidgetTester tester, { NavigationRailLabelType? labelType, bool extended = false }) async {
await tester.pumpWidget( await tester.pumpWidget(
Localizations( Localizations(
locale: const Locale('en', 'US'), locale: const Locale('en', 'US'),
...@@ -2184,7 +2182,7 @@ TextStyle _iconStyle(WidgetTester tester, IconData icon) { ...@@ -2184,7 +2182,7 @@ TextStyle _iconStyle(WidgetTester tester, IconData icon) {
of: find.byIcon(icon), of: find.byIcon(icon),
matching: find.byType(RichText), matching: find.byType(RichText),
), ),
).text.style; ).text.style!;
} }
Finder _opacityAboveLabel(String text) { Finder _opacityAboveLabel(String text) {
...@@ -2213,4 +2211,4 @@ Material _railMaterial(WidgetTester tester) { ...@@ -2213,4 +2211,4 @@ Material _railMaterial(WidgetTester tester) {
matching: find.byType(Material), matching: find.byType(Material),
), ),
); );
} }
\ No newline at end of file
...@@ -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/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
...@@ -271,7 +269,7 @@ TextStyle _selectedLabelStyle(WidgetTester tester) { ...@@ -271,7 +269,7 @@ TextStyle _selectedLabelStyle(WidgetTester tester) {
of: find.text('Abc'), of: find.text('Abc'),
matching: find.byType(RichText), matching: find.byType(RichText),
), ),
).text.style; ).text.style!;
} }
TextStyle _unselectedLabelStyle(WidgetTester tester) { TextStyle _unselectedLabelStyle(WidgetTester tester) {
...@@ -280,7 +278,7 @@ TextStyle _unselectedLabelStyle(WidgetTester tester) { ...@@ -280,7 +278,7 @@ TextStyle _unselectedLabelStyle(WidgetTester tester) {
of: find.text('Def'), of: find.text('Def'),
matching: find.byType(RichText), matching: find.byType(RichText),
), ),
).text.style; ).text.style!;
} }
Align _destinationsAlign(WidgetTester tester) { Align _destinationsAlign(WidgetTester tester) {
......
...@@ -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';
...@@ -40,10 +38,10 @@ void main() { ...@@ -40,10 +38,10 @@ void main() {
side: BorderSide(width: 1, color: colorScheme.onSurface.withOpacity(0.12)), side: BorderSide(width: 1, color: colorScheme.onSurface.withOpacity(0.12)),
borderRadius: BorderRadius.circular(4.0), borderRadius: BorderRadius.circular(4.0),
)); ));
expect(material.textStyle.color, colorScheme.primary); expect(material.textStyle!.color, colorScheme.primary);
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, OutlinedButton style overrides]', () { group('[Theme, TextTheme, OutlinedButton style overrides]', () {
...@@ -81,7 +79,7 @@ void main() { ...@@ -81,7 +79,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 OutlinedButton( return OutlinedButton(
...@@ -126,15 +124,15 @@ void main() { ...@@ -126,15 +124,15 @@ 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, primaryColor); expect(material.textStyle!.color, primaryColor);
expect(material.textStyle.fontSize, 12); expect(material.textStyle!.fontSize, 12);
expect(material.color, backgroundColor); expect(material.color, backgroundColor);
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), primaryColor.withOpacity(0.04)); expect(inkWell.overlayColor!.resolve(hovered), primaryColor.withOpacity(0.04));
expect(inkWell.overlayColor.resolve(focused), primaryColor.withOpacity(0.12)); expect(inkWell.overlayColor!.resolve(focused), primaryColor.withOpacity(0.12));
expect(inkWell.enableFeedback, enableFeedback); expect(inkWell.enableFeedback, enableFeedback);
expect(material.borderRadius, null); expect(material.borderRadius, null);
expect(material.shape, shape); expect(material.shape, shape);
...@@ -186,7 +184,7 @@ void main() { ...@@ -186,7 +184,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,15 +2,13 @@ ...@@ -2,15 +2,13 @@
// 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/material.dart'; import 'package:flutter/material.dart';
const Color kSelectedColor = Color(0xFF00FF00); const Color kSelectedColor = Color(0xFF00FF00);
const Color kUnselectedColor = Colors.transparent; const Color kUnselectedColor = Colors.transparent;
Widget buildFrame(TabController tabController, { Color color, Color selectedColor, double indicatorSize = 12.0 }) { Widget buildFrame(TabController tabController, { Color? color, Color? selectedColor, double indicatorSize = 12.0 }) {
return Directionality( return Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Theme( child: Theme(
......
...@@ -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/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -12,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -12,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() { void main() {
testWidgets('Default PageTransitionsTheme platform', (WidgetTester tester) async { testWidgets('Default PageTransitionsTheme platform', (WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp(home: Text('home'))); await tester.pumpWidget(const MaterialApp(home: Text('home')));
final PageTransitionsTheme theme = Theme.of(tester.element(find.text('home'))).pageTransitionsTheme; final PageTransitionsTheme theme = Theme.of(tester.element(find.text('home')))!.pageTransitionsTheme;
expect(theme.builders, isNotNull); expect(theme.builders, isNotNull);
for (final TargetPlatform platform in TargetPlatform.values) { for (final TargetPlatform platform in TargetPlatform.values) {
if (platform == TargetPlatform.fuchsia) { if (platform == TargetPlatform.fuchsia) {
...@@ -28,7 +26,7 @@ void main() { ...@@ -28,7 +26,7 @@ void main() {
'/': (BuildContext context) => Material( '/': (BuildContext context) => Material(
child: TextButton( child: TextButton(
child: const Text('push'), child: const Text('push'),
onPressed: () { Navigator.of(context).pushNamed('/b'); }, onPressed: () { Navigator.of(context)!.pushNamed('/b'); },
), ),
), ),
'/b': (BuildContext context) => const Text('page b'), '/b': (BuildContext context) => const Text('page b'),
...@@ -40,7 +38,7 @@ void main() { ...@@ -40,7 +38,7 @@ void main() {
), ),
); );
expect(Theme.of(tester.element(find.text('push'))).platform, debugDefaultTargetPlatformOverride); expect(Theme.of(tester.element(find.text('push')))!.platform, debugDefaultTargetPlatformOverride);
expect(find.byType(CupertinoPageTransition), findsOneWidget); expect(find.byType(CupertinoPageTransition), findsOneWidget);
await tester.tap(find.text('push')); await tester.tap(find.text('push'));
...@@ -54,7 +52,7 @@ void main() { ...@@ -54,7 +52,7 @@ void main() {
'/': (BuildContext context) => Material( '/': (BuildContext context) => Material(
child: TextButton( child: TextButton(
child: const Text('push'), child: const Text('push'),
onPressed: () { Navigator.of(context).pushNamed('/b'); }, onPressed: () { Navigator.of(context)!.pushNamed('/b'); },
), ),
), ),
'/b': (BuildContext context) => const Text('page b'), '/b': (BuildContext context) => const Text('page b'),
...@@ -73,7 +71,7 @@ void main() { ...@@ -73,7 +71,7 @@ void main() {
); );
} }
expect(Theme.of(tester.element(find.text('push'))).platform, debugDefaultTargetPlatformOverride); expect(Theme.of(tester.element(find.text('push')))!.platform, debugDefaultTargetPlatformOverride);
expect(findFadeUpwardsPageTransition(), findsOneWidget); expect(findFadeUpwardsPageTransition(), findsOneWidget);
await tester.tap(find.text('push')); await tester.tap(find.text('push'));
...@@ -87,7 +85,7 @@ void main() { ...@@ -87,7 +85,7 @@ void main() {
'/': (BuildContext context) => Material( '/': (BuildContext context) => Material(
child: TextButton( child: TextButton(
child: const Text('push'), child: const Text('push'),
onPressed: () { Navigator.of(context).pushNamed('/b'); }, onPressed: () { Navigator.of(context)!.pushNamed('/b'); },
), ),
), ),
'/b': (BuildContext context) => const Text('page b'), '/b': (BuildContext context) => const Text('page b'),
...@@ -113,7 +111,7 @@ void main() { ...@@ -113,7 +111,7 @@ void main() {
); );
} }
expect(Theme.of(tester.element(find.text('push'))).platform, debugDefaultTargetPlatformOverride); expect(Theme.of(tester.element(find.text('push')))!.platform, debugDefaultTargetPlatformOverride);
expect(findOpenUpwardsPageTransition(), findsOneWidget); expect(findOpenUpwardsPageTransition(), findsOneWidget);
await tester.tap(find.text('push')); await tester.tap(find.text('push'));
...@@ -127,7 +125,7 @@ void main() { ...@@ -127,7 +125,7 @@ void main() {
'/': (BuildContext context) => Material( '/': (BuildContext context) => Material(
child: TextButton( child: TextButton(
child: const Text('push'), child: const Text('push'),
onPressed: () { Navigator.of(context).pushNamed('/b'); }, onPressed: () { Navigator.of(context)!.pushNamed('/b'); },
), ),
), ),
'/b': (BuildContext context) => const Text('page b'), '/b': (BuildContext context) => const Text('page b'),
...@@ -153,7 +151,7 @@ void main() { ...@@ -153,7 +151,7 @@ void main() {
); );
} }
expect(Theme.of(tester.element(find.text('push'))).platform, debugDefaultTargetPlatformOverride); expect(Theme.of(tester.element(find.text('push')))!.platform, debugDefaultTargetPlatformOverride);
expect(findZoomPageTransition(), findsOneWidget); expect(findZoomPageTransition(), findsOneWidget);
await tester.tap(find.text('push')); await tester.tap(find.text('push'));
...@@ -171,7 +169,7 @@ void main() { ...@@ -171,7 +169,7 @@ void main() {
'/': (BuildContext context) => Material( '/': (BuildContext context) => Material(
child: TextButton( child: TextButton(
child: const Text('push'), child: const Text('push'),
onPressed: () { Navigator.of(context).pushNamed('/b'); }, onPressed: () { Navigator.of(context)!.pushNamed('/b'); },
), ),
), ),
'/b': (BuildContext context) => StatefulBuilder( '/b': (BuildContext context) => StatefulBuilder(
......
...@@ -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/gestures.dart' show DragStartBehavior; import 'package:flutter/gestures.dart' show DragStartBehavior;
...@@ -15,7 +13,7 @@ class TestDataSource extends DataTableSource { ...@@ -15,7 +13,7 @@ class TestDataSource extends DataTableSource {
this.onSelectChanged, this.onSelectChanged,
}); });
final void Function(bool) onSelectChanged; final void Function(bool?)? onSelectChanged;
int get generation => _generation; int get generation => _generation;
int _generation = 0; int _generation = 0;
...@@ -68,7 +66,7 @@ void main() { ...@@ -68,7 +66,7 @@ void main() {
availableRowsPerPage: const <int>[ availableRowsPerPage: const <int>[
2, 4, 8, 16, 2, 4, 8, 16,
], ],
onRowsPerPageChanged: (int rowsPerPage) { onRowsPerPageChanged: (int? rowsPerPage) {
log.add('rows-per-page-changed: $rowsPerPage'); log.add('rows-per-page-changed: $rowsPerPage');
}, },
onPageChanged: (int rowIndex) { onPageChanged: (int rowIndex) {
...@@ -218,7 +216,7 @@ void main() { ...@@ -218,7 +216,7 @@ void main() {
availableRowsPerPage: const <int>[ availableRowsPerPage: const <int>[
8, 9, 8, 9,
], ],
onRowsPerPageChanged: (int rowsPerPage) { }, onRowsPerPageChanged: (int? rowsPerPage) { },
columns: const <DataColumn>[ columns: const <DataColumn>[
DataColumn(label: Text('COL1')), DataColumn(label: Text('COL1')),
DataColumn(label: Text('COL2')), DataColumn(label: Text('COL2')),
...@@ -243,7 +241,7 @@ void main() { ...@@ -243,7 +241,7 @@ void main() {
source: source, source: source,
rowsPerPage: 501, rowsPerPage: 501,
availableRowsPerPage: const <int>[ 501 ], availableRowsPerPage: const <int>[ 501 ],
onRowsPerPageChanged: (int rowsPerPage) { }, onRowsPerPageChanged: (int? rowsPerPage) { },
columns: const <DataColumn>[ columns: const <DataColumn>[
DataColumn(label: Text('COL1')), DataColumn(label: Text('COL1')),
DataColumn(label: Text('COL2')), DataColumn(label: Text('COL2')),
...@@ -280,7 +278,7 @@ void main() { ...@@ -280,7 +278,7 @@ void main() {
rowsPerPage: 5, rowsPerPage: 5,
dragStartBehavior: DragStartBehavior.down, dragStartBehavior: DragStartBehavior.down,
availableRowsPerPage: const <int>[ 5 ], availableRowsPerPage: const <int>[ 5 ],
onRowsPerPageChanged: (int rowsPerPage) { }, onRowsPerPageChanged: (int? rowsPerPage) { },
columns: const <DataColumn>[ columns: const <DataColumn>[
DataColumn(label: Text('COL1')), DataColumn(label: Text('COL1')),
DataColumn(label: Text('COL2')), DataColumn(label: Text('COL2')),
...@@ -315,7 +313,7 @@ void main() { ...@@ -315,7 +313,7 @@ void main() {
availableRowsPerPage: const <int>[ availableRowsPerPage: const <int>[
2, 4, 8, 16, 2, 4, 8, 16,
], ],
onRowsPerPageChanged: (int rowsPerPage) {}, onRowsPerPageChanged: (int? rowsPerPage) {},
onPageChanged: (int rowIndex) {}, onPageChanged: (int rowIndex) {},
columns: const <DataColumn>[ columns: const <DataColumn>[
DataColumn(label: Text('Name')), DataColumn(label: Text('Name')),
...@@ -336,7 +334,7 @@ void main() { ...@@ -336,7 +334,7 @@ void main() {
availableRowsPerPage: const <int>[ availableRowsPerPage: const <int>[
2, 4, 8, 16, 2, 4, 8, 16,
], ],
onRowsPerPageChanged: (int rowsPerPage) {}, onRowsPerPageChanged: (int? rowsPerPage) {},
onPageChanged: (int rowIndex) {}, onPageChanged: (int rowIndex) {},
columns: const <DataColumn>[ columns: const <DataColumn>[
DataColumn(label: Text('Name')), DataColumn(label: Text('Name')),
...@@ -398,7 +396,7 @@ void main() { ...@@ -398,7 +396,7 @@ void main() {
await binding.setSurfaceSize(const Size(_width, _height)); await binding.setSurfaceSize(const Size(_width, _height));
final TestDataSource source = TestDataSource( final TestDataSource source = TestDataSource(
onSelectChanged: (bool value) {}, onSelectChanged: (bool? value) {},
); );
Finder cellContent; Finder cellContent;
Finder checkbox; Finder checkbox;
...@@ -412,9 +410,9 @@ void main() { ...@@ -412,9 +410,9 @@ void main() {
availableRowsPerPage: const <int>[ availableRowsPerPage: const <int>[
2, 4, 2, 4,
], ],
onRowsPerPageChanged: (int rowsPerPage) {}, onRowsPerPageChanged: (int? rowsPerPage) {},
onPageChanged: (int rowIndex) {}, onPageChanged: (int rowIndex) {},
onSelectAll: (bool value) {}, onSelectAll: (bool? value) {},
columns: const <DataColumn>[ columns: const <DataColumn>[
DataColumn(label: Text('Name')), DataColumn(label: Text('Name')),
DataColumn(label: Text('Calories'), numeric: true), DataColumn(label: Text('Calories'), numeric: true),
...@@ -481,9 +479,9 @@ void main() { ...@@ -481,9 +479,9 @@ void main() {
availableRowsPerPage: const <int>[ availableRowsPerPage: const <int>[
2, 4, 2, 4,
], ],
onRowsPerPageChanged: (int rowsPerPage) {}, onRowsPerPageChanged: (int? rowsPerPage) {},
onPageChanged: (int rowIndex) {}, onPageChanged: (int rowIndex) {},
onSelectAll: (bool value) {}, onSelectAll: (bool? value) {},
columns: const <DataColumn>[ columns: const <DataColumn>[
DataColumn(label: Text('Name')), DataColumn(label: Text('Name')),
DataColumn(label: Text('Calories'), numeric: true), DataColumn(label: Text('Calories'), numeric: true),
...@@ -564,7 +562,7 @@ void main() { ...@@ -564,7 +562,7 @@ void main() {
availableRowsPerPage: const <int>[ availableRowsPerPage: const <int>[
2, 4, 8, 16, 2, 4, 8, 16,
], ],
onRowsPerPageChanged: (int rowsPerPage) {}, onRowsPerPageChanged: (int? rowsPerPage) {},
onPageChanged: (int rowIndex) {}, onPageChanged: (int rowIndex) {},
columns: const <DataColumn>[ columns: const <DataColumn>[
DataColumn(label: Text('Name')), DataColumn(label: Text('Name')),
...@@ -620,7 +618,7 @@ void main() { ...@@ -620,7 +618,7 @@ void main() {
availableRowsPerPage: const <int>[ availableRowsPerPage: const <int>[
2, 4, 8, 16, 2, 4, 8, 16,
], ],
onRowsPerPageChanged: (int rowsPerPage) {}, onRowsPerPageChanged: (int? rowsPerPage) {},
onPageChanged: (int rowIndex) {}, onPageChanged: (int rowIndex) {},
columns: const <DataColumn>[ columns: const <DataColumn>[
DataColumn(label: Text('Name')), DataColumn(label: Text('Name')),
...@@ -691,7 +689,7 @@ void main() { ...@@ -691,7 +689,7 @@ void main() {
availableRowsPerPage: const <int>[ availableRowsPerPage: const <int>[
2, 4, 8, 16, 2, 4, 8, 16,
], ],
onRowsPerPageChanged: (int rowsPerPage) {}, onRowsPerPageChanged: (int? rowsPerPage) {},
onPageChanged: (int rowIndex) {}, onPageChanged: (int rowIndex) {},
columns: const <DataColumn>[ columns: const <DataColumn>[
DataColumn(label: Text('Name')), DataColumn(label: Text('Name')),
...@@ -735,7 +733,7 @@ void main() { ...@@ -735,7 +733,7 @@ void main() {
Widget buildTable(bool checkbox) => MaterialApp( Widget buildTable(bool checkbox) => MaterialApp(
home: PaginatedDataTable( home: PaginatedDataTable(
header: const Text('Test table'), header: const Text('Test table'),
source: TestDataSource(onSelectChanged: (bool value) {}), source: TestDataSource(onSelectChanged: (bool? value) {}),
showCheckboxColumn: checkbox, showCheckboxColumn: checkbox,
columns: const <DataColumn>[ columns: const <DataColumn>[
DataColumn(label: Text('Name')), DataColumn(label: Text('Name')),
......
...@@ -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_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -25,7 +23,6 @@ void main() { ...@@ -25,7 +23,6 @@ void main() {
testWidgets('Verify that a BottomSheet can be rebuilt with ScaffoldFeatureController.setState()', (WidgetTester tester) async { testWidgets('Verify that a BottomSheet can be rebuilt with ScaffoldFeatureController.setState()', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
PersistentBottomSheetController<void> bottomSheet;
int buildCount = 0; int buildCount = 0;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
...@@ -35,7 +32,7 @@ void main() { ...@@ -35,7 +32,7 @@ void main() {
), ),
)); ));
bottomSheet = scaffoldKey.currentState.showBottomSheet<void>((_) { final PersistentBottomSheetController<void> bottomSheet = scaffoldKey.currentState!.showBottomSheet<void>((_) {
return Builder( return Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
buildCount += 1; buildCount += 1;
...@@ -46,7 +43,7 @@ void main() { ...@@ -46,7 +43,7 @@ void main() {
await tester.pump(); await tester.pump();
expect(buildCount, equals(1)); expect(buildCount, equals(1));
bottomSheet.setState(() { }); bottomSheet.setState!(() { });
await tester.pump(); await tester.pump();
expect(buildCount, equals(2)); expect(buildCount, equals(2));
}); });
...@@ -92,7 +89,7 @@ void main() { ...@@ -92,7 +89,7 @@ void main() {
), ),
)); ));
scaffoldKey.currentState.showBottomSheet<void>((BuildContext context) { scaffoldKey.currentState!.showBottomSheet<void>((BuildContext context) {
return ListView( return ListView(
shrinkWrap: true, shrinkWrap: true,
primary: false, primary: false,
...@@ -124,7 +121,7 @@ void main() { ...@@ -124,7 +121,7 @@ void main() {
), ),
)); ));
scaffoldKey.currentState.showBottomSheet<void>((BuildContext context) { scaffoldKey.currentState!.showBottomSheet<void>((BuildContext context) {
return ListView( return ListView(
shrinkWrap: true, shrinkWrap: true,
primary: false, primary: false,
...@@ -159,7 +156,7 @@ void main() { ...@@ -159,7 +156,7 @@ void main() {
), ),
)); ));
scaffoldKey.currentState.showBottomSheet<void>( scaffoldKey.currentState!.showBottomSheet<void>(
(BuildContext context) { (BuildContext context) {
return DraggableScrollableSheet( return DraggableScrollableSheet(
expand: false, expand: false,
...@@ -313,7 +310,7 @@ void main() { ...@@ -313,7 +310,7 @@ void main() {
), ),
)); ));
scaffoldKey.currentState.showBottomSheet<void>( scaffoldKey.currentState!.showBottomSheet<void>(
(BuildContext context) { (BuildContext context) {
return DraggableScrollableSheet( return DraggableScrollableSheet(
expand: false, expand: false,
...@@ -363,7 +360,7 @@ void main() { ...@@ -363,7 +360,7 @@ void main() {
int buildCount = 0; int buildCount = 0;
showBottomSheet<void>( showBottomSheet<void>(
context: key.currentContext, context: key.currentContext!,
builder: (BuildContext context) { builder: (BuildContext context) {
return Builder( return Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
...@@ -378,8 +375,8 @@ void main() { ...@@ -378,8 +375,8 @@ void main() {
}); });
testWidgets('Scaffold removes top MediaQuery padding', (WidgetTester tester) async { testWidgets('Scaffold removes top MediaQuery padding', (WidgetTester tester) async {
BuildContext scaffoldContext; late BuildContext scaffoldContext;
BuildContext bottomSheetContext; late BuildContext bottomSheetContext;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: MediaQuery( home: MediaQuery(
...@@ -411,7 +408,7 @@ void main() { ...@@ -411,7 +408,7 @@ void main() {
await tester.pump(); await tester.pump();
expect( expect(
MediaQuery.of(bottomSheetContext).padding, MediaQuery.of(bottomSheetContext)!.padding,
const EdgeInsets.only( const EdgeInsets.only(
bottom: 50.0, bottom: 50.0,
left: 50.0, left: 50.0,
...@@ -492,7 +489,7 @@ void main() { ...@@ -492,7 +489,7 @@ void main() {
), ),
)); ));
scaffoldKey.currentState.showBottomSheet<void>((BuildContext context) { scaffoldKey.currentState!.showBottomSheet<void>((BuildContext context) {
return ListView( return ListView(
shrinkWrap: true, shrinkWrap: true,
primary: false, primary: false,
...@@ -522,7 +519,7 @@ void main() { ...@@ -522,7 +519,7 @@ void main() {
), ),
)); ));
final PersistentBottomSheetController<void> bottomSheet = scaffoldKey.currentState.showBottomSheet<void>((_) { final PersistentBottomSheetController<void> bottomSheet = scaffoldKey.currentState!.showBottomSheet<void>((_) {
return Builder( return Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
return Container(height: 200.0); return Container(height: 200.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 'dart:ui' show window, SemanticsFlag; import 'dart:ui' show window, SemanticsFlag;
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -66,7 +64,7 @@ void main() { ...@@ -66,7 +64,7 @@ void main() {
testWidgets('PopupMenuButton calls onCanceled callback when an item is not selected', (WidgetTester tester) async { testWidgets('PopupMenuButton calls onCanceled callback when an item is not selected', (WidgetTester tester) async {
int cancels = 0; int cancels = 0;
BuildContext popupContext; late BuildContext popupContext;
final Key noCallbackKey = UniqueKey(); final Key noCallbackKey = UniqueKey();
final Key withCallbackKey = UniqueKey(); final Key withCallbackKey = UniqueKey();
...@@ -125,7 +123,7 @@ void main() { ...@@ -125,7 +123,7 @@ void main() {
await tester.tap(find.byKey(withCallbackKey)); await tester.tap(find.byKey(withCallbackKey));
await tester.pump(); await tester.pump();
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
Navigator.of(popupContext).pop(); Navigator.of(popupContext)!.pop();
await tester.pump(); await tester.pump();
expect(cancels, equals(2)); expect(cancels, equals(2));
}); });
...@@ -140,7 +138,7 @@ void main() { ...@@ -140,7 +138,7 @@ void main() {
return MaterialApp( return MaterialApp(
home: Builder(builder: (BuildContext context) { home: Builder(builder: (BuildContext context) {
return MediaQuery( return MediaQuery(
data: MediaQuery.of(context).copyWith( data: MediaQuery.of(context)!.copyWith(
navigationMode: NavigationMode.directional, navigationMode: NavigationMode.directional,
), ),
child: Material( child: Material(
...@@ -191,7 +189,7 @@ void main() { ...@@ -191,7 +189,7 @@ void main() {
await tester.pumpWidget(buildApp(directional: true)); await tester.pumpWidget(buildApp(directional: true));
// Try to bring up the popup menu and select the first item from it // Try to bring up the popup menu and select the first item from it
Focus.of(popupButtonKey.currentContext).requestFocus(); Focus.of(popupButtonKey.currentContext!)!.requestFocus();
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.tap(find.byKey(popupButtonKey)); await tester.tap(find.byKey(popupButtonKey));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
...@@ -240,10 +238,10 @@ void main() { ...@@ -240,10 +238,10 @@ void main() {
), ),
), ),
); );
Focus.of(childKey.currentContext, nullOk: true).requestFocus(); Focus.of(childKey.currentContext!)!.requestFocus();
await tester.pump(); await tester.pump();
expect(Focus.of(childKey.currentContext, nullOk: true).hasPrimaryFocus, isFalse); expect(Focus.of(childKey.currentContext!)!.hasPrimaryFocus, isFalse);
expect(itemBuilderCalled, isFalse); expect(itemBuilderCalled, isFalse);
expect(onSelectedCalled, isFalse); expect(onSelectedCalled, isFalse);
}); });
...@@ -256,7 +254,7 @@ void main() { ...@@ -256,7 +254,7 @@ void main() {
MaterialApp( MaterialApp(
home: Builder(builder: (BuildContext context) { home: Builder(builder: (BuildContext context) {
return MediaQuery( return MediaQuery(
data: MediaQuery.of(context).copyWith( data: MediaQuery.of(context)!.copyWith(
navigationMode: NavigationMode.directional, navigationMode: NavigationMode.directional,
), ),
child: Material( child: Material(
...@@ -283,10 +281,10 @@ void main() { ...@@ -283,10 +281,10 @@ void main() {
}), }),
), ),
); );
Focus.of(childKey.currentContext, nullOk: true).requestFocus(); Focus.of(childKey.currentContext!)!.requestFocus();
await tester.pump(); await tester.pump();
expect(Focus.of(childKey.currentContext, nullOk: true).hasPrimaryFocus, isTrue); expect(Focus.of(childKey.currentContext!)!.hasPrimaryFocus, isTrue);
}); });
testWidgets('PopupMenuItem is only focusable when enabled', (WidgetTester tester) async { testWidgets('PopupMenuItem is only focusable when enabled', (WidgetTester tester) async {
...@@ -321,7 +319,7 @@ void main() { ...@@ -321,7 +319,7 @@ void main() {
// Open the popup to build and show the menu contents. // Open the popup to build and show the menu contents.
await tester.tap(find.byKey(popupButtonKey)); await tester.tap(find.byKey(popupButtonKey));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
final FocusNode childNode = Focus.of(childKey.currentContext, nullOk: true); final FocusNode childNode = Focus.of(childKey.currentContext!)!;
// Now that the contents are shown, request focus on the child text. // Now that the contents are shown, request focus on the child text.
childNode.requestFocus(); childNode.requestFocus();
await tester.pumpAndSettle(); await tester.pumpAndSettle();
...@@ -364,7 +362,7 @@ void main() { ...@@ -364,7 +362,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(itemBuilderCalled, isTrue); expect(itemBuilderCalled, isTrue);
expect(Focus.of(childKey.currentContext, nullOk: true).hasPrimaryFocus, isFalse); expect(Focus.of(childKey.currentContext!)!.hasPrimaryFocus, isFalse);
}); });
testWidgets('PopupMenuButton is horizontal on iOS', (WidgetTester tester) async { testWidgets('PopupMenuButton is horizontal on iOS', (WidgetTester tester) async {
...@@ -637,7 +635,7 @@ void main() { ...@@ -637,7 +635,7 @@ void main() {
}); });
testWidgets('PopupMenu removes MediaQuery padding', (WidgetTester tester) async { testWidgets('PopupMenu removes MediaQuery padding', (WidgetTester tester) async {
BuildContext popupContext; late BuildContext popupContext;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: MediaQuery( home: MediaQuery(
...@@ -674,7 +672,7 @@ void main() { ...@@ -674,7 +672,7 @@ void main() {
await tester.pump(); await tester.pump();
expect(MediaQuery.of(popupContext).padding, EdgeInsets.zero); expect(MediaQuery.of(popupContext)!.padding, EdgeInsets.zero);
}); });
testWidgets('Popup Menu Offset Test', (WidgetTester tester) async { testWidgets('Popup Menu Offset Test', (WidgetTester tester) async {
...@@ -1042,7 +1040,7 @@ void main() { ...@@ -1042,7 +1040,7 @@ void main() {
testWidgets('PopupMenuButton PopupMenuDivider', (WidgetTester tester) async { testWidgets('PopupMenuButton PopupMenuDivider', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/27072 // Regression test for https://github.com/flutter/flutter/issues/27072
String selectedValue; late String selectedValue;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
...@@ -1093,41 +1091,6 @@ void main() { ...@@ -1093,41 +1091,6 @@ void main() {
expect(selectedValue, '2'); expect(selectedValue, '2');
}); });
testWidgets('showMenu position required', (WidgetTester tester) async {
// Test for https://github.com/flutter/flutter/issues/22256
await tester.pumpWidget(
MaterialApp(
home: Material(
child: Center(
child: Builder(
builder: (BuildContext context) {
return ElevatedButton(
onPressed: () {
// Ensure showMenu throws an assertion without a position
expect(() {
// ignore: missing_required_param
showMenu<int>(
context: context,
items: <PopupMenuItem<int>>[
const PopupMenuItem<int>(
value: 1, child: Text('1'),
),
],
);
}, throwsAssertionError);
},
child: const Text('Menu Button'),
);
},
),
),
),
),
);
await tester.tap(find.text('Menu Button'));
});
testWidgets('PopupMenuItem child height is a minimum, child is vertically centered', (WidgetTester tester) async { testWidgets('PopupMenuItem child height is a minimum, child is vertically centered', (WidgetTester tester) async {
final Key popupMenuButtonKey = UniqueKey(); final Key popupMenuButtonKey = UniqueKey();
final Type menuItemType = const PopupMenuItem<String>(child: Text('item')).runtimeType; final Type menuItemType = const PopupMenuItem<String>(child: Text('item')).runtimeType;
...@@ -1219,14 +1182,14 @@ void main() { ...@@ -1219,14 +1182,14 @@ void main() {
double fontSize = 24, double fontSize = 24,
}) { }) {
return MaterialApp( return MaterialApp(
builder: (BuildContext context, Widget child) { builder: (BuildContext context, Widget? child) {
return Directionality( return Directionality(
textDirection: textDirection, textDirection: textDirection,
child: PopupMenuTheme( child: PopupMenuTheme(
data: PopupMenuTheme.of(context).copyWith( data: PopupMenuTheme.of(context).copyWith(
textStyle: Theme.of(context).textTheme.subtitle1.copyWith(fontSize: fontSize), textStyle: Theme.of(context)!.textTheme.subtitle1!.copyWith(fontSize: fontSize),
), ),
child: child, child: child!,
), ),
); );
}, },
...@@ -1533,7 +1496,7 @@ void main() { ...@@ -1533,7 +1496,7 @@ void main() {
expect(find.text('Tap me please!'), findsNothing); expect(find.text('Tap me please!'), findsNothing);
globalKey.currentState.showButtonMenu(); globalKey.currentState!.showButtonMenu();
// The PopupMenuItem will appear after an animation, hence, // The PopupMenuItem will appear after an animation, hence,
// we have to first wait for the tester to settle. // we have to first wait for the tester to settle.
await tester.pumpAndSettle(); await tester.pumpAndSettle();
...@@ -1571,7 +1534,7 @@ void main() { ...@@ -1571,7 +1534,7 @@ void main() {
await tester.pump(); await tester.pump();
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text); expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
// Test default cursor // Test default cursor
await tester.pumpWidget( await tester.pumpWidget(
...@@ -1594,7 +1557,7 @@ void main() { ...@@ -1594,7 +1557,7 @@ void main() {
), ),
); );
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click); expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click);
// Test default cursor when disabled // Test default cursor when disabled
await tester.pumpWidget( await tester.pumpWidget(
...@@ -1618,19 +1581,19 @@ void main() { ...@@ -1618,19 +1581,19 @@ void main() {
), ),
); );
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic); expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
}); });
} }
class TestApp extends StatefulWidget { class TestApp extends StatefulWidget {
const TestApp({ const TestApp({
Key key, Key? key,
this.textDirection, required this.textDirection,
this.child, this.child,
}) : super(key: key); }) : super(key: key);
final TextDirection textDirection; final TextDirection textDirection;
final Widget child; final Widget? child;
@override @override
_TestAppState createState() => _TestAppState(); _TestAppState createState() => _TestAppState();
...@@ -1670,7 +1633,7 @@ class MenuObserver extends NavigatorObserver { ...@@ -1670,7 +1633,7 @@ class MenuObserver extends NavigatorObserver {
int menuCount = 0; int menuCount = 0;
@override @override
void didPush(Route<dynamic> route, Route<dynamic> previousRoute) { void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {
if (route.toString().contains('_PopupMenuRoute')) { if (route.toString().contains('_PopupMenuRoute')) {
menuCount++; menuCount++;
} }
......
...@@ -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';
...@@ -79,7 +77,7 @@ void main() { ...@@ -79,7 +77,7 @@ void main() {
PopupMenuButton<void>( PopupMenuButton<void>(
key: popupButtonKey, key: popupButtonKey,
itemBuilder: (BuildContext context) { itemBuilder: (BuildContext context) {
return <PopupMenuEntry<Object>>[ return <PopupMenuEntry<void>>[
PopupMenuItem<void>( PopupMenuItem<void>(
key: popupItemKey, key: popupItemKey,
child: const Text('Example'), child: const Text('Example'),
...@@ -139,7 +137,7 @@ void main() { ...@@ -139,7 +137,7 @@ void main() {
key: popupButtonKey, key: popupButtonKey,
itemBuilder: (BuildContext context) { itemBuilder: (BuildContext context) {
return <PopupMenuEntry<Object>>[ return <PopupMenuEntry<Object>>[
PopupMenuItem<void>( PopupMenuItem<Object>(
key: popupItemKey, key: popupItemKey,
child: const Text('Example'), child: const Text('Example'),
), ),
...@@ -206,7 +204,7 @@ void main() { ...@@ -206,7 +204,7 @@ void main() {
color: color, color: color,
shape: shape, shape: shape,
itemBuilder: (BuildContext context) { itemBuilder: (BuildContext context) {
return <PopupMenuEntry<Object>>[ return <PopupMenuEntry<void>>[
PopupMenuItem<void>( PopupMenuItem<void>(
key: popupItemKey, key: popupItemKey,
textStyle: textStyle, textStyle: textStyle,
...@@ -270,7 +268,7 @@ void main() { ...@@ -270,7 +268,7 @@ void main() {
child: PopupMenuButton<void>( child: PopupMenuButton<void>(
key: popupButtonKey, key: popupButtonKey,
itemBuilder: (BuildContext context) { itemBuilder: (BuildContext context) {
return <PopupMenuEntry<Object>>[ return <PopupMenuEntry<void>>[
PopupMenuItem<void>( PopupMenuItem<void>(
key: popupItemKey, key: popupItemKey,
child: const Text('Example'), child: const Text('Example'),
......
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