Unverified Commit 793678d5 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Migrate tests to null-safety (#67692)

parent 9360bbbb
...@@ -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';
...@@ -52,7 +50,7 @@ void main() { ...@@ -52,7 +50,7 @@ void main() {
test('TextTheme merges properly in the presence of null fields.', () { test('TextTheme merges properly in the presence of null fields.', () {
const TextTheme partialTheme = TextTheme(headline6: TextStyle(color: Color(0xcafefeed))); const TextTheme partialTheme = TextTheme(headline6: TextStyle(color: Color(0xcafefeed)));
final TextTheme fullTheme = ThemeData.fallback().textTheme.merge(partialTheme); final TextTheme fullTheme = ThemeData.fallback().textTheme.merge(partialTheme);
expect(fullTheme.headline6.color, equals(partialTheme.headline6.color)); expect(fullTheme.headline6!.color, equals(partialTheme.headline6!.color));
const TextTheme onlyHeadlineAndTitle = TextTheme( const TextTheme onlyHeadlineAndTitle = TextTheme(
headline5: TextStyle(color: Color(0xcafefeed)), headline5: TextStyle(color: Color(0xcafefeed)),
...@@ -64,9 +62,9 @@ void main() { ...@@ -64,9 +62,9 @@ void main() {
); );
TextTheme merged = onlyHeadlineAndTitle.merge(onlyBody1AndTitle); TextTheme merged = onlyHeadlineAndTitle.merge(onlyBody1AndTitle);
expect(merged.bodyText1, isNull); expect(merged.bodyText1, isNull);
expect(merged.bodyText2.color, equals(onlyBody1AndTitle.bodyText2.color)); expect(merged.bodyText2!.color, equals(onlyBody1AndTitle.bodyText2!.color));
expect(merged.headline5.color, equals(onlyHeadlineAndTitle.headline5.color)); expect(merged.headline5!.color, equals(onlyHeadlineAndTitle.headline5!.color));
expect(merged.headline6.color, equals(onlyBody1AndTitle.headline6.color)); expect(merged.headline6!.color, equals(onlyBody1AndTitle.headline6!.color));
merged = onlyHeadlineAndTitle.merge(null); merged = onlyHeadlineAndTitle.merge(null);
expect(merged, equals(onlyHeadlineAndTitle)); expect(merged, equals(onlyHeadlineAndTitle));
...@@ -96,34 +94,34 @@ void main() { ...@@ -96,34 +94,34 @@ void main() {
decorationStyle: decorationStyle, decorationStyle: decorationStyle,
); );
expect(theme.headline1.color, displayColor); expect(theme.headline1!.color, displayColor);
expect(theme.headline2.color, displayColor); expect(theme.headline2!.color, displayColor);
expect(theme.headline3.color, displayColor); expect(theme.headline3!.color, displayColor);
expect(theme.headline4.color, displayColor); expect(theme.headline4!.color, displayColor);
expect(theme.caption.color, displayColor); expect(theme.caption!.color, displayColor);
expect(theme.headline5.color, bodyColor); expect(theme.headline5!.color, bodyColor);
expect(theme.headline6.color, bodyColor); expect(theme.headline6!.color, bodyColor);
expect(theme.subtitle1.color, bodyColor); expect(theme.subtitle1!.color, bodyColor);
expect(theme.bodyText1.color, bodyColor); expect(theme.bodyText1!.color, bodyColor);
expect(theme.bodyText2.color, bodyColor); expect(theme.bodyText2!.color, bodyColor);
expect(theme.button.color, bodyColor); expect(theme.button!.color, bodyColor);
expect(theme.subtitle2.color, bodyColor); expect(theme.subtitle2!.color, bodyColor);
expect(theme.overline.color, bodyColor); expect(theme.overline!.color, bodyColor);
final List<TextStyle> themeStyles = <TextStyle>[ final List<TextStyle> themeStyles = <TextStyle>[
theme.headline1, theme.headline1!,
theme.headline2, theme.headline2!,
theme.headline3, theme.headline3!,
theme.headline4, theme.headline4!,
theme.caption, theme.caption!,
theme.headline5, theme.headline5!,
theme.headline6, theme.headline6!,
theme.subtitle1, theme.subtitle1!,
theme.bodyText1, theme.bodyText1!,
theme.bodyText2, theme.bodyText2!,
theme.button, theme.button!,
theme.subtitle2, theme.subtitle2!,
theme.overline, theme.overline!,
]; ];
expect(themeStyles.every((TextStyle style) => style.fontFamily == fontFamily), true); expect(themeStyles.every((TextStyle style) => style.fontFamily == fontFamily), true);
expect(themeStyles.every((TextStyle style) => style.decorationColor == decorationColor), true); expect(themeStyles.every((TextStyle style) => style.decorationColor == decorationColor), true);
...@@ -139,19 +137,19 @@ void main() { ...@@ -139,19 +137,19 @@ void main() {
fontSizeDelta: 5.0, fontSizeDelta: 5.0,
); );
expect(sizeTheme.headline1.fontSize, baseTheme.headline1.fontSize * 2.0 + 5.0); expect(sizeTheme.headline1!.fontSize, baseTheme.headline1!.fontSize! * 2.0 + 5.0);
expect(sizeTheme.headline2.fontSize, baseTheme.headline2.fontSize * 2.0 + 5.0); expect(sizeTheme.headline2!.fontSize, baseTheme.headline2!.fontSize! * 2.0 + 5.0);
expect(sizeTheme.headline3.fontSize, baseTheme.headline3.fontSize * 2.0 + 5.0); expect(sizeTheme.headline3!.fontSize, baseTheme.headline3!.fontSize! * 2.0 + 5.0);
expect(sizeTheme.headline4.fontSize, baseTheme.headline4.fontSize * 2.0 + 5.0); expect(sizeTheme.headline4!.fontSize, baseTheme.headline4!.fontSize! * 2.0 + 5.0);
expect(sizeTheme.caption.fontSize, baseTheme.caption.fontSize * 2.0 + 5.0); expect(sizeTheme.caption!.fontSize, baseTheme.caption!.fontSize! * 2.0 + 5.0);
expect(sizeTheme.headline5.fontSize, baseTheme.headline5.fontSize * 2.0 + 5.0); expect(sizeTheme.headline5!.fontSize, baseTheme.headline5!.fontSize! * 2.0 + 5.0);
expect(sizeTheme.headline6.fontSize, baseTheme.headline6.fontSize * 2.0 + 5.0); expect(sizeTheme.headline6!.fontSize, baseTheme.headline6!.fontSize! * 2.0 + 5.0);
expect(sizeTheme.subtitle1.fontSize, baseTheme.subtitle1.fontSize * 2.0 + 5.0); expect(sizeTheme.subtitle1!.fontSize, baseTheme.subtitle1!.fontSize! * 2.0 + 5.0);
expect(sizeTheme.bodyText1.fontSize, baseTheme.bodyText1.fontSize * 2.0 + 5.0); expect(sizeTheme.bodyText1!.fontSize, baseTheme.bodyText1!.fontSize! * 2.0 + 5.0);
expect(sizeTheme.bodyText2.fontSize, baseTheme.bodyText2.fontSize * 2.0 + 5.0); expect(sizeTheme.bodyText2!.fontSize, baseTheme.bodyText2!.fontSize! * 2.0 + 5.0);
expect(sizeTheme.button.fontSize, baseTheme.button.fontSize * 2.0 + 5.0); expect(sizeTheme.button!.fontSize, baseTheme.button!.fontSize! * 2.0 + 5.0);
expect(sizeTheme.subtitle2.fontSize, baseTheme.subtitle2.fontSize * 2.0 + 5.0); expect(sizeTheme.subtitle2!.fontSize, baseTheme.subtitle2!.fontSize! * 2.0 + 5.0);
expect(sizeTheme.overline.fontSize, baseTheme.overline.fontSize * 2.0 + 5.0); expect(sizeTheme.overline!.fontSize, baseTheme.overline!.fontSize! * 2.0 + 5.0);
}); });
test('TextTheme lerp with second parameter null', () { test('TextTheme lerp with second parameter null', () {
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -37,8 +35,8 @@ void main() { ...@@ -37,8 +35,8 @@ void main() {
final ThemeData darkTheme = ThemeData(brightness: Brightness.dark); final ThemeData darkTheme = ThemeData(brightness: Brightness.dark);
final Typography typography = Typography.material2018(platform: lightTheme.platform); final Typography typography = Typography.material2018(platform: lightTheme.platform);
expect(lightTheme.textTheme.headline6.color, typography.black.headline6.color); expect(lightTheme.textTheme.headline6!.color, typography.black.headline6!.color);
expect(darkTheme.textTheme.headline6.color, typography.white.headline6.color); expect(darkTheme.textTheme.headline6!.color, typography.white.headline6!.color);
}); });
test('Default primary text theme contrasts with primary brightness', () { test('Default primary text theme contrasts with primary brightness', () {
...@@ -46,8 +44,8 @@ void main() { ...@@ -46,8 +44,8 @@ void main() {
final ThemeData darkTheme = ThemeData(primaryColorBrightness: Brightness.dark); final ThemeData darkTheme = ThemeData(primaryColorBrightness: Brightness.dark);
final Typography typography = Typography.material2018(platform: lightTheme.platform); final Typography typography = Typography.material2018(platform: lightTheme.platform);
expect(lightTheme.primaryTextTheme.headline6.color, typography.black.headline6.color); expect(lightTheme.primaryTextTheme.headline6!.color, typography.black.headline6!.color);
expect(darkTheme.primaryTextTheme.headline6.color, typography.white.headline6.color); expect(darkTheme.primaryTextTheme.headline6!.color, typography.white.headline6!.color);
}); });
test('Default accent text theme contrasts with accent brightness', () { test('Default accent text theme contrasts with accent brightness', () {
...@@ -55,8 +53,8 @@ void main() { ...@@ -55,8 +53,8 @@ void main() {
final ThemeData darkTheme = ThemeData(accentColorBrightness: Brightness.dark); final ThemeData darkTheme = ThemeData(accentColorBrightness: Brightness.dark);
final Typography typography = Typography.material2018(platform: lightTheme.platform); final Typography typography = Typography.material2018(platform: lightTheme.platform);
expect(lightTheme.accentTextTheme.headline6.color, typography.black.headline6.color); expect(lightTheme.accentTextTheme.headline6!.color, typography.black.headline6!.color);
expect(darkTheme.accentTextTheme.headline6.color, typography.white.headline6.color); expect(darkTheme.accentTextTheme.headline6!.color, typography.white.headline6!.color);
}); });
test('Default chip label style gets a default bodyText1 if textTheme.bodyText1 is null', () { test('Default chip label style gets a default bodyText1 if textTheme.bodyText1 is null', () {
...@@ -65,8 +63,8 @@ void main() { ...@@ -65,8 +63,8 @@ void main() {
final ThemeData darkTheme = ThemeData(brightness: Brightness.dark, textTheme: noBodyText1TextTheme); final ThemeData darkTheme = ThemeData(brightness: Brightness.dark, textTheme: noBodyText1TextTheme);
final Typography typography = Typography.material2018(platform: lightTheme.platform); final Typography typography = Typography.material2018(platform: lightTheme.platform);
expect(lightTheme.chipTheme.labelStyle.color, equals(typography.black.bodyText1.color.withAlpha(0xde))); expect(lightTheme.chipTheme.labelStyle.color, equals(typography.black.bodyText1!.color!.withAlpha(0xde)));
expect(darkTheme.chipTheme.labelStyle.color, equals(typography.white.bodyText1.color.withAlpha(0xde))); expect(darkTheme.chipTheme.labelStyle.color, equals(typography.white.bodyText1!.color!.withAlpha(0xde)));
}); });
test('Default icon theme contrasts with brightness', () { test('Default icon theme contrasts with brightness', () {
...@@ -74,8 +72,8 @@ void main() { ...@@ -74,8 +72,8 @@ void main() {
final ThemeData darkTheme = ThemeData(brightness: Brightness.dark); final ThemeData darkTheme = ThemeData(brightness: Brightness.dark);
final Typography typography = Typography.material2018(platform: lightTheme.platform); final Typography typography = Typography.material2018(platform: lightTheme.platform);
expect(lightTheme.textTheme.headline6.color, typography.black.headline6.color); expect(lightTheme.textTheme.headline6!.color, typography.black.headline6!.color);
expect(darkTheme.textTheme.headline6.color, typography.white.headline6.color); expect(darkTheme.textTheme.headline6!.color, typography.white.headline6!.color);
}); });
test('Default primary icon theme contrasts with primary brightness', () { test('Default primary icon theme contrasts with primary brightness', () {
...@@ -83,8 +81,8 @@ void main() { ...@@ -83,8 +81,8 @@ void main() {
final ThemeData darkTheme = ThemeData(primaryColorBrightness: Brightness.dark); final ThemeData darkTheme = ThemeData(primaryColorBrightness: Brightness.dark);
final Typography typography = Typography.material2018(platform: lightTheme.platform); final Typography typography = Typography.material2018(platform: lightTheme.platform);
expect(lightTheme.primaryTextTheme.headline6.color, typography.black.headline6.color); expect(lightTheme.primaryTextTheme.headline6!.color, typography.black.headline6!.color);
expect(darkTheme.primaryTextTheme.headline6.color, typography.white.headline6.color); expect(darkTheme.primaryTextTheme.headline6!.color, typography.white.headline6!.color);
}); });
test('Default accent icon theme contrasts with accent brightness', () { test('Default accent icon theme contrasts with accent brightness', () {
...@@ -92,8 +90,8 @@ void main() { ...@@ -92,8 +90,8 @@ void main() {
final ThemeData darkTheme = ThemeData(accentColorBrightness: Brightness.dark); final ThemeData darkTheme = ThemeData(accentColorBrightness: Brightness.dark);
final Typography typography = Typography.material2018(platform: lightTheme.platform); final Typography typography = Typography.material2018(platform: lightTheme.platform);
expect(lightTheme.accentTextTheme.headline6.color, typography.black.headline6.color); expect(lightTheme.accentTextTheme.headline6!.color, typography.black.headline6!.color);
expect(darkTheme.accentTextTheme.headline6.color, typography.white.headline6.color); expect(darkTheme.accentTextTheme.headline6!.color, typography.white.headline6!.color);
}); });
testWidgets('Defaults to MaterialTapTargetBehavior.padded on mobile platforms and MaterialTapTargetBehavior.shrinkWrap on desktop', (WidgetTester tester) async { testWidgets('Defaults to MaterialTapTargetBehavior.padded on mobile platforms and MaterialTapTargetBehavior.shrinkWrap on desktop', (WidgetTester tester) async {
...@@ -120,12 +118,12 @@ void main() { ...@@ -120,12 +118,12 @@ void main() {
), ),
); );
expect(themeData.textTheme.bodyText1.fontFamily, equals('Ahem')); expect(themeData.textTheme.bodyText1!.fontFamily, equals('Ahem'));
expect(themeData.primaryTextTheme.headline3.fontFamily, equals('Ahem')); expect(themeData.primaryTextTheme.headline3!.fontFamily, equals('Ahem'));
expect(themeData.accentTextTheme.headline1.fontFamily, equals('Ahem')); expect(themeData.accentTextTheme.headline1!.fontFamily, equals('Ahem'));
// Shouldn't override the specified style's family // Shouldn't override the specified style's family
expect(themeData.textTheme.headline6.fontFamily, equals('Roboto')); expect(themeData.textTheme.headline6!.fontFamily, equals('Roboto'));
}); });
test('Can estimate brightness - directly', () { test('Can estimate brightness - directly', () {
...@@ -192,7 +190,7 @@ void main() { ...@@ -192,7 +190,7 @@ void main() {
}); });
testWidgets('VisualDensity.adaptivePlatformDensity returns adaptive values', (WidgetTester tester) async { testWidgets('VisualDensity.adaptivePlatformDensity returns adaptive values', (WidgetTester tester) async {
switch (debugDefaultTargetPlatformOverride) { switch (debugDefaultTargetPlatformOverride!) {
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.iOS: case TargetPlatform.iOS:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
...@@ -207,7 +205,7 @@ void main() { ...@@ -207,7 +205,7 @@ void main() {
testWidgets('VisualDensity in ThemeData defaults to "compact" on desktop and "standard" on mobile', (WidgetTester tester) async { testWidgets('VisualDensity in ThemeData defaults to "compact" on desktop and "standard" on mobile', (WidgetTester tester) async {
final ThemeData themeData = ThemeData(); final ThemeData themeData = ThemeData();
switch (debugDefaultTargetPlatformOverride) { switch (debugDefaultTargetPlatformOverride!) {
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.iOS: case TargetPlatform.iOS:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
......
...@@ -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';
...@@ -28,7 +26,7 @@ void main() { ...@@ -28,7 +26,7 @@ void main() {
); );
final RawMaterialButton raw = tester.widget<RawMaterialButton>(find.byType(RawMaterialButton)); final RawMaterialButton raw = tester.widget<RawMaterialButton>(find.byType(RawMaterialButton));
expect(raw.textStyle.color, const Color(0xdd000000)); expect(raw.textStyle!.color, const Color(0xdd000000));
expect(raw.fillColor, const Color(0xffe0e0e0)); expect(raw.fillColor, const Color(0xffe0e0e0));
expect(raw.highlightColor, const Color(0x29000000)); // Was Color(0x66bcbcbc) expect(raw.highlightColor, const Color(0x29000000)); // Was Color(0x66bcbcbc)
expect(raw.splashColor, const Color(0x1f000000)); // Was Color(0x66c8c8c8) expect(raw.splashColor, const Color(0x1f000000)); // Was Color(0x66c8c8c8)
...@@ -56,7 +54,7 @@ void main() { ...@@ -56,7 +54,7 @@ void main() {
); );
final RawMaterialButton raw = tester.widget<RawMaterialButton>(find.byType(RawMaterialButton)); final RawMaterialButton raw = tester.widget<RawMaterialButton>(find.byType(RawMaterialButton));
expect(raw.textStyle.color, const Color(0x61000000)); expect(raw.textStyle!.color, const Color(0x61000000));
expect(raw.fillColor, const Color(0x61000000)); expect(raw.fillColor, const Color(0x61000000));
// highlightColor, disabled button can't be pressed // highlightColor, disabled button can't be pressed
// splashColor, disabled button doesn't splash // splashColor, disabled button doesn't splash
...@@ -86,7 +84,7 @@ void main() { ...@@ -86,7 +84,7 @@ void main() {
); );
final RawMaterialButton raw = tester.widget<RawMaterialButton>(find.byType(RawMaterialButton)); final RawMaterialButton raw = tester.widget<RawMaterialButton>(find.byType(RawMaterialButton));
expect(raw.textStyle.color, const Color(0xdd000000)); expect(raw.textStyle!.color, const Color(0xdd000000));
expect(raw.fillColor, null); expect(raw.fillColor, null);
expect(raw.highlightColor, const Color(0x29000000)); // Was Color(0x66bcbcbc) expect(raw.highlightColor, const Color(0x29000000)); // Was Color(0x66bcbcbc)
expect(raw.splashColor, const Color(0x1f000000)); // Was Color(0x66c8c8c8) expect(raw.splashColor, const Color(0x1f000000)); // Was Color(0x66c8c8c8)
...@@ -114,7 +112,7 @@ void main() { ...@@ -114,7 +112,7 @@ void main() {
); );
final RawMaterialButton raw = tester.widget<RawMaterialButton>(find.byType(RawMaterialButton)); final RawMaterialButton raw = tester.widget<RawMaterialButton>(find.byType(RawMaterialButton));
expect(raw.textStyle.color, const Color(0x61000000)); expect(raw.textStyle!.color, const Color(0x61000000));
expect(raw.fillColor, null); expect(raw.fillColor, null);
// highlightColor, disabled button can't be pressed // highlightColor, disabled button can't be pressed
// splashColor, disabled button doesn't splash // splashColor, disabled button doesn't splash
...@@ -148,7 +146,7 @@ void main() { ...@@ -148,7 +146,7 @@ void main() {
); );
final RawMaterialButton raw = tester.widget<RawMaterialButton>(find.byType(RawMaterialButton)); final RawMaterialButton raw = tester.widget<RawMaterialButton>(find.byType(RawMaterialButton));
expect(raw.textStyle.color, const Color(0xdd000000)); expect(raw.textStyle!.color, const Color(0xdd000000));
expect(raw.fillColor, const Color(0x00fafafa)); expect(raw.fillColor, const Color(0x00fafafa));
expect(raw.highlightColor, const Color(0x29000000)); // Was Color(0x66bcbcbc) expect(raw.highlightColor, const Color(0x29000000)); // Was Color(0x66bcbcbc)
expect(raw.splashColor, const Color(0x1f000000)); // Was Color(0x66c8c8c8) expect(raw.splashColor, const Color(0x1f000000)); // Was Color(0x66c8c8c8)
...@@ -175,7 +173,7 @@ void main() { ...@@ -175,7 +173,7 @@ void main() {
); );
final RawMaterialButton raw = tester.widget<RawMaterialButton>(find.byType(RawMaterialButton)); final RawMaterialButton raw = tester.widget<RawMaterialButton>(find.byType(RawMaterialButton));
expect(raw.textStyle.color, const Color(0xdd000000)); expect(raw.textStyle!.color, const Color(0xdd000000));
expect(raw.fillColor, Colors.transparent); expect(raw.fillColor, Colors.transparent);
expect(raw.highlightColor, const Color(0x29000000)); // Was Color(0x66bcbcbc) expect(raw.highlightColor, const Color(0x29000000)); // Was Color(0x66bcbcbc)
expect(raw.splashColor, const Color(0x1f000000)); // Was Color(0x66c8c8c8) expect(raw.splashColor, const Color(0x1f000000)); // Was Color(0x66c8c8c8)
...@@ -202,7 +200,7 @@ void main() { ...@@ -202,7 +200,7 @@ void main() {
); );
final RawMaterialButton raw = tester.widget<RawMaterialButton>(find.byType(RawMaterialButton)); final RawMaterialButton raw = tester.widget<RawMaterialButton>(find.byType(RawMaterialButton));
expect(raw.textStyle.color, const Color(0x61000000)); expect(raw.textStyle!.color, const Color(0x61000000));
expect(raw.fillColor, const Color(0x00000000)); expect(raw.fillColor, const Color(0x00000000));
// highlightColor, disabled button can't be pressed // highlightColor, disabled button can't be pressed
// splashColor, disabled button doesn't splash // splashColor, disabled button doesn't splash
...@@ -236,7 +234,7 @@ void main() { ...@@ -236,7 +234,7 @@ void main() {
final RawMaterialButton raw = tester.widget<RawMaterialButton>(find.byType(RawMaterialButton)); final RawMaterialButton raw = tester.widget<RawMaterialButton>(find.byType(RawMaterialButton));
expect(raw.enabled, true); expect(raw.enabled, true);
expect(raw.textStyle.color, const Color(0xffffffff)); expect(raw.textStyle!.color, const Color(0xffffffff));
expect(raw.fillColor, const Color(0xff2196f3)); expect(raw.fillColor, const Color(0xff2196f3));
expect(raw.elevation, 6.0); expect(raw.elevation, 6.0);
expect(raw.highlightElevation, 12.0); expect(raw.highlightElevation, 12.0);
...@@ -263,7 +261,7 @@ void main() { ...@@ -263,7 +261,7 @@ void main() {
final RawMaterialButton raw = tester.widget<RawMaterialButton>(find.byType(RawMaterialButton)); final RawMaterialButton raw = tester.widget<RawMaterialButton>(find.byType(RawMaterialButton));
expect(raw.enabled, false); expect(raw.enabled, false);
expect(raw.textStyle.color, const Color(0xffffffff)); expect(raw.textStyle!.color, const Color(0xffffffff));
expect(raw.fillColor, const Color(0xff2196f3)); expect(raw.fillColor, const Color(0xff2196f3));
// highlightColor, disabled button can't be pressed // highlightColor, disabled button can't be pressed
// splashColor, disabled button doesn't splash // splashColor, disabled button doesn't splash
......
...@@ -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';
...@@ -11,7 +9,7 @@ void main() { ...@@ -11,7 +9,7 @@ void main() {
group('TimeOfDay.format', () { group('TimeOfDay.format', () {
testWidgets('respects alwaysUse24HourFormat option', (WidgetTester tester) async { testWidgets('respects alwaysUse24HourFormat option', (WidgetTester tester) async {
Future<String> pumpTest(bool alwaysUse24HourFormat) async { Future<String> pumpTest(bool alwaysUse24HourFormat) async {
String formattedValue; late String formattedValue;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: MediaQuery( home: MediaQuery(
data: MediaQueryData(alwaysUse24HourFormat: alwaysUse24HourFormat), data: MediaQueryData(alwaysUse24HourFormat: alwaysUse24HourFormat),
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
...@@ -13,7 +11,7 @@ import '../rendering/mock_canvas.dart'; ...@@ -13,7 +11,7 @@ import '../rendering/mock_canvas.dart';
const double _defaultBorderWidth = 1.0; const double _defaultBorderWidth = 1.0;
Widget boilerplate({Widget child}) { Widget boilerplate({required Widget child}) {
return Directionality( return Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Center(child: child), child: Center(child: child),
...@@ -170,50 +168,6 @@ void main() { ...@@ -170,50 +168,6 @@ void main() {
}, },
); );
testWidgets('children property cannot be null', (WidgetTester tester) async {
try {
await tester.pumpWidget(
Material(
child: boilerplate(
child: ToggleButtons(
isSelected: const <bool>[false, true],
onPressed: (int index) {},
children: null,
),
),
),
);
fail('Should not be possible to create a toggle button with no children.');
} on AssertionError catch (e) {
expect(e.toString(), contains('children != null'));
}
});
testWidgets(
'isSelected property cannot be null',
(WidgetTester tester) async {
try {
await tester.pumpWidget(
Material(
child: boilerplate(
child: ToggleButtons(
isSelected: null,
onPressed: (int index) {},
children: const <Widget>[
Text('First child'),
Text('Second child'),
],
),
),
),
);
fail('Should not be possible to create a toggle button with no isSelected.');
} on AssertionError catch (e) {
expect(e.toString(), contains('isSelected != null'));
}
},
);
testWidgets( testWidgets(
'children and isSelected properties have to be the same length', 'children and isSelected properties have to be the same length',
(WidgetTester tester) async { (WidgetTester tester) async {
...@@ -262,15 +216,15 @@ void main() { ...@@ -262,15 +216,15 @@ void main() {
of: find.widgetWithText(RawMaterialButton, 'First child'), of: find.widgetWithText(RawMaterialButton, 'First child'),
matching: find.byType(DefaultTextStyle), matching: find.byType(DefaultTextStyle),
)).style; )).style;
expect(textStyle.fontFamily, theme.textTheme.bodyText2.fontFamily); expect(textStyle.fontFamily, theme.textTheme.bodyText2!.fontFamily);
expect(textStyle.decoration, theme.textTheme.bodyText2.decoration); expect(textStyle.decoration, theme.textTheme.bodyText2!.decoration);
textStyle = tester.widget<DefaultTextStyle>(find.descendant( textStyle = tester.widget<DefaultTextStyle>(find.descendant(
of: find.widgetWithText(RawMaterialButton, 'Second child'), of: find.widgetWithText(RawMaterialButton, 'Second child'),
matching: find.byType(DefaultTextStyle), matching: find.byType(DefaultTextStyle),
)).style; )).style;
expect(textStyle.fontFamily, theme.textTheme.bodyText2.fontFamily); expect(textStyle.fontFamily, theme.textTheme.bodyText2!.fontFamily);
expect(textStyle.decoration, theme.textTheme.bodyText2.decoration); expect(textStyle.decoration, theme.textTheme.bodyText2!.decoration);
}); });
testWidgets('Custom text style except color is applied', (WidgetTester tester) async { testWidgets('Custom text style except color is applied', (WidgetTester tester) async {
...@@ -1470,7 +1424,7 @@ void main() { ...@@ -1470,7 +1424,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(
...@@ -1491,7 +1445,7 @@ void main() { ...@@ -1491,7 +1445,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(
...@@ -1511,6 +1465,6 @@ void main() { ...@@ -1511,6 +1465,6 @@ void main() {
), ),
); );
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic); expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
}); });
} }
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
...@@ -11,7 +9,7 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -11,7 +9,7 @@ import 'package:flutter_test/flutter_test.dart';
import '../rendering/mock_canvas.dart'; import '../rendering/mock_canvas.dart';
Widget boilerplate({Widget child}) { Widget boilerplate({required Widget child}) {
return Directionality( return Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Center(child: child), child: Center(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 'dart:ui'; import 'dart:ui';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
...@@ -581,7 +579,7 @@ void main() { ...@@ -581,7 +579,7 @@ void main() {
(key.currentState as dynamic).ensureTooltipVisible(); // Before using "as dynamic" in your code, see note at the top of the file. (key.currentState as dynamic).ensureTooltipVisible(); // Before using "as dynamic" in your code, see note at the top of the file.
await tester.pump(const Duration(seconds: 2)); // faded in, show timer started (and at 0.0) await tester.pump(const Duration(seconds: 2)); // faded in, show timer started (and at 0.0)
final TextStyle textStyle = tester.widget<Text>(find.text(tooltipText)).style; final TextStyle textStyle = tester.widget<Text>(find.text(tooltipText)).style!;
expect(textStyle.color, Colors.white); expect(textStyle.color, Colors.white);
expect(textStyle.fontFamily, 'Roboto'); expect(textStyle.fontFamily, 'Roboto');
expect(textStyle.decoration, TextDecoration.none); expect(textStyle.decoration, TextDecoration.none);
...@@ -607,7 +605,7 @@ void main() { ...@@ -607,7 +605,7 @@ void main() {
(key.currentState as dynamic).ensureTooltipVisible(); // Before using "as dynamic" in your code, see note at the top of the file. (key.currentState as dynamic).ensureTooltipVisible(); // Before using "as dynamic" in your code, see note at the top of the file.
await tester.pump(const Duration(seconds: 2)); // faded in, show timer started (and at 0.0) await tester.pump(const Duration(seconds: 2)); // faded in, show timer started (and at 0.0)
final TextStyle textStyle = tester.widget<Text>(find.text(tooltipText)).style; final TextStyle textStyle = tester.widget<Text>(find.text(tooltipText)).style!;
expect(textStyle.color, Colors.black); expect(textStyle.color, Colors.black);
expect(textStyle.fontFamily, 'Roboto'); expect(textStyle.fontFamily, 'Roboto');
expect(textStyle.decoration, TextDecoration.none); expect(textStyle.decoration, TextDecoration.none);
...@@ -634,7 +632,7 @@ void main() { ...@@ -634,7 +632,7 @@ void main() {
(key.currentState as dynamic).ensureTooltipVisible(); // Before using "as dynamic" in your code, see note at the top of the file. (key.currentState as dynamic).ensureTooltipVisible(); // Before using "as dynamic" in your code, see note at the top of the file.
await tester.pump(const Duration(seconds: 2)); // faded in, show timer started (and at 0.0) await tester.pump(const Duration(seconds: 2)); // faded in, show timer started (and at 0.0)
final TextStyle textStyle = tester.widget<Text>(find.text(tooltipText)).style; final TextStyle textStyle = tester.widget<Text>(find.text(tooltipText)).style!;
expect(textStyle.color, Colors.orange); expect(textStyle.color, Colors.orange);
expect(textStyle.fontFamily, null); expect(textStyle.fontFamily, null);
expect(textStyle.decoration, TextDecoration.underline); expect(textStyle.decoration, TextDecoration.underline);
...@@ -833,12 +831,12 @@ void main() { ...@@ -833,12 +831,12 @@ void main() {
testWidgets('Tooltip shows/hides when hovered', (WidgetTester tester) async { testWidgets('Tooltip shows/hides when hovered', (WidgetTester tester) async {
const Duration waitDuration = Duration(milliseconds: 0); const Duration waitDuration = Duration(milliseconds: 0);
TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); TestGesture? gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
addTearDown(() async { addTearDown(() async {
if (gesture != null) if (gesture != null)
return gesture.removePointer(); return gesture.removePointer();
}); });
await gesture.addPointer(); await gesture!.addPointer();
await gesture.moveTo(const Offset(1.0, 1.0)); await gesture.moveTo(const Offset(1.0, 1.0));
await tester.pump(); await tester.pump();
await gesture.moveTo(Offset.zero); await gesture.moveTo(Offset.zero);
...@@ -1013,7 +1011,7 @@ void main() { ...@@ -1013,7 +1011,7 @@ void main() {
}); });
testWidgets('Tooltip text scales with textScaleFactor', (WidgetTester tester) async { testWidgets('Tooltip text scales with textScaleFactor', (WidgetTester tester) async {
Widget buildApp(String text, { double textScaleFactor }) { Widget buildApp(String text, { required double textScaleFactor }) {
return MediaQuery( return MediaQuery(
data: MediaQueryData(textScaleFactor: textScaleFactor), data: MediaQueryData(textScaleFactor: textScaleFactor),
child: Directionality( child: Directionality(
...@@ -1254,6 +1252,6 @@ void main() { ...@@ -1254,6 +1252,6 @@ void main() {
SemanticsNode findDebugSemantics(RenderObject object) { SemanticsNode findDebugSemantics(RenderObject object) {
if (object.debugSemantics != null) if (object.debugSemantics != null)
return object.debugSemantics; return object.debugSemantics!;
return findDebugSemantics(object.parent as RenderObject); return findDebugSemantics(object.parent! as RenderObject);
} }
...@@ -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/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter/src/material/tooltip_theme.dart'; import 'package:flutter/src/material/tooltip_theme.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
...@@ -151,7 +149,7 @@ void main() { ...@@ -151,7 +149,7 @@ void main() {
* * * *
*********************/ *********************/
final RenderBox tip = tester.renderObject(find.text(tooltipText)).parent as RenderBox; final RenderBox tip = tester.renderObject(find.text(tooltipText)).parent! as RenderBox;
expect(tip.size.height, equals(100.0)); expect(tip.size.height, equals(100.0));
expect(tip.localToGlobal(tip.size.topLeft(Offset.zero)).dy, equals(100.0)); expect(tip.localToGlobal(tip.size.topLeft(Offset.zero)).dy, equals(100.0));
expect(tip.localToGlobal(tip.size.bottomRight(Offset.zero)).dy, equals(200.0)); expect(tip.localToGlobal(tip.size.bottomRight(Offset.zero)).dy, equals(200.0));
...@@ -209,7 +207,7 @@ void main() { ...@@ -209,7 +207,7 @@ void main() {
* * * *
*********************/ *********************/
final RenderBox tip = tester.renderObject(find.text(tooltipText)).parent as RenderBox; final RenderBox tip = tester.renderObject(find.text(tooltipText)).parent! as RenderBox;
expect(tip.size.height, equals(100.0)); expect(tip.size.height, equals(100.0));
expect(tip.localToGlobal(tip.size.topLeft(Offset.zero)).dy, equals(100.0)); expect(tip.localToGlobal(tip.size.topLeft(Offset.zero)).dy, equals(100.0));
expect(tip.localToGlobal(tip.size.bottomRight(Offset.zero)).dy, equals(200.0)); expect(tip.localToGlobal(tip.size.bottomRight(Offset.zero)).dy, equals(200.0));
...@@ -280,7 +278,7 @@ void main() { ...@@ -280,7 +278,7 @@ void main() {
* * }- 10.0 margin * * }- 10.0 margin
*********************/ *********************/
final RenderBox tip = tester.renderObject(find.text(tooltipText)).parent as RenderBox; final RenderBox tip = tester.renderObject(find.text(tooltipText)).parent! as RenderBox;
expect(tip.size.height, equals(190.0)); expect(tip.size.height, equals(190.0));
expect(tip.localToGlobal(tip.size.topLeft(Offset.zero)).dy, equals(399.0)); expect(tip.localToGlobal(tip.size.topLeft(Offset.zero)).dy, equals(399.0));
expect(tip.localToGlobal(tip.size.bottomRight(Offset.zero)).dy, equals(589.0)); expect(tip.localToGlobal(tip.size.bottomRight(Offset.zero)).dy, equals(589.0));
...@@ -349,7 +347,7 @@ void main() { ...@@ -349,7 +347,7 @@ void main() {
* * }- 10.0 margin * * }- 10.0 margin
*********************/ *********************/
final RenderBox tip = tester.renderObject(find.text(tooltipText)).parent as RenderBox; final RenderBox tip = tester.renderObject(find.text(tooltipText)).parent! as RenderBox;
expect(tip.size.height, equals(190.0)); expect(tip.size.height, equals(190.0));
expect(tip.localToGlobal(tip.size.topLeft(Offset.zero)).dy, equals(399.0)); expect(tip.localToGlobal(tip.size.topLeft(Offset.zero)).dy, equals(399.0));
expect(tip.localToGlobal(tip.size.bottomRight(Offset.zero)).dy, equals(589.0)); expect(tip.localToGlobal(tip.size.bottomRight(Offset.zero)).dy, equals(589.0));
...@@ -408,7 +406,7 @@ void main() { ...@@ -408,7 +406,7 @@ void main() {
* * }- 10.0 margin * * }- 10.0 margin
*********************/ *********************/
final RenderBox tip = tester.renderObject(find.text(tooltipText)).parent as RenderBox; final RenderBox tip = tester.renderObject(find.text(tooltipText)).parent! as RenderBox;
expect(tip.size.height, equals(190.0)); expect(tip.size.height, equals(190.0));
expect(tip.localToGlobal(tip.size.topLeft(Offset.zero)).dy, equals(400.0)); expect(tip.localToGlobal(tip.size.topLeft(Offset.zero)).dy, equals(400.0));
expect(tip.localToGlobal(tip.size.bottomRight(Offset.zero)).dy, equals(590.0)); expect(tip.localToGlobal(tip.size.bottomRight(Offset.zero)).dy, equals(590.0));
...@@ -465,7 +463,7 @@ void main() { ...@@ -465,7 +463,7 @@ void main() {
* * }- 10.0 margin * * }- 10.0 margin
*********************/ *********************/
final RenderBox tip = tester.renderObject(find.text(tooltipText)).parent as RenderBox; final RenderBox tip = tester.renderObject(find.text(tooltipText)).parent! as RenderBox;
expect(tip.size.height, equals(190.0)); expect(tip.size.height, equals(190.0));
expect(tip.localToGlobal(tip.size.topLeft(Offset.zero)).dy, equals(400.0)); expect(tip.localToGlobal(tip.size.topLeft(Offset.zero)).dy, equals(400.0));
expect(tip.localToGlobal(tip.size.bottomRight(Offset.zero)).dy, equals(590.0)); expect(tip.localToGlobal(tip.size.bottomRight(Offset.zero)).dy, equals(590.0));
...@@ -505,7 +503,7 @@ void main() { ...@@ -505,7 +503,7 @@ void main() {
(key.currentState as dynamic).ensureTooltipVisible(); // Before using "as dynamic" in your code, see note at the top of the file. (key.currentState as dynamic).ensureTooltipVisible(); // Before using "as dynamic" in your code, see note at the top of the file.
await tester.pump(const Duration(seconds: 2)); // faded in, show timer started (and at 0.0) await tester.pump(const Duration(seconds: 2)); // faded in, show timer started (and at 0.0)
final RenderBox tip = tester.renderObject(find.text(tooltipText)).parent.parent.parent.parent.parent as RenderBox; final RenderBox tip = tester.renderObject(find.text(tooltipText)).parent!.parent!.parent!.parent!.parent! as RenderBox;
final RenderBox tooltipContent = tester.renderObject(find.text(tooltipText)); final RenderBox tooltipContent = tester.renderObject(find.text(tooltipText));
final Offset topLeftTipInGlobal = tip.localToGlobal(tip.size.topLeft(Offset.zero)); final Offset topLeftTipInGlobal = tip.localToGlobal(tip.size.topLeft(Offset.zero));
...@@ -561,7 +559,7 @@ void main() { ...@@ -561,7 +559,7 @@ void main() {
(key.currentState as dynamic).ensureTooltipVisible(); // Before using "as dynamic" in your code, see note at the top of the file. (key.currentState as dynamic).ensureTooltipVisible(); // Before using "as dynamic" in your code, see note at the top of the file.
await tester.pump(const Duration(seconds: 2)); // faded in, show timer started (and at 0.0) await tester.pump(const Duration(seconds: 2)); // faded in, show timer started (and at 0.0)
final RenderBox tip = tester.renderObject(find.text(tooltipText)).parent.parent.parent.parent.parent as RenderBox; final RenderBox tip = tester.renderObject(find.text(tooltipText)).parent!.parent!.parent!.parent!.parent! as RenderBox;
final RenderBox tooltipContent = tester.renderObject(find.text(tooltipText)); final RenderBox tooltipContent = tester.renderObject(find.text(tooltipText));
final Offset topLeftTipInGlobal = tip.localToGlobal(tip.size.topLeft(Offset.zero)); final Offset topLeftTipInGlobal = tip.localToGlobal(tip.size.topLeft(Offset.zero));
...@@ -609,7 +607,7 @@ void main() { ...@@ -609,7 +607,7 @@ void main() {
(key.currentState as dynamic).ensureTooltipVisible(); // Before using "as dynamic" in your code, see note at the top of the file. (key.currentState as dynamic).ensureTooltipVisible(); // Before using "as dynamic" in your code, see note at the top of the file.
await tester.pump(const Duration(seconds: 2)); // faded in, show timer started (and at 0.0) await tester.pump(const Duration(seconds: 2)); // faded in, show timer started (and at 0.0)
final TextStyle textStyle = tester.widget<Text>(find.text(tooltipText)).style; final TextStyle textStyle = tester.widget<Text>(find.text(tooltipText)).style!;
expect(textStyle.color, Colors.orange); expect(textStyle.color, Colors.orange);
expect(textStyle.fontFamily, null); expect(textStyle.fontFamily, null);
expect(textStyle.decoration, TextDecoration.underline); expect(textStyle.decoration, TextDecoration.underline);
...@@ -638,7 +636,7 @@ void main() { ...@@ -638,7 +636,7 @@ void main() {
(key.currentState as dynamic).ensureTooltipVisible(); // Before using "as dynamic" in your code, see note at the top of the file. (key.currentState as dynamic).ensureTooltipVisible(); // Before using "as dynamic" in your code, see note at the top of the file.
await tester.pump(const Duration(seconds: 2)); // faded in, show timer started (and at 0.0) await tester.pump(const Duration(seconds: 2)); // faded in, show timer started (and at 0.0)
final TextStyle textStyle = tester.widget<Text>(find.text(tooltipText)).style; final TextStyle textStyle = tester.widget<Text>(find.text(tooltipText)).style!;
expect(textStyle.color, Colors.orange); expect(textStyle.color, Colors.orange);
expect(textStyle.fontFamily, null); expect(textStyle.fontFamily, null);
expect(textStyle.decoration, TextDecoration.underline); expect(textStyle.decoration, TextDecoration.underline);
...@@ -681,7 +679,7 @@ void main() { ...@@ -681,7 +679,7 @@ void main() {
(key.currentState as dynamic).ensureTooltipVisible(); // Before using "as dynamic" in your code, see note at the top of the file. (key.currentState as dynamic).ensureTooltipVisible(); // Before using "as dynamic" in your code, see note at the top of the file.
await tester.pump(const Duration(seconds: 2)); // faded in, show timer started (and at 0.0) await tester.pump(const Duration(seconds: 2)); // faded in, show timer started (and at 0.0)
final RenderBox tip = tester.renderObject(find.text(tooltipText)).parent.parent.parent.parent as RenderBox; final RenderBox tip = tester.renderObject(find.text(tooltipText)).parent!.parent!.parent!.parent! as RenderBox;
expect(tip.size.height, equals(32.0)); expect(tip.size.height, equals(32.0));
expect(tip.size.width, equals(74.0)); expect(tip.size.width, equals(74.0));
...@@ -723,7 +721,7 @@ void main() { ...@@ -723,7 +721,7 @@ void main() {
(key.currentState as dynamic).ensureTooltipVisible(); // Before using "as dynamic" in your code, see note at the top of the file. (key.currentState as dynamic).ensureTooltipVisible(); // Before using "as dynamic" in your code, see note at the top of the file.
await tester.pump(const Duration(seconds: 2)); // faded in, show timer started (and at 0.0) await tester.pump(const Duration(seconds: 2)); // faded in, show timer started (and at 0.0)
final RenderBox tip = tester.renderObject(find.text(tooltipText)).parent.parent.parent.parent as RenderBox; final RenderBox tip = tester.renderObject(find.text(tooltipText)).parent!.parent!.parent!.parent! as RenderBox;
expect(tip.size.height, equals(32.0)); expect(tip.size.height, equals(32.0));
expect(tip.size.width, equals(74.0)); expect(tip.size.width, equals(74.0));
...@@ -1259,6 +1257,6 @@ void main() { ...@@ -1259,6 +1257,6 @@ void main() {
SemanticsNode findDebugSemantics(RenderObject object) { SemanticsNode findDebugSemantics(RenderObject object) {
if (object.debugSemantics != null) if (object.debugSemantics != null)
return object.debugSemantics; return object.debugSemantics!;
return findDebugSemantics(object.parent as RenderObject); return findDebugSemantics(object.parent! as RenderObject);
} }
...@@ -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_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -19,16 +17,16 @@ void main() { ...@@ -19,16 +17,16 @@ void main() {
}); });
test('Typography on non-Apple platforms defaults to the correct font', () { test('Typography on non-Apple platforms defaults to the correct font', () {
expect(Typography.material2018(platform: TargetPlatform.android).black.headline6.fontFamily, 'Roboto'); expect(Typography.material2018(platform: TargetPlatform.android).black.headline6!.fontFamily, 'Roboto');
expect(Typography.material2018(platform: TargetPlatform.fuchsia).black.headline6.fontFamily, 'Roboto'); expect(Typography.material2018(platform: TargetPlatform.fuchsia).black.headline6!.fontFamily, 'Roboto');
expect(Typography.material2018(platform: TargetPlatform.linux).black.headline6.fontFamily, 'Roboto'); expect(Typography.material2018(platform: TargetPlatform.linux).black.headline6!.fontFamily, 'Roboto');
expect(Typography.material2018(platform: TargetPlatform.linux).black.headline6.fontFamilyFallback, <String>['Ubuntu', 'Cantarell', 'DejaVu Sans', 'Liberation Sans', 'Arial']); expect(Typography.material2018(platform: TargetPlatform.linux).black.headline6!.fontFamilyFallback, <String>['Ubuntu', 'Cantarell', 'DejaVu Sans', 'Liberation Sans', 'Arial']);
expect(Typography.material2018(platform: TargetPlatform.windows).black.headline6.fontFamily, 'Segoe UI'); expect(Typography.material2018(platform: TargetPlatform.windows).black.headline6!.fontFamily, 'Segoe UI');
expect(Typography.material2018(platform: TargetPlatform.android).white.headline6.fontFamily, 'Roboto'); expect(Typography.material2018(platform: TargetPlatform.android).white.headline6!.fontFamily, 'Roboto');
expect(Typography.material2018(platform: TargetPlatform.fuchsia).white.headline6.fontFamily, 'Roboto'); expect(Typography.material2018(platform: TargetPlatform.fuchsia).white.headline6!.fontFamily, 'Roboto');
expect(Typography.material2018(platform: TargetPlatform.linux).white.headline6.fontFamily, 'Roboto'); expect(Typography.material2018(platform: TargetPlatform.linux).white.headline6!.fontFamily, 'Roboto');
expect(Typography.material2018(platform: TargetPlatform.linux).white.headline6.fontFamilyFallback, <String>['Ubuntu', 'Cantarell', 'DejaVu Sans', 'Liberation Sans', 'Arial']); expect(Typography.material2018(platform: TargetPlatform.linux).white.headline6!.fontFamilyFallback, <String>['Ubuntu', 'Cantarell', 'DejaVu Sans', 'Liberation Sans', 'Arial']);
expect(Typography.material2018(platform: TargetPlatform.windows).white.headline6.fontFamily, 'Segoe UI'); expect(Typography.material2018(platform: TargetPlatform.windows).white.headline6!.fontFamily, 'Segoe UI');
}); });
// Ref: https://developer.apple.com/ios/human-interface-guidelines/visual-design/typography/ // Ref: https://developer.apple.com/ios/human-interface-guidelines/visual-design/typography/
...@@ -91,7 +89,7 @@ void main() { ...@@ -91,7 +89,7 @@ void main() {
final List<String> nonDefaultPropertyNames = builder.properties final List<String> nonDefaultPropertyNames = builder.properties
.where((DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info)) .where((DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info))
.map((DiagnosticsNode node) => node.name).toList(); .map((DiagnosticsNode node) => node.name!).toList();
expect(nonDefaultPropertyNames, <String>['black', 'white', 'englishLike', 'dense', 'tall']); expect(nonDefaultPropertyNames, <String>['black', 'white', 'englishLike', 'dense', 'tall']);
}); });
...@@ -106,81 +104,81 @@ void main() { ...@@ -106,81 +104,81 @@ void main() {
const FontWeight medium = FontWeight.w500; const FontWeight medium = FontWeight.w500;
// H1 Roboto light 96 -1.5 // H1 Roboto light 96 -1.5
expect(theme.headline1.fontFamily, 'Roboto'); expect(theme.headline1!.fontFamily, 'Roboto');
expect(theme.headline1.fontWeight, light); expect(theme.headline1!.fontWeight, light);
expect(theme.headline1.fontSize, 96); expect(theme.headline1!.fontSize, 96);
expect(theme.headline1.letterSpacing, -1.5); expect(theme.headline1!.letterSpacing, -1.5);
// H2 Roboto light 60 -0.5 // H2 Roboto light 60 -0.5
expect(theme.headline2.fontFamily, 'Roboto'); expect(theme.headline2!.fontFamily, 'Roboto');
expect(theme.headline2.fontWeight, light); expect(theme.headline2!.fontWeight, light);
expect(theme.headline2.fontSize, 60); expect(theme.headline2!.fontSize, 60);
expect(theme.headline2.letterSpacing, -0.5); expect(theme.headline2!.letterSpacing, -0.5);
// H3 Roboto regular 48 0 // H3 Roboto regular 48 0
expect(theme.headline3.fontFamily, 'Roboto'); expect(theme.headline3!.fontFamily, 'Roboto');
expect(theme.headline3.fontWeight, regular); expect(theme.headline3!.fontWeight, regular);
expect(theme.headline3.fontSize, 48); expect(theme.headline3!.fontSize, 48);
expect(theme.headline3.letterSpacing, 0); expect(theme.headline3!.letterSpacing, 0);
// H4 Roboto regular 34 0.25 // H4 Roboto regular 34 0.25
expect(theme.headline4.fontFamily, 'Roboto'); expect(theme.headline4!.fontFamily, 'Roboto');
expect(theme.headline4.fontWeight, regular); expect(theme.headline4!.fontWeight, regular);
expect(theme.headline4.fontSize, 34); expect(theme.headline4!.fontSize, 34);
expect(theme.headline4.letterSpacing, 0.25); expect(theme.headline4!.letterSpacing, 0.25);
// H5 Roboto regular 24 0 // H5 Roboto regular 24 0
expect(theme.headline5.fontFamily, 'Roboto'); expect(theme.headline5!.fontFamily, 'Roboto');
expect(theme.headline5.fontWeight, regular); expect(theme.headline5!.fontWeight, regular);
expect(theme.headline5.fontSize, 24); expect(theme.headline5!.fontSize, 24);
expect(theme.headline5.letterSpacing, 0); expect(theme.headline5!.letterSpacing, 0);
// H6 Roboto medium 20 0.15 // H6 Roboto medium 20 0.15
expect(theme.headline6.fontFamily, 'Roboto'); expect(theme.headline6!.fontFamily, 'Roboto');
expect(theme.headline6.fontWeight, medium); expect(theme.headline6!.fontWeight, medium);
expect(theme.headline6.fontSize, 20); expect(theme.headline6!.fontSize, 20);
expect(theme.headline6.letterSpacing, 0.15); expect(theme.headline6!.letterSpacing, 0.15);
// Subtitle1 Roboto regular 16 0.15 // Subtitle1 Roboto regular 16 0.15
expect(theme.subtitle1.fontFamily, 'Roboto'); expect(theme.subtitle1!.fontFamily, 'Roboto');
expect(theme.subtitle1.fontWeight, regular); expect(theme.subtitle1!.fontWeight, regular);
expect(theme.subtitle1.fontSize, 16); expect(theme.subtitle1!.fontSize, 16);
expect(theme.subtitle1.letterSpacing, 0.15); expect(theme.subtitle1!.letterSpacing, 0.15);
// Subtitle2 Roboto medium 14 0.1 // Subtitle2 Roboto medium 14 0.1
expect(theme.subtitle2.fontFamily, 'Roboto'); expect(theme.subtitle2!.fontFamily, 'Roboto');
expect(theme.subtitle2.fontWeight, medium); expect(theme.subtitle2!.fontWeight, medium);
expect(theme.subtitle2.fontSize, 14); expect(theme.subtitle2!.fontSize, 14);
expect(theme.subtitle2.letterSpacing, 0.1); expect(theme.subtitle2!.letterSpacing, 0.1);
// Body1 Roboto regular 16 0.5 // Body1 Roboto regular 16 0.5
expect(theme.bodyText1.fontFamily, 'Roboto'); expect(theme.bodyText1!.fontFamily, 'Roboto');
expect(theme.bodyText1.fontWeight, regular); expect(theme.bodyText1!.fontWeight, regular);
expect(theme.bodyText1.fontSize, 16); expect(theme.bodyText1!.fontSize, 16);
expect(theme.bodyText1.letterSpacing, 0.5); expect(theme.bodyText1!.letterSpacing, 0.5);
// Body2 Roboto regular 14 0.25 // Body2 Roboto regular 14 0.25
expect(theme.bodyText2.fontFamily, 'Roboto'); expect(theme.bodyText2!.fontFamily, 'Roboto');
expect(theme.bodyText2.fontWeight, regular); expect(theme.bodyText2!.fontWeight, regular);
expect(theme.bodyText2.fontSize, 14); expect(theme.bodyText2!.fontSize, 14);
expect(theme.bodyText2.letterSpacing, 0.25); expect(theme.bodyText2!.letterSpacing, 0.25);
// BUTTON Roboto medium 14 1.25 // BUTTON Roboto medium 14 1.25
expect(theme.button.fontFamily, 'Roboto'); expect(theme.button!.fontFamily, 'Roboto');
expect(theme.button.fontWeight, medium); expect(theme.button!.fontWeight, medium);
expect(theme.button.fontSize, 14); expect(theme.button!.fontSize, 14);
expect(theme.button.letterSpacing, 1.25); expect(theme.button!.letterSpacing, 1.25);
// Caption Roboto regular 12 0.4 // Caption Roboto regular 12 0.4
expect(theme.caption.fontFamily, 'Roboto'); expect(theme.caption!.fontFamily, 'Roboto');
expect(theme.caption.fontWeight, regular); expect(theme.caption!.fontWeight, regular);
expect(theme.caption.fontSize, 12); expect(theme.caption!.fontSize, 12);
expect(theme.caption.letterSpacing, 0.4); expect(theme.caption!.letterSpacing, 0.4);
// OVERLINE Roboto regular 10 1.5 // OVERLINE Roboto regular 10 1.5
expect(theme.overline.fontFamily, 'Roboto'); expect(theme.overline!.fontFamily, 'Roboto');
expect(theme.overline.fontWeight, regular); expect(theme.overline!.fontWeight, regular);
expect(theme.overline.fontSize, 10); expect(theme.overline!.fontSize, 10);
expect(theme.overline.letterSpacing, 1.5); expect(theme.overline!.letterSpacing, 1.5);
}); });
} }
...@@ -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';
...@@ -143,7 +141,7 @@ void main() { ...@@ -143,7 +141,7 @@ void main() {
// Regression test for https://github.com/flutter/flutter/issues/25801. // Regression test for https://github.com/flutter/flutter/issues/25801.
testWidgets('UserAccountsDrawerHeader icon does not rotate after setState', (WidgetTester tester) async { testWidgets('UserAccountsDrawerHeader icon does not rotate after setState', (WidgetTester tester) async {
StateSetter testSetState; late StateSetter testSetState;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: Material( home: Material(
child: StatefulBuilder( child: StatefulBuilder(
...@@ -251,12 +249,12 @@ void main() { ...@@ -251,12 +249,12 @@ void main() {
testWidgets('UserAccountsDrawerHeader null parameters LTR', (WidgetTester tester) async { testWidgets('UserAccountsDrawerHeader null parameters LTR', (WidgetTester tester) async {
Widget buildFrame({ Widget buildFrame({
Widget currentAccountPicture, Widget? currentAccountPicture,
List<Widget> otherAccountsPictures, List<Widget>? otherAccountsPictures,
Widget accountName, Widget? accountName,
Widget accountEmail, Widget? accountEmail,
VoidCallback onDetailsPressed, VoidCallback? onDetailsPressed,
EdgeInsets margin, EdgeInsets? margin,
}) { }) {
return MaterialApp( return MaterialApp(
home: Material( home: Material(
...@@ -359,12 +357,12 @@ void main() { ...@@ -359,12 +357,12 @@ void main() {
testWidgets('UserAccountsDrawerHeader null parameters RTL', (WidgetTester tester) async { testWidgets('UserAccountsDrawerHeader null parameters RTL', (WidgetTester tester) async {
Widget buildFrame({ Widget buildFrame({
Widget currentAccountPicture, Widget? currentAccountPicture,
List<Widget> otherAccountsPictures, List<Widget>? otherAccountsPictures,
Widget accountName, Widget? accountName,
Widget accountEmail, Widget? accountEmail,
VoidCallback onDetailsPressed, VoidCallback? onDetailsPressed,
EdgeInsets margin, EdgeInsets? margin,
}) { }) {
return MaterialApp( return MaterialApp(
home: Directionality( home: Directionality(
......
...@@ -2,21 +2,19 @@ ...@@ -2,21 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
bool willPopValue = false; bool willPopValue = false;
class SamplePage extends StatefulWidget { class SamplePage extends StatefulWidget {
const SamplePage({ Key key }) : super(key: key); const SamplePage({ Key? key }) : super(key: key);
@override @override
SamplePageState createState() => SamplePageState(); SamplePageState createState() => SamplePageState();
} }
class SamplePageState extends State<SamplePage> { class SamplePageState extends State<SamplePage> {
ModalRoute<void> _route; ModalRoute<void>? _route;
Future<bool> _callback() async => willPopValue; Future<bool> _callback() async => willPopValue;
...@@ -45,7 +43,7 @@ class SamplePageState extends State<SamplePage> { ...@@ -45,7 +43,7 @@ class SamplePageState extends State<SamplePage> {
int willPopCount = 0; int willPopCount = 0;
class SampleForm extends StatelessWidget { class SampleForm extends StatelessWidget {
const SampleForm({ Key key, this.callback }) : super(key: key); const SampleForm({ Key? key, required this.callback }) : super(key: key);
final WillPopCallback callback; final WillPopCallback callback;
...@@ -68,7 +66,7 @@ class SampleForm extends StatelessWidget { ...@@ -68,7 +66,7 @@ class SampleForm extends StatelessWidget {
// Expose the protected hasScopedWillPopCallback getter // Expose the protected hasScopedWillPopCallback getter
class TestPageRoute<T> extends MaterialPageRoute<T> { class TestPageRoute<T> extends MaterialPageRoute<T> {
TestPageRoute({ WidgetBuilder builder }) TestPageRoute({ required WidgetBuilder builder })
: super(builder: builder, maintainState: true); : super(builder: builder, maintainState: true);
bool get hasCallback => super.hasScopedWillPopCallback; bool get hasCallback => super.hasScopedWillPopCallback;
...@@ -118,7 +116,7 @@ void main() { ...@@ -118,7 +116,7 @@ void main() {
// Use didPopRoute() to simulate the system back button. Check that // Use didPopRoute() to simulate the system back button. Check that
// didPopRoute() indicates that the notification was handled. // didPopRoute() indicates that the notification was handled.
final dynamic widgetsAppState = tester.state(find.byType(WidgetsApp)); final dynamic widgetsAppState = tester.state(find.byType(WidgetsApp)); // ignore: unnecessary_nullable_for_final_variable_declarations
expect(await widgetsAppState.didPopRoute(), isTrue); expect(await widgetsAppState.didPopRoute(), isTrue);
expect(find.text('Sample Page'), findsOneWidget); expect(find.text('Sample Page'), findsOneWidget);
...@@ -141,7 +139,7 @@ void main() { ...@@ -141,7 +139,7 @@ void main() {
child: TextButton( child: TextButton(
child: const Text('X'), child: const Text('X'),
onPressed: () { onPressed: () {
Navigator.of(context).push(MaterialPageRoute<void>( Navigator.of(context)!.push(MaterialPageRoute<void>(
builder: (BuildContext context) { builder: (BuildContext context) {
return SampleForm( return SampleForm(
callback: () => Future<bool>.value(willPopValue), callback: () => Future<bool>.value(willPopValue),
...@@ -162,12 +160,6 @@ void main() { ...@@ -162,12 +160,6 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text('Sample Form'), findsOneWidget); expect(find.text('Sample Form'), findsOneWidget);
// Should not pop if callback returns null
willPopValue = null;
await tester.tap(find.byTooltip('Back'));
await tester.pumpAndSettle();
expect(find.text('Sample Form'), findsOneWidget);
// Should pop if callback returns true // Should pop if callback returns true
willPopValue = true; willPopValue = true;
await tester.tap(find.byTooltip('Back')); await tester.tap(find.byTooltip('Back'));
...@@ -186,7 +178,7 @@ void main() { ...@@ -186,7 +178,7 @@ void main() {
child: TextButton( child: TextButton(
child: const Text('X'), child: const Text('X'),
onPressed: () { onPressed: () {
Navigator.of(context).push(MaterialPageRoute<void>( Navigator.of(context)!.push(MaterialPageRoute<void>(
builder: (BuildContext context) { builder: (BuildContext context) {
return SampleForm( return SampleForm(
callback: () => Future<bool>.value(willPopValue), callback: () => Future<bool>.value(willPopValue),
...@@ -238,11 +230,11 @@ void main() { ...@@ -238,11 +230,11 @@ void main() {
actions: <Widget> [ actions: <Widget> [
TextButton( TextButton(
child: const Text('YES'), child: const Text('YES'),
onPressed: () { Navigator.of(context).pop(true); }, onPressed: () { Navigator.of(context)!.pop(true); },
), ),
TextButton( TextButton(
child: const Text('NO'), child: const Text('NO'),
onPressed: () { Navigator.of(context).pop(false); }, onPressed: () { Navigator.of(context)!.pop(false); },
), ),
], ],
); );
...@@ -260,7 +252,7 @@ void main() { ...@@ -260,7 +252,7 @@ void main() {
child: TextButton( child: TextButton(
child: const Text('X'), child: const Text('X'),
onPressed: () { onPressed: () {
Navigator.of(context).push(MaterialPageRoute<void>( Navigator.of(context)!.push(MaterialPageRoute<void>(
builder: (BuildContext context) { builder: (BuildContext context) {
return SampleForm( return SampleForm(
callback: () => showYesNoAlert(context), callback: () => showYesNoAlert(context),
...@@ -322,7 +314,7 @@ void main() { ...@@ -322,7 +314,7 @@ void main() {
}); });
testWidgets('Route.scopedWillPop callbacks do not accumulate', (WidgetTester tester) async { testWidgets('Route.scopedWillPop callbacks do not accumulate', (WidgetTester tester) async {
StateSetter contentsSetState; // call this to rebuild the route's SampleForm contents late StateSetter contentsSetState; // call this to rebuild the route's SampleForm contents
bool contentsEmpty = false; // when true, don't include the SampleForm in the route bool contentsEmpty = false; // when true, don't include the SampleForm in the route
final TestPageRoute<void> route = TestPageRoute<void>( final TestPageRoute<void> route = TestPageRoute<void>(
...@@ -330,7 +322,7 @@ void main() { ...@@ -330,7 +322,7 @@ void main() {
return StatefulBuilder( return StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
contentsSetState = setState; contentsSetState = setState;
return contentsEmpty ? Container() : SampleForm(key: UniqueKey()); return contentsEmpty ? Container() : SampleForm(key: UniqueKey(), callback: () async => false);
} }
); );
}, },
...@@ -346,7 +338,7 @@ void main() { ...@@ -346,7 +338,7 @@ void main() {
child: TextButton( child: TextButton(
child: const Text('X'), child: const Text('X'),
onPressed: () { onPressed: () {
Navigator.of(context).push(route); Navigator.of(context)!.push(route);
}, },
), ),
); );
......
...@@ -2,13 +2,11 @@ ...@@ -2,13 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
class TestRoute<T> extends PageRoute<T> { class TestRoute<T> extends PageRoute<T> {
TestRoute({ this.child, RouteSettings settings }) : super(settings: settings); TestRoute({ required this.child, RouteSettings? settings }) : super(settings: settings);
final Widget child; final Widget child;
...@@ -16,10 +14,10 @@ class TestRoute<T> extends PageRoute<T> { ...@@ -16,10 +14,10 @@ class TestRoute<T> extends PageRoute<T> {
Duration get transitionDuration => const Duration(milliseconds: 150); Duration get transitionDuration => const Duration(milliseconds: 150);
@override @override
Color get barrierColor => null; Color? get barrierColor => null;
@override @override
String get barrierLabel => null; String? get barrierLabel => null;
@override @override
bool get maintainState => false; bool get maintainState => false;
......
...@@ -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/services.dart'; import 'package:flutter/services.dart';
...@@ -33,7 +31,7 @@ void main() { ...@@ -33,7 +31,7 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
WidgetsApp( WidgetsApp(
key: key, key: key,
builder: (BuildContext context, Widget child) { builder: (BuildContext context, Widget? child) {
return const Placeholder(); return const Placeholder();
}, },
color: const Color(0xFF123456), color: const Color(0xFF123456),
...@@ -43,17 +41,17 @@ void main() { ...@@ -43,17 +41,17 @@ void main() {
}); });
testWidgets('WidgetsApp can override default key bindings', (WidgetTester tester) async { testWidgets('WidgetsApp can override default key bindings', (WidgetTester tester) async {
bool checked = false; bool? checked = false;
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
WidgetsApp( WidgetsApp(
key: key, key: key,
builder: (BuildContext context, Widget child) { builder: (BuildContext context, Widget? child) {
return Material( return Material(
child: Checkbox( child: Checkbox(
value: checked, value: checked,
autofocus: true, autofocus: true,
onChanged: (bool value) { onChanged: (bool? value) {
checked = value; checked = value;
}, },
), ),
...@@ -79,12 +77,12 @@ void main() { ...@@ -79,12 +77,12 @@ void main() {
shortcuts: <LogicalKeySet, Intent> { shortcuts: <LogicalKeySet, Intent> {
LogicalKeySet(LogicalKeyboardKey.space): const TestIntent(), LogicalKeySet(LogicalKeyboardKey.space): const TestIntent(),
}, },
builder: (BuildContext context, Widget child) { builder: (BuildContext context, Widget? child) {
return Material( return Material(
child: Checkbox( child: Checkbox(
value: checked, value: checked,
autofocus: true, autofocus: true,
onChanged: (bool value) { onChanged: (bool? value) {
checked = value; checked = value;
}, },
), ),
...@@ -104,16 +102,16 @@ void main() { ...@@ -104,16 +102,16 @@ void main() {
}); });
testWidgets('WidgetsApp default activation key mappings work', (WidgetTester tester) async { testWidgets('WidgetsApp default activation key mappings work', (WidgetTester tester) async {
bool checked = false; bool? checked = false;
await tester.pumpWidget( await tester.pumpWidget(
WidgetsApp( WidgetsApp(
builder: (BuildContext context, Widget child) { builder: (BuildContext context, Widget? child) {
return Material( return Material(
child: Checkbox( child: Checkbox(
value: checked, value: checked,
autofocus: true, autofocus: true,
onChanged: (bool value) { onChanged: (bool? value) {
checked = value; checked = value;
}, },
), ),
...@@ -147,15 +145,15 @@ void main() { ...@@ -147,15 +145,15 @@ void main() {
group('error control test', () { group('error control test', () {
Future<void> expectFlutterError({ Future<void> expectFlutterError({
GlobalKey<NavigatorState> key, required GlobalKey<NavigatorState> key,
Widget widget, required Widget widget,
WidgetTester tester, required WidgetTester tester,
String errorMessage, required String errorMessage,
}) async { }) async {
await tester.pumpWidget(widget); await tester.pumpWidget(widget);
FlutterError error; late FlutterError error;
try { try {
key.currentState.pushNamed('/path'); key.currentState!.pushNamed('/path');
} on FlutterError catch (e) { } on FlutterError catch (e) {
error = e; error = e;
} finally { } finally {
...@@ -258,7 +256,7 @@ void main() { ...@@ -258,7 +256,7 @@ void main() {
expect(find.text('non-regular page two'), findsOneWidget); expect(find.text('non-regular page two'), findsOneWidget);
expect(find.text('non-regular page one'), findsNothing); expect(find.text('non-regular page one'), findsNothing);
expect(find.text('regular page'), findsNothing); expect(find.text('regular page'), findsNothing);
navigatorKey.currentState.pop(); navigatorKey.currentState!.pop();
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text('non-regular page two'), findsNothing); expect(find.text('non-regular page two'), findsNothing);
expect(find.text('non-regular page one'), findsOneWidget); expect(find.text('non-regular page one'), findsOneWidget);
...@@ -273,7 +271,7 @@ void main() { ...@@ -273,7 +271,7 @@ void main() {
); );
final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate( final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate(
builder: (BuildContext context, RouteInformation information) { builder: (BuildContext context, RouteInformation information) {
return Text(information.location); return Text(information.location!);
}, },
onPopPage: (Route<void> route, void result, SimpleNavigatorRouterDelegate delegate) { onPopPage: (Route<void> route, void result, SimpleNavigatorRouterDelegate delegate) {
delegate.routeInformation = const RouteInformation( delegate.routeInformation = const RouteInformation(
...@@ -292,7 +290,7 @@ void main() { ...@@ -292,7 +290,7 @@ void main() {
// Simulate android back button intent. // Simulate android back button intent.
final ByteData message = const JSONMethodCodec().encodeMethodCall(const MethodCall('popRoute')); final ByteData message = const JSONMethodCodec().encodeMethodCall(const MethodCall('popRoute'));
await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage('flutter/navigation', message, (_) { }); await ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage('flutter/navigation', message, (_) { });
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text('popped'), findsOneWidget); expect(find.text('popped'), findsOneWidget);
}); });
...@@ -300,8 +298,9 @@ void main() { ...@@ -300,8 +298,9 @@ void main() {
testWidgets('WidgetsApp.router has correct default', (WidgetTester tester) async { testWidgets('WidgetsApp.router has correct default', (WidgetTester tester) async {
final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate( final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate(
builder: (BuildContext context, RouteInformation information) { builder: (BuildContext context, RouteInformation information) {
return Text(information.location); return Text(information.location!);
}, },
onPopPage: (Route<Object?> route, Object? result, SimpleNavigatorRouterDelegate delegate) => true,
); );
await tester.pumpWidget(WidgetsApp.router( await tester.pumpWidget(WidgetsApp.router(
routeInformationParser: SimpleRouteInformationParser(), routeInformationParser: SimpleRouteInformationParser(),
...@@ -331,22 +330,22 @@ class SimpleRouteInformationParser extends RouteInformationParser<RouteInformati ...@@ -331,22 +330,22 @@ class SimpleRouteInformationParser extends RouteInformationParser<RouteInformati
class SimpleNavigatorRouterDelegate extends RouterDelegate<RouteInformation> with PopNavigatorRouterDelegateMixin<RouteInformation>, ChangeNotifier { class SimpleNavigatorRouterDelegate extends RouterDelegate<RouteInformation> with PopNavigatorRouterDelegateMixin<RouteInformation>, ChangeNotifier {
SimpleNavigatorRouterDelegate({ SimpleNavigatorRouterDelegate({
@required this.builder, required this.builder,
this.onPopPage, required this.onPopPage,
}); });
@override @override
GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>(); GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
RouteInformation get routeInformation => _routeInformation; RouteInformation get routeInformation => _routeInformation;
RouteInformation _routeInformation; late RouteInformation _routeInformation;
set routeInformation(RouteInformation newValue) { set routeInformation(RouteInformation newValue) {
_routeInformation = newValue; _routeInformation = newValue;
notifyListeners(); notifyListeners();
} }
SimpleRouterDelegateBuilder builder; final SimpleRouterDelegateBuilder builder;
SimpleNavigatorRouterDelegatePopPage<void> onPopPage; final SimpleNavigatorRouterDelegatePopPage<void> onPopPage;
@override @override
Future<void> setNewRoutePath(RouteInformation configuration) { Future<void> setNewRoutePath(RouteInformation configuration) {
...@@ -370,7 +369,7 @@ class SimpleNavigatorRouterDelegate extends RouterDelegate<RouteInformation> wit ...@@ -370,7 +369,7 @@ class SimpleNavigatorRouterDelegate extends RouterDelegate<RouteInformation> wit
child: Text('base'), child: Text('base'),
), ),
MaterialPage<void>( MaterialPage<void>(
key: ValueKey<String>(routeInformation?.location), key: ValueKey<String>(routeInformation.location!),
child: builder(context, routeInformation), child: builder(context, routeInformation),
) )
], ],
......
...@@ -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/widgets.dart'; import 'package:flutter/widgets.dart';
const Color kTitleColor = Color(0xFF333333); const Color kTitleColor = Color(0xFF333333);
const String kTitleString = 'Hello World'; const String kTitleString = 'Hello World';
Future<void> pumpApp(WidgetTester tester, { GenerateAppTitle onGenerateTitle }) async { Future<void> pumpApp(WidgetTester tester, { GenerateAppTitle? onGenerateTitle }) async {
await tester.pumpWidget( await tester.pumpWidget(
WidgetsApp( WidgetsApp(
supportedLocales: const <Locale>[ supportedLocales: const <Locale>[
......
...@@ -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/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
......
...@@ -2,13 +2,11 @@ ...@@ -2,13 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
class InvalidOnInitLifecycleWidget extends StatefulWidget { class InvalidOnInitLifecycleWidget extends StatefulWidget {
const InvalidOnInitLifecycleWidget({Key key}) : super(key: key); const InvalidOnInitLifecycleWidget({Key? key}) : super(key: key);
@override @override
InvalidOnInitLifecycleWidgetState createState() => InvalidOnInitLifecycleWidgetState(); InvalidOnInitLifecycleWidgetState createState() => InvalidOnInitLifecycleWidgetState();
...@@ -27,7 +25,7 @@ class InvalidOnInitLifecycleWidgetState extends State<InvalidOnInitLifecycleWidg ...@@ -27,7 +25,7 @@ class InvalidOnInitLifecycleWidgetState extends State<InvalidOnInitLifecycleWidg
} }
class InvalidDidUpdateWidgetLifecycleWidget extends StatefulWidget { class InvalidDidUpdateWidgetLifecycleWidget extends StatefulWidget {
const InvalidDidUpdateWidgetLifecycleWidget({Key key, this.id}) : super(key: key); const InvalidDidUpdateWidgetLifecycleWidget({Key? key, required this.id}) : super(key: key);
final int id; final int id;
......
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