Unverified Commit c083f02f authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

Migrate more material tests to NNBD (#67674)

This migrates more material tests to NNBD.
parent dcb5975d
...@@ -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:async'; import 'dart:async';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -733,7 +731,7 @@ class LicensePageObserver extends NavigatorObserver { ...@@ -733,7 +731,7 @@ class LicensePageObserver extends NavigatorObserver {
int licensePageCount = 0; int licensePageCount = 0;
@override @override
void didPush(Route<dynamic> route, Route<dynamic> previousRoute) { void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {
if (route is MaterialPageRoute<dynamic>) { if (route is MaterialPageRoute<dynamic>) {
licensePageCount++; licensePageCount++;
} }
...@@ -745,7 +743,7 @@ class AboutDialogObserver extends NavigatorObserver { ...@@ -745,7 +743,7 @@ class AboutDialogObserver 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++;
} }
......
...@@ -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 show pi; import 'dart:math' as math show pi;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -13,8 +11,8 @@ import '../flutter_test_alternative.dart' show Fake; ...@@ -13,8 +11,8 @@ import '../flutter_test_alternative.dart' show Fake;
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
class MockCanvas extends Fake implements Canvas { class MockCanvas extends Fake implements Canvas {
Path capturedPath; late Path capturedPath;
Paint capturedPaint; late Paint capturedPaint;
@override @override
void drawPath(Path path, Paint paint) { void drawPath(Path path, Paint paint) {
...@@ -22,13 +20,13 @@ class MockCanvas extends Fake implements Canvas { ...@@ -22,13 +20,13 @@ class MockCanvas extends Fake implements Canvas {
capturedPaint = paint; capturedPaint = paint;
} }
double capturedSx; late double capturedSx;
double capturedSy; late double capturedSy;
@override @override
void scale(double sx, [double sy]) { void scale(double sx, [double? sy]) {
capturedSx = sx; capturedSx = sx;
capturedSy = sy; capturedSy = sy!;
} }
final List<RecordedCanvasCall> invocations = <RecordedCanvasCall>[]; final List<RecordedCanvasCall> invocations = <RecordedCanvasCall>[];
...@@ -96,7 +94,7 @@ void main() { ...@@ -96,7 +94,7 @@ void main() {
); );
final CustomPaint customPaint = tester.widget(find.byType(CustomPaint)); final CustomPaint customPaint = tester.widget(find.byType(CustomPaint));
final MockCanvas canvas = MockCanvas(); final MockCanvas canvas = MockCanvas();
customPaint.painter.paint(canvas, const Size(48.0, 48.0)); customPaint.painter!.paint(canvas, const Size(48.0, 48.0));
expect(canvas.capturedPaint, hasColor(0xFF666666)); expect(canvas.capturedPaint, hasColor(0xFF666666));
}); });
...@@ -118,7 +116,7 @@ void main() { ...@@ -118,7 +116,7 @@ void main() {
); );
final CustomPaint customPaint = tester.widget(find.byType(CustomPaint)); final CustomPaint customPaint = tester.widget(find.byType(CustomPaint));
final MockCanvas canvas = MockCanvas(); final MockCanvas canvas = MockCanvas();
customPaint.painter.paint(canvas, const Size(48.0, 48.0)); customPaint.painter!.paint(canvas, const Size(48.0, 48.0));
expect(canvas.capturedPaint, hasColor(0x80666666)); expect(canvas.capturedPaint, hasColor(0x80666666));
}); });
...@@ -140,7 +138,7 @@ void main() { ...@@ -140,7 +138,7 @@ void main() {
); );
final CustomPaint customPaint = tester.widget(find.byType(CustomPaint)); final CustomPaint customPaint = tester.widget(find.byType(CustomPaint));
final MockCanvas canvas = MockCanvas(); final MockCanvas canvas = MockCanvas();
customPaint.painter.paint(canvas, const Size(48.0, 48.0)); customPaint.painter!.paint(canvas, const Size(48.0, 48.0));
expect(canvas.capturedPaint, hasColor(0xFF0000FF)); expect(canvas.capturedPaint, hasColor(0xFF0000FF));
}); });
...@@ -162,7 +160,7 @@ void main() { ...@@ -162,7 +160,7 @@ void main() {
); );
final CustomPaint customPaint = tester.widget(find.byType(CustomPaint)); final CustomPaint customPaint = tester.widget(find.byType(CustomPaint));
final MockCanvas canvas = MockCanvas(); final MockCanvas canvas = MockCanvas();
customPaint.painter.paint(canvas, const Size(12.0, 12.0)); customPaint.painter!.paint(canvas, const Size(12.0, 12.0));
// arrow_menu default size is 48x48 so we expect it to be scaled by 0.25. // arrow_menu default size is 48x48 so we expect it to be scaled by 0.25.
expect(canvas.capturedSx, 0.25); expect(canvas.capturedSx, 0.25);
expect(canvas.capturedSy, 0.25); expect(canvas.capturedSy, 0.25);
...@@ -187,7 +185,7 @@ void main() { ...@@ -187,7 +185,7 @@ void main() {
); );
final CustomPaint customPaint = tester.widget(find.byType(CustomPaint)); final CustomPaint customPaint = tester.widget(find.byType(CustomPaint));
final MockCanvas canvas = MockCanvas(); final MockCanvas canvas = MockCanvas();
customPaint.painter.paint(canvas, const Size(12.0, 12.0)); customPaint.painter!.paint(canvas, const Size(12.0, 12.0));
// arrow_menu default size is 48x48 so we expect it to be scaled by 2. // arrow_menu default size is 48x48 so we expect it to be scaled by 2.
expect(canvas.capturedSx, 2); expect(canvas.capturedSx, 2);
expect(canvas.capturedSy, 2); expect(canvas.capturedSy, 2);
...@@ -230,7 +228,7 @@ void main() { ...@@ -230,7 +228,7 @@ void main() {
); );
final CustomPaint customPaint = tester.widget(find.byType(CustomPaint)); final CustomPaint customPaint = tester.widget(find.byType(CustomPaint));
final MockCanvas canvas = MockCanvas(); final MockCanvas canvas = MockCanvas();
customPaint.painter.paint(canvas, const Size(48.0, 48.0)); customPaint.painter!.paint(canvas, const Size(48.0, 48.0));
expect(canvas.invocations, const <RecordedCanvasCall>[ expect(canvas.invocations, const <RecordedCanvasCall>[
RecordedRotate(math.pi), RecordedRotate(math.pi),
RecordedTranslate(-48, -48), RecordedTranslate(-48, -48),
...@@ -254,7 +252,7 @@ void main() { ...@@ -254,7 +252,7 @@ void main() {
); );
final CustomPaint customPaint = tester.widget(find.byType(CustomPaint)); final CustomPaint customPaint = tester.widget(find.byType(CustomPaint));
final MockCanvas canvas = MockCanvas(); final MockCanvas canvas = MockCanvas();
customPaint.painter.paint(canvas, const Size(48.0, 48.0)); customPaint.painter!.paint(canvas, const Size(48.0, 48.0));
expect(canvas.invocations, isEmpty); expect(canvas.invocations, isEmpty);
}); });
...@@ -276,7 +274,7 @@ void main() { ...@@ -276,7 +274,7 @@ void main() {
); );
final CustomPaint customPaint = tester.widget(find.byType(CustomPaint)); final CustomPaint customPaint = tester.widget(find.byType(CustomPaint));
final MockCanvas canvas = MockCanvas(); final MockCanvas canvas = MockCanvas();
customPaint.painter.paint(canvas, const Size(48.0, 48.0)); customPaint.painter!.paint(canvas, const Size(48.0, 48.0));
expect(canvas.invocations, const <RecordedCanvasCall>[ expect(canvas.invocations, const <RecordedCanvasCall>[
RecordedRotate(math.pi), RecordedRotate(math.pi),
RecordedTranslate(-48, -48), RecordedTranslate(-48, -48),
......
...@@ -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';
...@@ -14,10 +12,10 @@ import '../rendering/mock_canvas.dart'; ...@@ -14,10 +12,10 @@ import '../rendering/mock_canvas.dart';
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
Widget buildSliverAppBarApp({ Widget buildSliverAppBarApp({
bool floating, bool floating = false,
bool pinned, bool pinned = false,
double collapsedHeight, double? collapsedHeight,
double expandedHeight, double? expandedHeight,
bool snap = false, bool snap = false,
double toolbarHeight = kToolbarHeight, double toolbarHeight = kToolbarHeight,
}) { }) {
...@@ -65,7 +63,7 @@ Widget buildSliverAppBarApp({ ...@@ -65,7 +63,7 @@ Widget buildSliverAppBarApp({
} }
ScrollController primaryScrollController(WidgetTester tester) { ScrollController primaryScrollController(WidgetTester tester) {
return PrimaryScrollController.of(tester.element(find.byType(CustomScrollView))); return PrimaryScrollController.of(tester.element(find.byType(CustomScrollView)))!;
} }
double appBarHeight(WidgetTester tester) => tester.getSize(find.byType(AppBar, skipOffstage: false)).height; double appBarHeight(WidgetTester tester) => tester.getSize(find.byType(AppBar, skipOffstage: false)).height;
...@@ -303,7 +301,7 @@ void main() { ...@@ -303,7 +301,7 @@ void main() {
final Key titleKey = UniqueKey(); final Key titleKey = UniqueKey();
Widget leading = Container(); Widget leading = Container();
List<Widget> actions; List<Widget> actions = <Widget>[];
Widget buildApp() { Widget buildApp() {
return MaterialApp( return MaterialApp(
...@@ -360,8 +358,8 @@ void main() { ...@@ -360,8 +358,8 @@ void main() {
final Key titleKey = UniqueKey(); final Key titleKey = UniqueKey();
double titleWidth = 700.0; double titleWidth = 700.0;
Widget leading = Container(); Widget? leading = Container();
List<Widget> actions; List<Widget> actions = <Widget>[];
Widget buildApp() { Widget buildApp() {
return MaterialApp( return MaterialApp(
...@@ -412,8 +410,8 @@ void main() { ...@@ -412,8 +410,8 @@ void main() {
final Key titleKey = UniqueKey(); final Key titleKey = UniqueKey();
double titleWidth = 700.0; double titleWidth = 700.0;
Widget leading = Container(); Widget? leading = Container();
List<Widget> actions; List<Widget> actions = <Widget>[];
Widget buildApp() { Widget buildApp() {
return MaterialApp( return MaterialApp(
...@@ -1952,14 +1950,14 @@ void main() { ...@@ -1952,14 +1950,14 @@ void main() {
}); });
testWidgets('AppBars title has upper limit on text scaling, textScaleFactor = 1, 1.34, 2', (WidgetTester tester) async { testWidgets('AppBars title has upper limit on text scaling, textScaleFactor = 1, 1.34, 2', (WidgetTester tester) async {
double textScaleFactor; late double textScaleFactor;
Widget buildFrame() { Widget buildFrame() {
return MaterialApp( return 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(
appBar: AppBar( appBar: AppBar(
centerTitle: false, centerTitle: false,
...@@ -1988,9 +1986,9 @@ void main() { ...@@ -1988,9 +1986,9 @@ void main() {
}); });
testWidgets('AppBars with jumbo titles, textScaleFactor = 3, 3.5, 4', (WidgetTester tester) async { testWidgets('AppBars with jumbo titles, textScaleFactor = 3, 3.5, 4', (WidgetTester tester) async {
double textScaleFactor; double textScaleFactor = 1.0;
TextDirection textDirection; TextDirection textDirection = TextDirection.ltr;
bool centerTitle; bool centerTitle = false;
Widget buildFrame() { Widget buildFrame() {
return MaterialApp( return MaterialApp(
...@@ -2004,7 +2002,7 @@ void main() { ...@@ -2004,7 +2002,7 @@ void main() {
appBar: AppBar( appBar: AppBar(
centerTitle: centerTitle, centerTitle: centerTitle,
title: MediaQuery( title: MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: textScaleFactor), data: MediaQuery.of(context)!.copyWith(textScaleFactor: textScaleFactor),
child: const Text('Jumbo'), child: const Text('Jumbo'),
), ),
), ),
...@@ -2023,10 +2021,8 @@ void main() { ...@@ -2023,10 +2021,8 @@ void main() {
// Overall screen size is 800x600 // Overall screen size is 800x600
// Left or right justified title is padded by 16 on the "start" side. // Left or right justified title is padded by 16 on the "start" side.
// Toolbar height is 56. // Toolbar height is 56.
// "Jumbo" title is 100x20.
textScaleFactor = 1; // "Jumbo" title is 100x20.
textDirection = TextDirection.ltr;
centerTitle = false;
await tester.pumpWidget(buildFrame()); await tester.pumpWidget(buildFrame());
expect(tester.getRect(appBarTitle), const Rect.fromLTRB(16, 18, 116, 38)); expect(tester.getRect(appBarTitle), const Rect.fromLTRB(16, 18, 116, 38));
expect(tester.getCenter(appBarTitle).dy, tester.getCenter(toolbar).dy); expect(tester.getCenter(appBarTitle).dy, tester.getCenter(toolbar).dy);
...@@ -2058,7 +2054,7 @@ void main() { ...@@ -2058,7 +2054,7 @@ void main() {
}); });
testWidgets('SliverAppBar configures the delegate properly', (WidgetTester tester) async { testWidgets('SliverAppBar configures the delegate properly', (WidgetTester tester) async {
Future<void> buildAndVerifyDelegate({ bool pinned, bool floating, bool snap }) async { Future<void> buildAndVerifyDelegate({ required bool pinned, required bool floating, required bool snap }) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: CustomScrollView( home: CustomScrollView(
...@@ -2150,17 +2146,6 @@ void main() { ...@@ -2150,17 +2146,6 @@ void main() {
expect(appBarHeight(tester), collapsedHeight + initialTabBarHeight); expect(appBarHeight(tester), collapsedHeight + initialTabBarHeight);
}); });
test('SliverApp toolbarHeight cannot be null', () {
try{
SliverAppBar(
toolbarHeight: null,
);
} on AssertionError catch (error) {
expect(error.toString(), contains('toolbarHeight != null'));
expect(error.toString(), contains('is not true'));
}
});
testWidgets('AppBar respects leadingWidth', (WidgetTester tester) async { testWidgets('AppBar respects leadingWidth', (WidgetTester tester) async {
const Key key = Key('leading'); const Key key = Key('leading');
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
......
...@@ -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/services.dart'; import 'package:flutter/services.dart';
...@@ -31,14 +29,14 @@ void main() { ...@@ -31,14 +29,14 @@ void main() {
final RichText actionIconText = _getAppBarIconRichText(tester); final RichText actionIconText = _getAppBarIconRichText(tester);
final DefaultTextStyle text = _getAppBarText(tester); final DefaultTextStyle text = _getAppBarText(tester);
expect(SystemChrome.latestStyle.statusBarBrightness, Brightness.dark); expect(SystemChrome.latestStyle!.statusBarBrightness, Brightness.dark);
expect(widget.color, Colors.blue); expect(widget.color, Colors.blue);
expect(widget.elevation, 4.0); expect(widget.elevation, 4.0);
expect(widget.shadowColor, Colors.black); expect(widget.shadowColor, Colors.black);
expect(iconTheme.data, const IconThemeData(color: Colors.white)); expect(iconTheme.data, const IconThemeData(color: Colors.white));
expect(actionsIconTheme.data, const IconThemeData(color: Colors.white)); expect(actionsIconTheme.data, const IconThemeData(color: Colors.white));
expect(actionIconText.text.style.color, Colors.white); expect(actionIconText.text.style!.color, Colors.white);
expect(text.style, Typography.material2014().englishLike.bodyText2.merge(Typography.material2014().white.bodyText2)); expect(text.style, Typography.material2014().englishLike.bodyText2!.merge(Typography.material2014().white.bodyText2));
}); });
testWidgets('AppBar uses values from AppBarTheme', (WidgetTester tester) async { testWidgets('AppBar uses values from AppBarTheme', (WidgetTester tester) async {
...@@ -60,14 +58,14 @@ void main() { ...@@ -60,14 +58,14 @@ void main() {
final RichText actionIconText = _getAppBarIconRichText(tester); final RichText actionIconText = _getAppBarIconRichText(tester);
final DefaultTextStyle text = _getAppBarText(tester); final DefaultTextStyle text = _getAppBarText(tester);
expect(SystemChrome.latestStyle.statusBarBrightness, appBarTheme.brightness); expect(SystemChrome.latestStyle!.statusBarBrightness, appBarTheme.brightness);
expect(widget.color, appBarTheme.color); expect(widget.color, appBarTheme.color);
expect(widget.elevation, appBarTheme.elevation); expect(widget.elevation, appBarTheme.elevation);
expect(widget.shadowColor, appBarTheme.shadowColor); expect(widget.shadowColor, appBarTheme.shadowColor);
expect(iconTheme.data, appBarTheme.iconTheme); expect(iconTheme.data, appBarTheme.iconTheme);
expect(actionsIconTheme.data, appBarTheme.actionsIconTheme); expect(actionsIconTheme.data, appBarTheme.actionsIconTheme);
expect(actionIconText.text.style.color, appBarTheme.actionsIconTheme.color); expect(actionIconText.text.style!.color, appBarTheme.actionsIconTheme!.color);
expect(text.style, appBarTheme.textTheme.bodyText2); expect(text.style, appBarTheme.textTheme!.bodyText2);
}); });
testWidgets('AppBar widget properties take priority over theme', (WidgetTester tester) async { testWidgets('AppBar widget properties take priority over theme', (WidgetTester tester) async {
...@@ -103,13 +101,13 @@ void main() { ...@@ -103,13 +101,13 @@ void main() {
final RichText actionIconText = _getAppBarIconRichText(tester); final RichText actionIconText = _getAppBarIconRichText(tester);
final DefaultTextStyle text = _getAppBarText(tester); final DefaultTextStyle text = _getAppBarText(tester);
expect(SystemChrome.latestStyle.statusBarBrightness, brightness); expect(SystemChrome.latestStyle!.statusBarBrightness, brightness);
expect(widget.color, color); expect(widget.color, color);
expect(widget.elevation, elevation); expect(widget.elevation, elevation);
expect(widget.shadowColor, shadowColor); expect(widget.shadowColor, shadowColor);
expect(iconTheme.data, iconThemeData); expect(iconTheme.data, iconThemeData);
expect(actionsIconTheme.data, actionsIconThemeData); expect(actionsIconTheme.data, actionsIconThemeData);
expect(actionIconText.text.style.color, actionsIconThemeData.color); expect(actionIconText.text.style!.color, actionsIconThemeData.color);
expect(text.style, textTheme.bodyText2); expect(text.style, textTheme.bodyText2);
}); });
...@@ -132,7 +130,7 @@ void main() { ...@@ -132,7 +130,7 @@ void main() {
)); ));
final RichText actionIconText = _getAppBarIconRichText(tester); final RichText actionIconText = _getAppBarIconRichText(tester);
expect(actionIconText.text.style.color, color); expect(actionIconText.text.style!.color, color);
}); });
testWidgets('AppBarTheme properties take priority over ThemeData properties', (WidgetTester tester) async { testWidgets('AppBarTheme properties take priority over ThemeData properties', (WidgetTester tester) async {
...@@ -154,14 +152,14 @@ void main() { ...@@ -154,14 +152,14 @@ void main() {
final RichText actionIconText = _getAppBarIconRichText(tester); final RichText actionIconText = _getAppBarIconRichText(tester);
final DefaultTextStyle text = _getAppBarText(tester); final DefaultTextStyle text = _getAppBarText(tester);
expect(SystemChrome.latestStyle.statusBarBrightness, appBarTheme.brightness); expect(SystemChrome.latestStyle!.statusBarBrightness, appBarTheme.brightness);
expect(widget.color, appBarTheme.color); expect(widget.color, appBarTheme.color);
expect(widget.elevation, appBarTheme.elevation); expect(widget.elevation, appBarTheme.elevation);
expect(widget.shadowColor, appBarTheme.shadowColor); expect(widget.shadowColor, appBarTheme.shadowColor);
expect(iconTheme.data, appBarTheme.iconTheme); expect(iconTheme.data, appBarTheme.iconTheme);
expect(actionsIconTheme.data, appBarTheme.actionsIconTheme); expect(actionsIconTheme.data, appBarTheme.actionsIconTheme);
expect(actionIconText.text.style.color, appBarTheme.actionsIconTheme.color); expect(actionIconText.text.style!.color, appBarTheme.actionsIconTheme!.color);
expect(text.style, appBarTheme.textTheme.bodyText2); expect(text.style, appBarTheme.textTheme!.bodyText2);
}); });
testWidgets('ThemeData properties are used when no AppBarTheme is set', (WidgetTester tester) async { testWidgets('ThemeData properties are used when no AppBarTheme is set', (WidgetTester tester) async {
...@@ -182,15 +180,15 @@ void main() { ...@@ -182,15 +180,15 @@ void main() {
final RichText actionIconText = _getAppBarIconRichText(tester); final RichText actionIconText = _getAppBarIconRichText(tester);
final DefaultTextStyle text = _getAppBarText(tester); final DefaultTextStyle text = _getAppBarText(tester);
expect(SystemChrome.latestStyle.statusBarBrightness, themeData.brightness); expect(SystemChrome.latestStyle!.statusBarBrightness, themeData.brightness);
expect(widget.color, themeData.primaryColor); expect(widget.color, themeData.primaryColor);
expect(widget.elevation, 4.0); expect(widget.elevation, 4.0);
expect(widget.shadowColor, Colors.black); expect(widget.shadowColor, Colors.black);
expect(iconTheme.data, themeData.primaryIconTheme); expect(iconTheme.data, themeData.primaryIconTheme);
expect(actionsIconTheme.data, themeData.primaryIconTheme); expect(actionsIconTheme.data, themeData.primaryIconTheme);
expect(actionIconText.text.style.color, themeData.primaryIconTheme.color); expect(actionIconText.text.style!.color, themeData.primaryIconTheme.color);
// Default value for ThemeData.typography is Typography.material2014() // Default value for ThemeData.typography is Typography.material2014()
expect(text.style, Typography.material2014().englishLike.bodyText2.merge(Typography.material2014().white.bodyText2).merge(themeData.primaryTextTheme.bodyText2)); expect(text.style, Typography.material2014().englishLike.bodyText2!.merge(Typography.material2014().white.bodyText2).merge(themeData.primaryTextTheme.bodyText2));
}); });
testWidgets('AppBar uses AppBarTheme.centerTitle when centerTitle is null', (WidgetTester tester) async { testWidgets('AppBar uses AppBarTheme.centerTitle when centerTitle is null', (WidgetTester tester) async {
......
...@@ -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';
...@@ -15,9 +13,9 @@ void main() { ...@@ -15,9 +13,9 @@ void main() {
primarySwatch: Colors.green, primarySwatch: Colors.green,
), ),
home: const Placeholder(), home: const Placeholder(),
builder: (BuildContext context, Widget child) { builder: (BuildContext context, Widget? child) {
log.add('build'); log.add('build');
expect(Theme.of(context).primaryColor, Colors.green); expect(Theme.of(context)!.primaryColor, Colors.green);
expect(Directionality.of(context), TextDirection.ltr); expect(Directionality.of(context), TextDirection.ltr);
expect(child, isA<Navigator>()); expect(child, isA<Navigator>());
return const Placeholder(); return const Placeholder();
...@@ -49,15 +47,15 @@ void main() { ...@@ -49,15 +47,15 @@ void main() {
home: Builder( home: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
log.add('build'); log.add('build');
expect(Theme.of(context).primaryColor, Colors.yellow); expect(Theme.of(context)!.primaryColor, Colors.yellow);
expect(Directionality.of(context), TextDirection.rtl); expect(Directionality.of(context), TextDirection.rtl);
return const Placeholder(); return const Placeholder();
}, },
), ),
builder: (BuildContext context, Widget child) { builder: (BuildContext context, Widget? child) {
return Directionality( return Directionality(
textDirection: TextDirection.rtl, textDirection: TextDirection.rtl,
child: child, child: child!,
); );
}, },
), ),
......
...@@ -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';
......
...@@ -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';
...@@ -132,7 +130,7 @@ void main() { ...@@ -132,7 +130,7 @@ void main() {
of: find.byType(BackButton), of: find.byType(BackButton),
matching: find.byType(RichText) matching: find.byType(RichText)
)); ));
expect(iconText.text.style.color, Colors.blue); expect(iconText.text.style!.color, Colors.blue);
}); });
testWidgets('BackButton semantics', (WidgetTester tester) async { testWidgets('BackButton semantics', (WidgetTester tester) async {
...@@ -182,7 +180,7 @@ void main() { ...@@ -182,7 +180,7 @@ void main() {
of: find.byType(CloseButton), of: find.byType(CloseButton),
matching: find.byType(RichText) matching: find.byType(RichText)
)); ));
expect(iconText.text.style.color, Colors.red); expect(iconText.text.style!.color, Colors.red);
}); });
testWidgets('CloseButton onPressed overrides default pop behavior', (WidgetTester tester) async { testWidgets('CloseButton onPressed overrides default pop behavior', (WidgetTester tester) async {
......
...@@ -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';
...@@ -260,5 +258,5 @@ Container _getContainerFromBanner(WidgetTester tester) { ...@@ -260,5 +258,5 @@ Container _getContainerFromBanner(WidgetTester tester) {
} }
RenderParagraph _getTextRenderObjectFromDialog(WidgetTester tester, String text) { RenderParagraph _getTextRenderObjectFromDialog(WidgetTester tester, String text) {
return tester.element<StatelessElement>(find.descendant(of: find.byType(MaterialBanner), matching: find.text(text))).renderObject as RenderParagraph; return tester.element<StatelessElement>(find.descendant(of: find.byType(MaterialBanner), matching: find.text(text))).renderObject! as RenderParagraph;
} }
...@@ -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';
...@@ -70,7 +68,7 @@ void main() { ...@@ -70,7 +68,7 @@ void main() {
final RenderParagraph content = _getTextRenderObjectFromDialog(tester, contentText); final RenderParagraph content = _getTextRenderObjectFromDialog(tester, contentText);
expect(container.color, const Color(0xffffffff)); expect(container.color, const Color(0xffffffff));
// Default value for ThemeData.typography is Typography.material2014() // Default value for ThemeData.typography is Typography.material2014()
expect(content.text.style, Typography.material2014().englishLike.bodyText2.merge(Typography.material2014().black.bodyText2)); expect(content.text.style, Typography.material2014().englishLike.bodyText2!.merge(Typography.material2014().black.bodyText2));
}); });
testWidgets('MaterialBanner uses values from MaterialBannerThemeData', (WidgetTester tester) async { testWidgets('MaterialBanner uses values from MaterialBannerThemeData', (WidgetTester tester) async {
...@@ -185,7 +183,7 @@ Finder _containerFinder() { ...@@ -185,7 +183,7 @@ Finder _containerFinder() {
} }
RenderParagraph _getTextRenderObjectFromDialog(WidgetTester tester, String text) { RenderParagraph _getTextRenderObjectFromDialog(WidgetTester tester, String text) {
return tester.element<StatelessElement>(_textFinder(text)).renderObject as RenderParagraph; return tester.element<StatelessElement>(_textFinder(text)).renderObject! as RenderParagraph;
} }
Finder _textFinder(String text) { Finder _textFinder(String text) {
......
...@@ -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';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
...@@ -90,7 +88,7 @@ void main() { ...@@ -90,7 +88,7 @@ void main() {
home: Builder( home: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
return Theme( return Theme(
data: Theme.of(context).copyWith(bottomAppBarColor: const Color(0xffffff00)), data: Theme.of(context)!.copyWith(bottomAppBarColor: const Color(0xffffff00)),
child: const Scaffold( child: const Scaffold(
floatingActionButton: FloatingActionButton( floatingActionButton: FloatingActionButton(
onPressed: null, onPressed: null,
...@@ -115,7 +113,7 @@ void main() { ...@@ -115,7 +113,7 @@ void main() {
home: Builder( home: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
return Theme( return Theme(
data: Theme.of(context).copyWith(bottomAppBarColor: const Color(0xffffff00)), data: Theme.of(context)!.copyWith(bottomAppBarColor: const Color(0xffffff00)),
child: const Scaffold( child: const Scaffold(
floatingActionButton: FloatingActionButton( floatingActionButton: FloatingActionButton(
onPressed: null, onPressed: null,
...@@ -392,19 +390,19 @@ void main() { ...@@ -392,19 +390,19 @@ void main() {
class ClipCachePainter extends CustomPainter { class ClipCachePainter extends CustomPainter {
ClipCachePainter(this.context); ClipCachePainter(this.context);
Path value; late Path value;
BuildContext context; BuildContext context;
@override @override
void paint(Canvas canvas, Size size) { void paint(Canvas canvas, Size size) {
final RenderPhysicalShape physicalShape = findPhysicalShapeChild(context); final RenderPhysicalShape physicalShape = findPhysicalShapeChild(context)!;
value = physicalShape.clipper.getClip(size); value = physicalShape.clipper!.getClip(size);
} }
RenderPhysicalShape findPhysicalShapeChild(BuildContext context) { RenderPhysicalShape? findPhysicalShapeChild(BuildContext context) {
RenderPhysicalShape result; RenderPhysicalShape? result;
context.visitChildElements((Element e) { context.visitChildElements((Element e) {
final RenderObject renderObject = e.findRenderObject(); final RenderObject renderObject = e.findRenderObject()!;
if (renderObject.runtimeType == RenderPhysicalShape) { if (renderObject.runtimeType == RenderPhysicalShape) {
assert(result == null); assert(result == null);
result = renderObject as RenderPhysicalShape; result = renderObject as RenderPhysicalShape;
...@@ -422,7 +420,7 @@ class ClipCachePainter extends CustomPainter { ...@@ -422,7 +420,7 @@ class ClipCachePainter extends CustomPainter {
} }
class ShapeListener extends StatefulWidget { class ShapeListener extends StatefulWidget {
const ShapeListener(this.child, { Key key }) : super(key: key); const ShapeListener(this.child, { Key? key }) : super(key: key);
final Widget child; final Widget child;
...@@ -440,7 +438,7 @@ class ShapeListenerState extends State<ShapeListener> { ...@@ -440,7 +438,7 @@ class ShapeListenerState extends State<ShapeListener> {
); );
} }
ClipCachePainter cache; late ClipCachePainter cache;
@override @override
void didChangeDependencies() { void didChangeDependencies() {
...@@ -454,7 +452,7 @@ class RectangularNotch extends NotchedShape { ...@@ -454,7 +452,7 @@ class RectangularNotch extends NotchedShape {
const RectangularNotch(); const RectangularNotch();
@override @override
Path getOuterPath(Rect host, Rect guest) { Path getOuterPath(Rect host, Rect? guest) {
if (guest == null) if (guest == null)
return Path()..addRect(host); return Path()..addRect(host);
return Path() return Path()
......
...@@ -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';
......
...@@ -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';
...@@ -139,14 +137,14 @@ void main() { ...@@ -139,14 +137,14 @@ void main() {
), ),
); );
final TextStyle selectedFontStyle = tester.renderObject<RenderParagraph>(find.text('AC')).text.style; final TextStyle selectedFontStyle = tester.renderObject<RenderParagraph>(find.text('AC')).text.style!;
final TextStyle selectedIcon = _iconStyle(tester, Icons.ac_unit); final TextStyle selectedIcon = _iconStyle(tester, Icons.ac_unit);
final TextStyle unselectedIcon = _iconStyle(tester, Icons.access_alarm); final TextStyle unselectedIcon = _iconStyle(tester, Icons.access_alarm);
expect(selectedFontStyle.fontSize, selectedFontStyle.fontSize); expect(selectedFontStyle.fontSize, selectedFontStyle.fontSize);
// Unselected label has a font size of 22 but is scaled down to be font size 21. // Unselected label has a font size of 22 but is scaled down to be font size 21.
expect( expect(
tester.firstWidget<Transform>(find.ancestor(of: find.text('Alarm'), matching: find.byType(Transform))).transform, tester.firstWidget<Transform>(find.ancestor(of: find.text('Alarm'), matching: find.byType(Transform))).transform,
equals(Matrix4.diagonal3(Vector3.all(unselectedTextStyle.fontSize / selectedTextStyle.fontSize))), equals(Matrix4.diagonal3(Vector3.all(unselectedTextStyle.fontSize! / selectedTextStyle.fontSize!))),
); );
expect(selectedIcon.color, equals(selectedItemColor)); expect(selectedIcon.color, equals(selectedItemColor));
expect(selectedIcon.fontSize, equals(selectedIconTheme.size)); expect(selectedIcon.fontSize, equals(selectedIconTheme.size));
...@@ -232,14 +230,14 @@ void main() { ...@@ -232,14 +230,14 @@ void main() {
), ),
); );
final TextStyle selectedFontStyle = tester.renderObject<RenderParagraph>(find.text('AC')).text.style; final TextStyle selectedFontStyle = tester.renderObject<RenderParagraph>(find.text('AC')).text.style!;
final TextStyle selectedIcon = _iconStyle(tester, Icons.ac_unit); final TextStyle selectedIcon = _iconStyle(tester, Icons.ac_unit);
final TextStyle unselectedIcon = _iconStyle(tester, Icons.access_alarm); final TextStyle unselectedIcon = _iconStyle(tester, Icons.access_alarm);
expect(selectedFontStyle.fontSize, selectedFontStyle.fontSize); expect(selectedFontStyle.fontSize, selectedFontStyle.fontSize);
// Unselected label has a font size of 22 but is scaled down to be font size 21. // Unselected label has a font size of 22 but is scaled down to be font size 21.
expect( expect(
tester.firstWidget<Transform>(find.ancestor(of: find.text('Alarm'), matching: find.byType(Transform))).transform, tester.firstWidget<Transform>(find.ancestor(of: find.text('Alarm'), matching: find.byType(Transform))).transform,
equals(Matrix4.diagonal3(Vector3.all(unselectedTextStyle.fontSize / selectedTextStyle.fontSize))), equals(Matrix4.diagonal3(Vector3.all(unselectedTextStyle.fontSize! / selectedTextStyle.fontSize!))),
); );
expect(selectedIcon.color, equals(selectedItemColor)); expect(selectedIcon.color, equals(selectedItemColor));
expect(selectedIcon.fontSize, equals(selectedIconTheme.size)); expect(selectedIcon.fontSize, equals(selectedIconTheme.size));
...@@ -266,7 +264,7 @@ TextStyle _iconStyle(WidgetTester tester, IconData icon) { ...@@ -266,7 +264,7 @@ 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!;
} }
Material _material(WidgetTester tester) { Material _material(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_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
...@@ -28,7 +26,7 @@ void main() { ...@@ -28,7 +26,7 @@ void main() {
} }
testWidgets('Tapping on a modal BottomSheet should not dismiss it', (WidgetTester tester) async { testWidgets('Tapping on a modal BottomSheet should not dismiss it', (WidgetTester tester) async {
BuildContext savedContext; late BuildContext savedContext;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -64,7 +62,7 @@ void main() { ...@@ -64,7 +62,7 @@ void main() {
}); });
testWidgets('Tapping outside a modal BottomSheet should dismiss it by default', (WidgetTester tester) async { testWidgets('Tapping outside a modal BottomSheet should dismiss it by default', (WidgetTester tester) async {
BuildContext savedContext; late BuildContext savedContext;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: Builder( home: Builder(
...@@ -98,7 +96,7 @@ void main() { ...@@ -98,7 +96,7 @@ void main() {
}); });
testWidgets('Tapping outside a modal BottomSheet should dismiss it when isDismissible=true', (WidgetTester tester) async { testWidgets('Tapping outside a modal BottomSheet should dismiss it when isDismissible=true', (WidgetTester tester) async {
BuildContext savedContext; late BuildContext savedContext;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: Builder( home: Builder(
...@@ -133,7 +131,7 @@ void main() { ...@@ -133,7 +131,7 @@ void main() {
}); });
testWidgets('Verify that the BottomSheet animates non-linearly', (WidgetTester tester) async { testWidgets('Verify that the BottomSheet animates non-linearly', (WidgetTester tester) async {
BuildContext savedContext; late BuildContext savedContext;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: Builder( home: Builder(
...@@ -165,7 +163,7 @@ void main() { ...@@ -165,7 +163,7 @@ void main() {
}); });
testWidgets('Tapping outside a modal BottomSheet should not dismiss it when isDismissible=false', (WidgetTester tester) async { testWidgets('Tapping outside a modal BottomSheet should not dismiss it when isDismissible=false', (WidgetTester tester) async {
BuildContext savedContext; late BuildContext savedContext;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -202,7 +200,7 @@ void main() { ...@@ -202,7 +200,7 @@ void main() {
}); });
testWidgets('Swiping down a modal BottomSheet should dismiss it by default', (WidgetTester tester) async { testWidgets('Swiping down a modal BottomSheet should dismiss it by default', (WidgetTester tester) async {
BuildContext savedContext; late BuildContext savedContext;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: Builder( home: Builder(
...@@ -237,7 +235,7 @@ void main() { ...@@ -237,7 +235,7 @@ void main() {
}); });
testWidgets('Swiping down a modal BottomSheet should not dismiss it when enableDrag is false', (WidgetTester tester) async { testWidgets('Swiping down a modal BottomSheet should not dismiss it when enableDrag is false', (WidgetTester tester) async {
BuildContext savedContext; late BuildContext savedContext;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: Builder( home: Builder(
...@@ -273,7 +271,7 @@ void main() { ...@@ -273,7 +271,7 @@ void main() {
}); });
testWidgets('Swiping down a modal BottomSheet should dismiss it when enableDrag is true', (WidgetTester tester) async { testWidgets('Swiping down a modal BottomSheet should dismiss it when enableDrag is true', (WidgetTester tester) async {
BuildContext savedContext; late BuildContext savedContext;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: Builder( home: Builder(
...@@ -309,7 +307,7 @@ void main() { ...@@ -309,7 +307,7 @@ void main() {
}); });
testWidgets('Modal BottomSheet builder should only be called once', (WidgetTester tester) async { testWidgets('Modal BottomSheet builder should only be called once', (WidgetTester tester) async {
BuildContext savedContext; late BuildContext savedContext;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: Builder( home: Builder(
...@@ -354,7 +352,7 @@ void main() { ...@@ -354,7 +352,7 @@ void main() {
expect(showBottomSheetThenCalled, isFalse); expect(showBottomSheetThenCalled, isFalse);
expect(find.text('BottomSheet'), findsNothing); expect(find.text('BottomSheet'), findsNothing);
scaffoldKey.currentState.showBottomSheet<void>((BuildContext context) { scaffoldKey.currentState!.showBottomSheet<void>((BuildContext context) {
return Container( return Container(
margin: const EdgeInsets.all(40.0), margin: const EdgeInsets.all(40.0),
child: const Text('BottomSheet'), child: const Text('BottomSheet'),
...@@ -408,7 +406,7 @@ void main() { ...@@ -408,7 +406,7 @@ void main() {
), ),
)); ));
scaffoldKey.currentState.showBottomSheet<void>((BuildContext context) { scaffoldKey.currentState!.showBottomSheet<void>((BuildContext context) {
return Container( return Container(
margin: const EdgeInsets.all(40.0), margin: const EdgeInsets.all(40.0),
child: const Text('BottomSheet'), child: const Text('BottomSheet'),
...@@ -428,8 +426,8 @@ void main() { ...@@ -428,8 +426,8 @@ void main() {
}); });
testWidgets('modal BottomSheet has no top MediaQuery', (WidgetTester tester) async { testWidgets('modal BottomSheet has no top MediaQuery', (WidgetTester tester) async {
BuildContext outerContext; late BuildContext outerContext;
BuildContext innerContext; late BuildContext innerContext;
await tester.pumpWidget(Localizations( await tester.pumpWidget(Localizations(
locale: const Locale('en', 'US'), locale: const Locale('en', 'US'),
...@@ -469,11 +467,11 @@ void main() { ...@@ -469,11 +467,11 @@ void main() {
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
expect( expect(
MediaQuery.of(outerContext).padding, MediaQuery.of(outerContext)!.padding,
const EdgeInsets.all(50.0), const EdgeInsets.all(50.0),
); );
expect( expect(
MediaQuery.of(innerContext).padding, MediaQuery.of(innerContext)!.padding,
const EdgeInsets.only(left: 50.0, right: 50.0, bottom: 50.0), const EdgeInsets.only(left: 50.0, right: 50.0, bottom: 50.0),
); );
}); });
...@@ -490,7 +488,7 @@ void main() { ...@@ -490,7 +488,7 @@ void main() {
)); ));
showModalBottomSheet<void>(context: scaffoldKey.currentContext, builder: (BuildContext context) { showModalBottomSheet<void>(context: scaffoldKey.currentContext!, builder: (BuildContext context) {
return Container( return Container(
child: const Text('BottomSheet'), child: const Text('BottomSheet'),
); );
...@@ -545,7 +543,7 @@ void main() { ...@@ -545,7 +543,7 @@ void main() {
)); ));
showModalBottomSheet<void>( showModalBottomSheet<void>(
context: scaffoldKey.currentContext, context: scaffoldKey.currentContext!,
backgroundColor: color, backgroundColor: color,
barrierColor: barrierColor, barrierColor: barrierColor,
elevation: elevation, elevation: elevation,
...@@ -584,7 +582,7 @@ void main() { ...@@ -584,7 +582,7 @@ void main() {
showModalBottomSheet<void>( showModalBottomSheet<void>(
context: scaffoldKey.currentContext, context: scaffoldKey.currentContext!,
builder: (BuildContext context) { builder: (BuildContext context) {
return DraggableScrollableSheet( return DraggableScrollableSheet(
expand: false, expand: false,
...@@ -710,13 +708,13 @@ void main() { ...@@ -710,13 +708,13 @@ void main() {
), ),
)); ));
RouteSettings retrievedRouteSettings; late RouteSettings retrievedRouteSettings;
showModalBottomSheet<void>( showModalBottomSheet<void>(
context: scaffoldKey.currentContext, context: scaffoldKey.currentContext!,
routeSettings: routeSettings, routeSettings: routeSettings,
builder: (BuildContext context) { builder: (BuildContext context) {
retrievedRouteSettings = ModalRoute.of(context).settings; retrievedRouteSettings = ModalRoute.of(context)!.settings;
return Container( return Container(
child: const Text('BottomSheet'), child: const Text('BottomSheet'),
); );
...@@ -731,9 +729,9 @@ void main() { ...@@ -731,9 +729,9 @@ void main() {
} }
class _TestPage extends StatelessWidget { class _TestPage extends StatelessWidget {
const _TestPage({Key key, this.useRootNavigator}) : super(key: key); const _TestPage({Key? key, this.useRootNavigator}) : super(key: key);
final bool useRootNavigator; final bool? useRootNavigator;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -743,7 +741,7 @@ class _TestPage extends StatelessWidget { ...@@ -743,7 +741,7 @@ class _TestPage extends StatelessWidget {
onPressed: () { onPressed: () {
if (useRootNavigator != null) { if (useRootNavigator != null) {
showModalBottomSheet<void>( showModalBottomSheet<void>(
useRootNavigator: useRootNavigator, useRootNavigator: useRootNavigator!,
context: context, context: context,
builder: (_) => const Text('Modal bottom sheet'), builder: (_) => const Text('Modal bottom sheet'),
); );
......
...@@ -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/services.dart'; import 'package:flutter/services.dart';
......
...@@ -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';
...@@ -243,7 +241,7 @@ void main() { ...@@ -243,7 +241,7 @@ void main() {
group('button properties override ButtonTheme', () { group('button properties override ButtonTheme', () {
testWidgets('default button properties override ButtonTheme properties', (WidgetTester tester) async { testWidgets('default button properties override ButtonTheme properties', (WidgetTester tester) async {
BuildContext capturedContext; late BuildContext capturedContext;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: ButtonBar( home: ButtonBar(
...@@ -266,7 +264,7 @@ void main() { ...@@ -266,7 +264,7 @@ void main() {
}); });
testWidgets('ButtonBarTheme button properties override defaults and ButtonTheme properties', (WidgetTester tester) async { testWidgets('ButtonBarTheme button properties override defaults and ButtonTheme properties', (WidgetTester tester) async {
BuildContext capturedContext; late BuildContext capturedContext;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: ButtonBarTheme( home: ButtonBarTheme(
...@@ -299,7 +297,7 @@ void main() { ...@@ -299,7 +297,7 @@ void main() {
}); });
testWidgets('ButtonBar button properties override ButtonBarTheme, defaults and ButtonTheme properties', (WidgetTester tester) async { testWidgets('ButtonBar button properties override ButtonBarTheme, defaults and ButtonTheme properties', (WidgetTester tester) async {
BuildContext capturedContext; late BuildContext capturedContext;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: ButtonBarTheme( home: ButtonBarTheme(
......
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