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 'dart:ui' as ui; import 'dart:ui' as ui;
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -46,11 +44,11 @@ void main() { ...@@ -46,11 +44,11 @@ void main() {
await tester.tap(find.byKey(popupMenuButtonKey)); await tester.tap(find.byKey(popupMenuButtonKey));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
expect(Theme.of(tester.element(find.text('menuItem'))).brightness, equals(Brightness.dark)); expect(Theme.of(tester.element(find.text('menuItem')))!.brightness, equals(Brightness.dark));
}); });
testWidgets('Fallback theme', (WidgetTester tester) async { testWidgets('Fallback theme', (WidgetTester tester) async {
BuildContext capturedContext; late BuildContext capturedContext;
await tester.pumpWidget( await tester.pumpWidget(
Builder( Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
...@@ -116,7 +114,7 @@ void main() { ...@@ -116,7 +114,7 @@ void main() {
await tester.tap(find.byKey(popupMenuButtonKey)); await tester.tap(find.byKey(popupMenuButtonKey));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
expect(Theme.of(tester.element(find.text('menuItem'))).brightness, equals(Brightness.light)); expect(Theme.of(tester.element(find.text('menuItem')))!.brightness, equals(Brightness.light));
}); });
testWidgets('DropdownMenu inherits shadowed app theme', (WidgetTester tester) async { testWidgets('DropdownMenu inherits shadowed app theme', (WidgetTester tester) async {
...@@ -131,7 +129,7 @@ void main() { ...@@ -131,7 +129,7 @@ void main() {
actions: <Widget>[ actions: <Widget>[
DropdownButton<String>( DropdownButton<String>(
key: dropdownMenuButtonKey, key: dropdownMenuButtonKey,
onChanged: (String newValue) { }, onChanged: (String? newValue) { },
value: 'menuItem', value: 'menuItem',
items: const <DropdownMenuItem<String>>[ items: const <DropdownMenuItem<String>>[
DropdownMenuItem<String>( DropdownMenuItem<String>(
...@@ -151,7 +149,7 @@ void main() { ...@@ -151,7 +149,7 @@ void main() {
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
for (final Element item in tester.elementList(find.text('menuItem'))) for (final Element item in tester.elementList(find.text('menuItem')))
expect(Theme.of(item).brightness, equals(Brightness.light)); expect(Theme.of(item)!.brightness, equals(Brightness.light));
}); });
testWidgets('ModalBottomSheet inherits shadowed app theme', (WidgetTester tester) async { testWidgets('ModalBottomSheet inherits shadowed app theme', (WidgetTester tester) async {
...@@ -183,7 +181,7 @@ void main() { ...@@ -183,7 +181,7 @@ void main() {
await tester.tap(find.text('SHOW')); await tester.tap(find.text('SHOW'));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
expect(Theme.of(tester.element(find.text('bottomSheet'))).brightness, equals(Brightness.light)); expect(Theme.of(tester.element(find.text('bottomSheet')))!.brightness, equals(Brightness.light));
await tester.tap(find.text('bottomSheet')); // dismiss the bottom sheet await tester.tap(find.text('bottomSheet')); // dismiss the bottom sheet
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
...@@ -220,7 +218,7 @@ void main() { ...@@ -220,7 +218,7 @@ void main() {
await tester.tap(find.text('SHOW')); await tester.tap(find.text('SHOW'));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
expect(Theme.of(tester.element(find.text('dialog'))).brightness, equals(Brightness.light)); expect(Theme.of(tester.element(find.text('dialog')))!.brightness, equals(Brightness.light));
}); });
testWidgets("Scaffold inherits theme's scaffoldBackgroundColor", (WidgetTester tester) async { testWidgets("Scaffold inherits theme's scaffoldBackgroundColor", (WidgetTester tester) async {
...@@ -275,8 +273,8 @@ void main() { ...@@ -275,8 +273,8 @@ void main() {
RenderParagraph glyphText = tester.renderObject(find.byType(RichText)); RenderParagraph glyphText = tester.renderObject(find.byType(RichText));
expect(glyphText.text.style.color, Colors.green); expect(glyphText.text.style!.color, Colors.green);
expect(glyphText.text.style.fontSize, 10.0); expect(glyphText.text.style!.fontSize, 10.0);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -288,14 +286,14 @@ void main() { ...@@ -288,14 +286,14 @@ void main() {
glyphText = tester.renderObject(find.byType(RichText)); glyphText = tester.renderObject(find.byType(RichText));
expect(glyphText.text.style.color, Color.lerp(Colors.green, Colors.orange, 0.5)); expect(glyphText.text.style!.color, Color.lerp(Colors.green, Colors.orange, 0.5));
expect(glyphText.text.style.fontSize, 15.0); expect(glyphText.text.style!.fontSize, 15.0);
await tester.pump(const Duration(milliseconds: 100)); // Finish the transition await tester.pump(const Duration(milliseconds: 100)); // Finish the transition
glyphText = tester.renderObject(find.byType(RichText)); glyphText = tester.renderObject(find.byType(RichText));
expect(glyphText.text.style.color, Colors.orange); expect(glyphText.text.style!.color, Colors.orange);
expect(glyphText.text.style.fontSize, 20.0); expect(glyphText.text.style!.fontSize, 20.0);
}); });
testWidgets( testWidgets(
...@@ -338,21 +336,21 @@ void main() { ...@@ -338,21 +336,21 @@ void main() {
final ThemeData fallback = ThemeData.fallback(); final ThemeData fallback = ThemeData.fallback();
final ThemeData customTheme = fallback.copyWith( final ThemeData customTheme = fallback.copyWith(
primaryTextTheme: fallback.primaryTextTheme.copyWith( primaryTextTheme: fallback.primaryTextTheme.copyWith(
bodyText2: fallback.primaryTextTheme.bodyText2.copyWith( bodyText2: fallback.primaryTextTheme.bodyText2!.copyWith(
fontSize: _kMagicFontSize, fontSize: _kMagicFontSize,
), ),
), ),
); );
expect(customTheme.primaryTextTheme.bodyText2.fontSize, _kMagicFontSize); expect(customTheme.primaryTextTheme.bodyText2!.fontSize, _kMagicFontSize);
double actualFontSize; late double actualFontSize;
await tester.pumpWidget(Directionality( await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Theme( child: Theme(
data: customTheme, data: customTheme,
child: Builder(builder: (BuildContext context) { child: Builder(builder: (BuildContext context) {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context)!;
actualFontSize = theme.primaryTextTheme.bodyText2.fontSize; actualFontSize = theme.primaryTextTheme.bodyText2!.fontSize!;
return Text( return Text(
'A', 'A',
style: theme.primaryTextTheme.bodyText2, style: theme.primaryTextTheme.bodyText2,
...@@ -365,12 +363,12 @@ void main() { ...@@ -365,12 +363,12 @@ void main() {
}); });
testWidgets('Default Theme provides all basic TextStyle properties', (WidgetTester tester) async { testWidgets('Default Theme provides all basic TextStyle properties', (WidgetTester tester) async {
ThemeData theme; late ThemeData theme;
await tester.pumpWidget(Directionality( await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Builder( child: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
theme = Theme.of(context); theme = Theme.of(context)!;
return const Text('A'); return const Text('A');
}, },
), ),
...@@ -378,17 +376,17 @@ void main() { ...@@ -378,17 +376,17 @@ void main() {
List<TextStyle> extractStyles(TextTheme textTheme) { List<TextStyle> extractStyles(TextTheme textTheme) {
return <TextStyle>[ return <TextStyle>[
textTheme.headline1, textTheme.headline1!,
textTheme.headline2, textTheme.headline2!,
textTheme.headline3, textTheme.headline3!,
textTheme.headline4, textTheme.headline4!,
textTheme.headline5, textTheme.headline5!,
textTheme.headline6, textTheme.headline6!,
textTheme.subtitle1, textTheme.subtitle1!,
textTheme.bodyText1, textTheme.bodyText1!,
textTheme.bodyText2, textTheme.bodyText2!,
textTheme.caption, textTheme.caption!,
textTheme.button, textTheme.button!,
]; ];
} }
...@@ -413,14 +411,14 @@ void main() { ...@@ -413,14 +411,14 @@ void main() {
} }
} }
expect(theme.textTheme.headline1.debugLabel, '(englishLike display4 2014).merge(blackMountainView headline1)'); expect(theme.textTheme.headline1!.debugLabel, '(englishLike display4 2014).merge(blackMountainView headline1)');
}); });
group('Cupertino theme', () { group('Cupertino theme', () {
int buildCount; late int buildCount;
CupertinoThemeData actualTheme; CupertinoThemeData? actualTheme;
IconThemeData actualIconTheme; IconThemeData? actualIconTheme;
BuildContext context; BuildContext? context;
final Widget singletonThemeSubtree = Builder( final Widget singletonThemeSubtree = Builder(
builder: (BuildContext localContext) { builder: (BuildContext localContext) {
...@@ -434,7 +432,7 @@ void main() { ...@@ -434,7 +432,7 @@ void main() {
Future<CupertinoThemeData> testTheme(WidgetTester tester, ThemeData theme) async { Future<CupertinoThemeData> testTheme(WidgetTester tester, ThemeData theme) async {
await tester.pumpWidget(Theme(data: theme, child: singletonThemeSubtree)); await tester.pumpWidget(Theme(data: theme, child: singletonThemeSubtree));
return actualTheme; return actualTheme!;
} }
setUp(() { setUp(() {
...@@ -468,23 +466,23 @@ void main() { ...@@ -468,23 +466,23 @@ void main() {
testWidgets('MaterialTheme overrides the brightness', (WidgetTester tester) async { testWidgets('MaterialTheme overrides the brightness', (WidgetTester tester) async {
await testTheme(tester, ThemeData.dark()); await testTheme(tester, ThemeData.dark());
expect(CupertinoTheme.brightnessOf(context), Brightness.dark); expect(CupertinoTheme.brightnessOf(context!), Brightness.dark);
await testTheme(tester, ThemeData.light()); await testTheme(tester, ThemeData.light());
expect(CupertinoTheme.brightnessOf(context), Brightness.light); expect(CupertinoTheme.brightnessOf(context!), Brightness.light);
// Overridable by cupertinoOverrideTheme. // Overridable by cupertinoOverrideTheme.
await testTheme(tester, ThemeData( await testTheme(tester, ThemeData(
brightness: Brightness.light, brightness: Brightness.light,
cupertinoOverrideTheme: const CupertinoThemeData(brightness: Brightness.dark), cupertinoOverrideTheme: const CupertinoThemeData(brightness: Brightness.dark),
)); ));
expect(CupertinoTheme.brightnessOf(context), Brightness.dark); expect(CupertinoTheme.brightnessOf(context!), Brightness.dark);
await testTheme(tester, ThemeData( await testTheme(tester, ThemeData(
brightness: Brightness.dark, brightness: Brightness.dark,
cupertinoOverrideTheme: const CupertinoThemeData(brightness: Brightness.light), cupertinoOverrideTheme: const CupertinoThemeData(brightness: Brightness.light),
)); ));
expect(CupertinoTheme.brightnessOf(context), Brightness.light); expect(CupertinoTheme.brightnessOf(context!), Brightness.light);
}); });
testWidgets('Can override material theme', (WidgetTester tester) async { testWidgets('Can override material theme', (WidgetTester tester) async {
...@@ -544,7 +542,7 @@ void main() { ...@@ -544,7 +542,7 @@ void main() {
)); ));
expect(buildCount, 1); expect(buildCount, 1);
expect(actualIconTheme.color, materialIconColor); expect(actualIconTheme!.color, materialIconColor);
}); });
testWidgets( testWidgets(
...@@ -674,9 +672,9 @@ void main() { ...@@ -674,9 +672,9 @@ void main() {
}); });
} }
int testBuildCalled; int testBuildCalled = 0;
class Test extends StatefulWidget { class Test extends StatefulWidget {
const Test({ Key key }) : super(key: key); const Test({ Key? key }) : super(key: key);
@override @override
_TestState createState() => _TestState(); _TestState createState() => _TestState();
...@@ -688,7 +686,7 @@ class _TestState extends State<Test> { ...@@ -688,7 +686,7 @@ class _TestState extends State<Test> {
testBuildCalled += 1; testBuildCalled += 1;
return Container( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Theme.of(context).primaryColor, color: Theme.of(context)!.primaryColor,
), ),
); );
} }
...@@ -704,56 +702,56 @@ class _TextStyleProxy implements TextStyle { ...@@ -704,56 +702,56 @@ class _TextStyleProxy implements TextStyle {
// Do make sure that all the properties correctly forward to the _delegate. // Do make sure that all the properties correctly forward to the _delegate.
@override @override
Color get color => _delegate.color; Color? get color => _delegate.color;
@override @override
Color get backgroundColor => _delegate.backgroundColor; Color? get backgroundColor => _delegate.backgroundColor;
@override @override
String get debugLabel => _delegate.debugLabel; String? get debugLabel => _delegate.debugLabel;
@override @override
TextDecoration get decoration => _delegate.decoration; TextDecoration? get decoration => _delegate.decoration;
@override @override
Color get decorationColor => _delegate.decorationColor; Color? get decorationColor => _delegate.decorationColor;
@override @override
TextDecorationStyle get decorationStyle => _delegate.decorationStyle; TextDecorationStyle? get decorationStyle => _delegate.decorationStyle;
@override @override
double get decorationThickness => _delegate.decorationThickness; double? get decorationThickness => _delegate.decorationThickness;
@override @override
String get fontFamily => _delegate.fontFamily; String? get fontFamily => _delegate.fontFamily;
@override @override
List<String> get fontFamilyFallback => _delegate.fontFamilyFallback; List<String>? get fontFamilyFallback => _delegate.fontFamilyFallback;
@override @override
double get fontSize => _delegate.fontSize; double? get fontSize => _delegate.fontSize;
@override @override
FontStyle get fontStyle => _delegate.fontStyle; FontStyle? get fontStyle => _delegate.fontStyle;
@override @override
FontWeight get fontWeight => _delegate.fontWeight; FontWeight? get fontWeight => _delegate.fontWeight;
@override @override
double get height => _delegate.height; double? get height => _delegate.height;
@override @override
Locale get locale => _delegate.locale; Locale? get locale => _delegate.locale;
@override @override
ui.Paint get foreground => _delegate.foreground; ui.Paint? get foreground => _delegate.foreground;
@override @override
ui.Paint get background => _delegate.background; ui.Paint? get background => _delegate.background;
@override @override
bool get inherit => _delegate.inherit; bool get inherit => _delegate.inherit;
@override @override
double get letterSpacing => _delegate.letterSpacing; double? get letterSpacing => _delegate.letterSpacing;
@override @override
TextBaseline get textBaseline => _delegate.textBaseline; TextBaseline? get textBaseline => _delegate.textBaseline;
@override @override
double get wordSpacing => _delegate.wordSpacing; double? get wordSpacing => _delegate.wordSpacing;
@override @override
List<Shadow> get shadows => _delegate.shadows; List<Shadow>? get shadows => _delegate.shadows;
@override @override
List<ui.FontFeature> get fontFeatures => _delegate.fontFeatures; List<ui.FontFeature>? get fontFeatures => _delegate.fontFeatures;
@override @override
String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) => String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) =>
super.toString(); super.toString();
@override @override
DiagnosticsNode toDiagnosticsNode({ String name, DiagnosticsTreeStyle style }) { DiagnosticsNode toDiagnosticsNode({ String? name, DiagnosticsTreeStyle? style }) {
throw UnimplementedError(); throw UnimplementedError();
} }
...@@ -764,29 +762,29 @@ class _TextStyleProxy implements TextStyle { ...@@ -764,29 +762,29 @@ class _TextStyleProxy implements TextStyle {
@override @override
TextStyle apply({ TextStyle apply({
Color color, Color? color,
Color backgroundColor, Color? backgroundColor,
TextDecoration decoration, TextDecoration? decoration,
Color decorationColor, Color? decorationColor,
TextDecorationStyle decorationStyle, TextDecorationStyle? decorationStyle,
double decorationThicknessFactor = 1.0, double decorationThicknessFactor = 1.0,
double decorationThicknessDelta = 0.0, double decorationThicknessDelta = 0.0,
String fontFamily, String? fontFamily,
List<String> fontFamilyFallback, List<String>? fontFamilyFallback,
double fontSizeFactor = 1.0, double fontSizeFactor = 1.0,
double fontSizeDelta = 0.0, double fontSizeDelta = 0.0,
int fontWeightDelta = 0, int fontWeightDelta = 0,
FontStyle fontStyle, FontStyle? fontStyle,
double letterSpacingFactor = 1.0, double letterSpacingFactor = 1.0,
double letterSpacingDelta = 0.0, double letterSpacingDelta = 0.0,
double wordSpacingFactor = 1.0, double wordSpacingFactor = 1.0,
double wordSpacingDelta = 0.0, double wordSpacingDelta = 0.0,
double heightFactor = 1.0, double heightFactor = 1.0,
double heightDelta = 0.0, double heightDelta = 0.0,
TextBaseline textBaseline, TextBaseline? textBaseline,
Locale locale, Locale? locale,
List<ui.Shadow> shadows, List<ui.Shadow>? shadows,
List<ui.FontFeature> fontFeatures, List<ui.FontFeature>? fontFeatures,
}) { }) {
throw UnimplementedError(); throw UnimplementedError();
} }
...@@ -798,28 +796,28 @@ class _TextStyleProxy implements TextStyle { ...@@ -798,28 +796,28 @@ class _TextStyleProxy implements TextStyle {
@override @override
TextStyle copyWith({ TextStyle copyWith({
bool inherit, bool? inherit,
Color color, Color? color,
Color backgroundColor, Color? backgroundColor,
String fontFamily, String? fontFamily,
List<String> fontFamilyFallback, List<String>? fontFamilyFallback,
double fontSize, double? fontSize,
FontWeight fontWeight, FontWeight? fontWeight,
FontStyle fontStyle, FontStyle? fontStyle,
double letterSpacing, double? letterSpacing,
double wordSpacing, double? wordSpacing,
TextBaseline textBaseline, TextBaseline? textBaseline,
double height, double? height,
Locale locale, Locale? locale,
ui.Paint foreground, ui.Paint? foreground,
ui.Paint background, ui.Paint? background,
List<Shadow> shadows, List<Shadow>? shadows,
List<ui.FontFeature> fontFeatures, List<ui.FontFeature>? fontFeatures,
TextDecoration decoration, TextDecoration? decoration,
Color decorationColor, Color? decorationColor,
TextDecorationStyle decorationStyle, TextDecorationStyle? decorationStyle,
double decorationThickness, double? decorationThickness,
String debugLabel, String? debugLabel,
}) { }) {
throw UnimplementedError(); throw UnimplementedError();
} }
...@@ -831,19 +829,19 @@ class _TextStyleProxy implements TextStyle { ...@@ -831,19 +829,19 @@ class _TextStyleProxy implements TextStyle {
@override @override
ui.ParagraphStyle getParagraphStyle({ ui.ParagraphStyle getParagraphStyle({
TextAlign textAlign, TextAlign? textAlign,
TextDirection textDirection, TextDirection? textDirection,
double textScaleFactor = 1.0, double textScaleFactor = 1.0,
String ellipsis, String? ellipsis,
int maxLines, int? maxLines,
ui.TextHeightBehavior textHeightBehavior, ui.TextHeightBehavior? textHeightBehavior,
Locale locale, Locale? locale,
String fontFamily, String? fontFamily,
double fontSize, double? fontSize,
FontWeight fontWeight, FontWeight? fontWeight,
FontStyle fontStyle, FontStyle? fontStyle,
double height, double? height,
StrutStyle strutStyle, StrutStyle? strutStyle,
}) { }) {
throw UnimplementedError(); throw UnimplementedError();
} }
...@@ -854,7 +852,7 @@ class _TextStyleProxy implements TextStyle { ...@@ -854,7 +852,7 @@ class _TextStyleProxy implements TextStyle {
} }
@override @override
TextStyle merge(TextStyle other) { TextStyle merge(TextStyle? other) {
throw UnimplementedError(); throw UnimplementedError();
} }
} }
...@@ -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
@TestOn('!chrome') // entire file needs triage. @TestOn('!chrome') // entire file needs triage.
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
...@@ -19,14 +17,14 @@ final Finder _timePickerDialog = find.byWidgetPredicate((Widget widget) => '${wi ...@@ -19,14 +17,14 @@ final Finder _timePickerDialog = find.byWidgetPredicate((Widget widget) => '${wi
class _TimePickerLauncher extends StatelessWidget { class _TimePickerLauncher extends StatelessWidget {
const _TimePickerLauncher({ const _TimePickerLauncher({
Key key, Key? key,
this.onChanged, required this.onChanged,
this.locale, this.locale,
this.entryMode = TimePickerEntryMode.dial, this.entryMode = TimePickerEntryMode.dial,
}) : super(key: key); }) : super(key: key);
final ValueChanged<TimeOfDay> onChanged; final ValueChanged<TimeOfDay> onChanged;
final Locale locale; final Locale? locale;
final TimePickerEntryMode entryMode; final TimePickerEntryMode entryMode;
@override @override
...@@ -55,7 +53,7 @@ class _TimePickerLauncher extends StatelessWidget { ...@@ -55,7 +53,7 @@ class _TimePickerLauncher extends StatelessWidget {
} }
} }
Future<Offset> startPicker( Future<Offset?> startPicker(
WidgetTester tester, WidgetTester tester,
ValueChanged<TimeOfDay> onChanged, { ValueChanged<TimeOfDay> onChanged, {
TimePickerEntryMode entryMode = TimePickerEntryMode.dial, TimePickerEntryMode entryMode = TimePickerEntryMode.dial,
...@@ -67,7 +65,7 @@ Future<Offset> startPicker( ...@@ -67,7 +65,7 @@ Future<Offset> startPicker(
} }
Future<void> finishPicker(WidgetTester tester) async { Future<void> finishPicker(WidgetTester tester) async {
final MaterialLocalizations materialLocalizations = MaterialLocalizations.of(tester.element(find.byType(ElevatedButton))); final MaterialLocalizations materialLocalizations = MaterialLocalizations.of(tester.element(find.byType(ElevatedButton)))!;
await tester.tap(find.text(materialLocalizations.okButtonLabel)); await tester.tap(find.text(materialLocalizations.okButtonLabel));
await tester.pumpAndSettle(const Duration(seconds: 1)); await tester.pumpAndSettle(const Duration(seconds: 1));
} }
...@@ -84,24 +82,24 @@ void main() { ...@@ -84,24 +82,24 @@ void main() {
void _tests() { void _tests() {
testWidgets('tap-select an hour', (WidgetTester tester) async { testWidgets('tap-select an hour', (WidgetTester tester) async {
TimeOfDay result; late TimeOfDay result;
Offset center = await startPicker(tester, (TimeOfDay time) { result = time; }); Offset center = (await startPicker(tester, (TimeOfDay time) { result = time; }))!;
await tester.tapAt(Offset(center.dx, center.dy - 50.0)); // 12:00 AM await tester.tapAt(Offset(center.dx, center.dy - 50.0)); // 12:00 AM
await finishPicker(tester); await finishPicker(tester);
expect(result, equals(const TimeOfDay(hour: 0, minute: 0))); expect(result, equals(const TimeOfDay(hour: 0, minute: 0)));
center = await startPicker(tester, (TimeOfDay time) { result = time; }); center = (await startPicker(tester, (TimeOfDay time) { result = time; }))!;
await tester.tapAt(Offset(center.dx + 50.0, center.dy)); await tester.tapAt(Offset(center.dx + 50.0, center.dy));
await finishPicker(tester); await finishPicker(tester);
expect(result, equals(const TimeOfDay(hour: 3, minute: 0))); expect(result, equals(const TimeOfDay(hour: 3, minute: 0)));
center = await startPicker(tester, (TimeOfDay time) { result = time; }); center = (await startPicker(tester, (TimeOfDay time) { result = time; }))!;
await tester.tapAt(Offset(center.dx, center.dy + 50.0)); await tester.tapAt(Offset(center.dx, center.dy + 50.0));
await finishPicker(tester); await finishPicker(tester);
expect(result, equals(const TimeOfDay(hour: 6, minute: 0))); expect(result, equals(const TimeOfDay(hour: 6, minute: 0)));
center = await startPicker(tester, (TimeOfDay time) { result = time; }); center = (await startPicker(tester, (TimeOfDay time) { result = time; }))!;
await tester.tapAt(Offset(center.dx, center.dy + 50.0)); await tester.tapAt(Offset(center.dx, center.dy + 50.0));
await tester.tapAt(Offset(center.dx - 50, center.dy)); await tester.tapAt(Offset(center.dx - 50, center.dy));
await finishPicker(tester); await finishPicker(tester);
...@@ -109,9 +107,9 @@ void _tests() { ...@@ -109,9 +107,9 @@ void _tests() {
}); });
testWidgets('drag-select an hour', (WidgetTester tester) async { testWidgets('drag-select an hour', (WidgetTester tester) async {
TimeOfDay result; late TimeOfDay result;
final Offset center = await startPicker(tester, (TimeOfDay time) { result = time; }); final Offset center = (await startPicker(tester, (TimeOfDay time) { result = time; }))!;
final Offset hour0 = Offset(center.dx, center.dy - 50.0); // 12:00 AM final Offset hour0 = Offset(center.dx, center.dy - 50.0); // 12:00 AM
final Offset hour3 = Offset(center.dx + 50.0, center.dy); final Offset hour3 = Offset(center.dx + 50.0, center.dy);
final Offset hour6 = Offset(center.dx, center.dy + 50.0); final Offset hour6 = Offset(center.dx, center.dy + 50.0);
...@@ -148,9 +146,9 @@ void _tests() { ...@@ -148,9 +146,9 @@ void _tests() {
}); });
testWidgets('tap-select switches from hour to minute', (WidgetTester tester) async { testWidgets('tap-select switches from hour to minute', (WidgetTester tester) async {
TimeOfDay result; late TimeOfDay result;
final Offset center = await startPicker(tester, (TimeOfDay time) { result = time; }); final Offset center = (await startPicker(tester, (TimeOfDay time) { result = time; }))!;
final Offset hour6 = Offset(center.dx, center.dy + 50.0); // 6:00 final Offset hour6 = Offset(center.dx, center.dy + 50.0); // 6:00
final Offset min45 = Offset(center.dx - 50.0, center.dy); // 45 mins (or 9:00 hours) final Offset min45 = Offset(center.dx - 50.0, center.dy); // 45 mins (or 9:00 hours)
...@@ -162,9 +160,9 @@ void _tests() { ...@@ -162,9 +160,9 @@ void _tests() {
}); });
testWidgets('drag-select switches from hour to minute', (WidgetTester tester) async { testWidgets('drag-select switches from hour to minute', (WidgetTester tester) async {
TimeOfDay result; late TimeOfDay result;
final Offset center = await startPicker(tester, (TimeOfDay time) { result = time; }); final Offset center = (await startPicker(tester, (TimeOfDay time) { result = time; }))!;
final Offset hour3 = Offset(center.dx + 50.0, center.dy); final Offset hour3 = Offset(center.dx + 50.0, center.dy);
final Offset hour6 = Offset(center.dx, center.dy + 50.0); final Offset hour6 = Offset(center.dx, center.dy + 50.0);
final Offset hour9 = Offset(center.dx - 50.0, center.dy); final Offset hour9 = Offset(center.dx - 50.0, center.dy);
...@@ -181,9 +179,9 @@ void _tests() { ...@@ -181,9 +179,9 @@ void _tests() {
}); });
testWidgets('tap-select rounds down to nearest 5 minute increment', (WidgetTester tester) async { testWidgets('tap-select rounds down to nearest 5 minute increment', (WidgetTester tester) async {
TimeOfDay result; late TimeOfDay result;
final Offset center = await startPicker(tester, (TimeOfDay time) { result = time; }); final Offset center = (await startPicker(tester, (TimeOfDay time) { result = time; }))!;
final Offset hour6 = Offset(center.dx, center.dy + 50.0); // 6:00 final Offset hour6 = Offset(center.dx, center.dy + 50.0); // 6:00
final Offset min46 = Offset(center.dx - 50.0, center.dy - 5); // 46 mins final Offset min46 = Offset(center.dx - 50.0, center.dy - 5); // 46 mins
...@@ -195,9 +193,9 @@ void _tests() { ...@@ -195,9 +193,9 @@ void _tests() {
}); });
testWidgets('tap-select rounds up to nearest 5 minute increment', (WidgetTester tester) async { testWidgets('tap-select rounds up to nearest 5 minute increment', (WidgetTester tester) async {
TimeOfDay result; late TimeOfDay result;
final Offset center = await startPicker(tester, (TimeOfDay time) { result = time; }); final Offset center = (await startPicker(tester, (TimeOfDay time) { result = time; }))!;
final Offset hour6 = Offset(center.dx, center.dy + 50.0); // 6:00 final Offset hour6 = Offset(center.dx, center.dy + 50.0); // 6:00
final Offset min48 = Offset(center.dx - 50.0, center.dy - 15); // 48 mins final Offset min48 = Offset(center.dx - 50.0, center.dy - 15); // 48 mins
...@@ -211,25 +209,25 @@ void _tests() { ...@@ -211,25 +209,25 @@ void _tests() {
group('haptic feedback', () { group('haptic feedback', () {
const Duration kFastFeedbackInterval = Duration(milliseconds: 10); const Duration kFastFeedbackInterval = Duration(milliseconds: 10);
const Duration kSlowFeedbackInterval = Duration(milliseconds: 200); const Duration kSlowFeedbackInterval = Duration(milliseconds: 200);
FeedbackTester feedback; late FeedbackTester feedback;
setUp(() { setUp(() {
feedback = FeedbackTester(); feedback = FeedbackTester();
}); });
tearDown(() { tearDown(() {
feedback?.dispose(); feedback.dispose();
}); });
testWidgets('tap-select vibrates once', (WidgetTester tester) async { testWidgets('tap-select vibrates once', (WidgetTester tester) async {
final Offset center = await startPicker(tester, (TimeOfDay time) { }); final Offset center = (await startPicker(tester, (TimeOfDay time) { }))!;
await tester.tapAt(Offset(center.dx, center.dy - 50.0)); await tester.tapAt(Offset(center.dx, center.dy - 50.0));
await finishPicker(tester); await finishPicker(tester);
expect(feedback.hapticCount, 1); expect(feedback.hapticCount, 1);
}); });
testWidgets('quick successive tap-selects vibrate once', (WidgetTester tester) async { testWidgets('quick successive tap-selects vibrate once', (WidgetTester tester) async {
final Offset center = await startPicker(tester, (TimeOfDay time) { }); final Offset center = (await startPicker(tester, (TimeOfDay time) { }))!;
await tester.tapAt(Offset(center.dx, center.dy - 50.0)); await tester.tapAt(Offset(center.dx, center.dy - 50.0));
await tester.pump(kFastFeedbackInterval); await tester.pump(kFastFeedbackInterval);
await tester.tapAt(Offset(center.dx, center.dy + 50.0)); await tester.tapAt(Offset(center.dx, center.dy + 50.0));
...@@ -238,7 +236,7 @@ void _tests() { ...@@ -238,7 +236,7 @@ void _tests() {
}); });
testWidgets('slow successive tap-selects vibrate once per tap', (WidgetTester tester) async { testWidgets('slow successive tap-selects vibrate once per tap', (WidgetTester tester) async {
final Offset center = await startPicker(tester, (TimeOfDay time) { }); final Offset center = (await startPicker(tester, (TimeOfDay time) { }))!;
await tester.tapAt(Offset(center.dx, center.dy - 50.0)); await tester.tapAt(Offset(center.dx, center.dy - 50.0));
await tester.pump(kSlowFeedbackInterval); await tester.pump(kSlowFeedbackInterval);
await tester.tapAt(Offset(center.dx, center.dy + 50.0)); await tester.tapAt(Offset(center.dx, center.dy + 50.0));
...@@ -249,7 +247,7 @@ void _tests() { ...@@ -249,7 +247,7 @@ void _tests() {
}); });
testWidgets('drag-select vibrates once', (WidgetTester tester) async { testWidgets('drag-select vibrates once', (WidgetTester tester) async {
final Offset center = await startPicker(tester, (TimeOfDay time) { }); final Offset center = (await startPicker(tester, (TimeOfDay time) { }))!;
final Offset hour0 = Offset(center.dx, center.dy - 50.0); final Offset hour0 = Offset(center.dx, center.dy - 50.0);
final Offset hour3 = Offset(center.dx + 50.0, center.dy); final Offset hour3 = Offset(center.dx + 50.0, center.dy);
...@@ -261,7 +259,7 @@ void _tests() { ...@@ -261,7 +259,7 @@ void _tests() {
}); });
testWidgets('quick drag-select vibrates once', (WidgetTester tester) async { testWidgets('quick drag-select vibrates once', (WidgetTester tester) async {
final Offset center = await startPicker(tester, (TimeOfDay time) { }); final Offset center = (await startPicker(tester, (TimeOfDay time) { }))!;
final Offset hour0 = Offset(center.dx, center.dy - 50.0); final Offset hour0 = Offset(center.dx, center.dy - 50.0);
final Offset hour3 = Offset(center.dx + 50.0, center.dy); final Offset hour3 = Offset(center.dx + 50.0, center.dy);
...@@ -277,7 +275,7 @@ void _tests() { ...@@ -277,7 +275,7 @@ void _tests() {
}); });
testWidgets('slow drag-select vibrates once', (WidgetTester tester) async { testWidgets('slow drag-select vibrates once', (WidgetTester tester) async {
final Offset center = await startPicker(tester, (TimeOfDay time) { }); final Offset center = (await startPicker(tester, (TimeOfDay time) { }))!;
final Offset hour0 = Offset(center.dx, center.dy - 50.0); final Offset hour0 = Offset(center.dx, center.dy - 50.0);
final Offset hour3 = Offset(center.dx + 50.0, center.dy); final Offset hour3 = Offset(center.dx + 50.0, center.dy);
...@@ -403,12 +401,12 @@ void _tests() { ...@@ -403,12 +401,12 @@ void _tests() {
testWidgets('can increment and decrement hours', (WidgetTester tester) async { testWidgets('can increment and decrement hours', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
Future<void> actAndExpect({ String initialValue, SemanticsAction action, String finalValue }) async { Future<void> actAndExpect({ required String initialValue, required SemanticsAction action, required String finalValue }) async {
final SemanticsNode elevenHours = semantics.nodesWith( final SemanticsNode elevenHours = semantics.nodesWith(
value: 'Select hours $initialValue', value: 'Select hours $initialValue',
ancestor: tester.renderObject(_hourControl).debugSemantics, ancestor: tester.renderObject(_hourControl).debugSemantics,
).single; ).single;
tester.binding.pipelineOwner.semanticsOwner.performAction(elevenHours.id, action); tester.binding.pipelineOwner.semanticsOwner!.performAction(elevenHours.id, action);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect( expect(
find.descendant(of: _hourControl, matching: find.text(finalValue)), find.descendant(of: _hourControl, matching: find.text(finalValue)),
...@@ -430,7 +428,7 @@ void _tests() { ...@@ -430,7 +428,7 @@ void _tests() {
); );
// Ensure we preserve day period as we roll over. // Ensure we preserve day period as we roll over.
final dynamic pickerState = tester.state(_timePickerDialog); final dynamic pickerState = tester.state(_timePickerDialog); // ignore: unnecessary_nullable_for_final_variable_declarations
expect(pickerState.selectedTime, const TimeOfDay(hour: 1, minute: 0)); expect(pickerState.selectedTime, const TimeOfDay(hour: 1, minute: 0));
await actAndExpect( await actAndExpect(
...@@ -469,12 +467,12 @@ void _tests() { ...@@ -469,12 +467,12 @@ void _tests() {
testWidgets('can increment and decrement minutes', (WidgetTester tester) async { testWidgets('can increment and decrement minutes', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
Future<void> actAndExpect({ String initialValue, SemanticsAction action, String finalValue }) async { Future<void> actAndExpect({ required String initialValue, required SemanticsAction action, required String finalValue }) async {
final SemanticsNode elevenHours = semantics.nodesWith( final SemanticsNode elevenHours = semantics.nodesWith(
value: 'Select minutes $initialValue', value: 'Select minutes $initialValue',
ancestor: tester.renderObject(_minuteControl).debugSemantics, ancestor: tester.renderObject(_minuteControl).debugSemantics,
).single; ).single;
tester.binding.pipelineOwner.semanticsOwner.performAction(elevenHours.id, action); tester.binding.pipelineOwner.semanticsOwner!.performAction(elevenHours.id, action);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect( expect(
find.descendant(of: _minuteControl, matching: find.text(finalValue)), find.descendant(of: _minuteControl, matching: find.text(finalValue)),
...@@ -495,7 +493,7 @@ void _tests() { ...@@ -495,7 +493,7 @@ void _tests() {
); );
// Ensure we preserve hour period as we roll over. // Ensure we preserve hour period as we roll over.
final dynamic pickerState = tester.state(_timePickerDialog); final dynamic pickerState = tester.state(_timePickerDialog); // ignore: unnecessary_nullable_for_final_variable_declarations
expect(pickerState.selectedTime, const TimeOfDay(hour: 11, minute: 0)); expect(pickerState.selectedTime, const TimeOfDay(hour: 11, minute: 0));
await actAndExpect( await actAndExpect(
...@@ -554,10 +552,10 @@ void _tests() { ...@@ -554,10 +552,10 @@ void _tests() {
showTimePicker( showTimePicker(
context: context, context: context,
initialTime: const TimeOfDay(hour: 7, minute: 0), initialTime: const TimeOfDay(hour: 7, minute: 0),
builder: (BuildContext context, Widget child) { builder: (BuildContext context, Widget? child) {
return Directionality( return Directionality(
textDirection: textDirection, textDirection: textDirection,
child: child, child: child!,
); );
}, },
); );
...@@ -705,10 +703,10 @@ void _tests() { ...@@ -705,10 +703,10 @@ void _tests() {
showTimePicker( showTimePicker(
context: context, context: context,
initialTime: const TimeOfDay(hour: 7, minute: 0), initialTime: const TimeOfDay(hour: 7, minute: 0),
builder: (BuildContext context, Widget child) { builder: (BuildContext context, Widget? child) {
return Directionality( return Directionality(
textDirection: textDirection, textDirection: textDirection,
child: child, child: child!,
); );
}, },
); );
...@@ -795,7 +793,7 @@ void _testsInput() { ...@@ -795,7 +793,7 @@ void _testsInput() {
}); });
testWidgets('Initial time is the default', (WidgetTester tester) async { testWidgets('Initial time is the default', (WidgetTester tester) async {
TimeOfDay result; late TimeOfDay result;
await startPicker(tester, (TimeOfDay time) { result = time; }, entryMode: TimePickerEntryMode.input); await startPicker(tester, (TimeOfDay time) { result = time; }, entryMode: TimePickerEntryMode.input);
await finishPicker(tester); await finishPicker(tester);
expect(result, equals(const TimeOfDay(hour: 7, minute: 0))); expect(result, equals(const TimeOfDay(hour: 7, minute: 0)));
...@@ -899,7 +897,7 @@ void _testsInput() { ...@@ -899,7 +897,7 @@ void _testsInput() {
}); });
testWidgets('Entered text returns time', (WidgetTester tester) async { testWidgets('Entered text returns time', (WidgetTester tester) async {
TimeOfDay result; late TimeOfDay result;
await startPicker(tester, (TimeOfDay time) { result = time; }, entryMode: TimePickerEntryMode.input); await startPicker(tester, (TimeOfDay time) { result = time; }, entryMode: TimePickerEntryMode.input);
await tester.enterText(find.byType(TextField).first, '9'); await tester.enterText(find.byType(TextField).first, '9');
await tester.enterText(find.byType(TextField).last, '12'); await tester.enterText(find.byType(TextField).last, '12');
...@@ -908,7 +906,7 @@ void _testsInput() { ...@@ -908,7 +906,7 @@ void _testsInput() {
}); });
testWidgets('Toggle to dial mode keeps selected time', (WidgetTester tester) async { testWidgets('Toggle to dial mode keeps selected time', (WidgetTester tester) async {
TimeOfDay result; late TimeOfDay result;
await startPicker(tester, (TimeOfDay time) { result = time; }, entryMode: TimePickerEntryMode.input); await startPicker(tester, (TimeOfDay time) { result = time; }, entryMode: TimePickerEntryMode.input);
await tester.enterText(find.byType(TextField).first, '8'); await tester.enterText(find.byType(TextField).first, '8');
await tester.enterText(find.byType(TextField).last, '15'); await tester.enterText(find.byType(TextField).last, '15');
...@@ -918,7 +916,7 @@ void _testsInput() { ...@@ -918,7 +916,7 @@ void _testsInput() {
}); });
testWidgets('Invalid text prevents dismissing', (WidgetTester tester) async { testWidgets('Invalid text prevents dismissing', (WidgetTester tester) async {
TimeOfDay result; TimeOfDay? result;
await startPicker(tester, (TimeOfDay time) { result = time; }, entryMode: TimePickerEntryMode.input); await startPicker(tester, (TimeOfDay time) { result = time; }, entryMode: TimePickerEntryMode.input);
// Invalid hour. // Invalid hour.
...@@ -959,7 +957,7 @@ class PickerObserver extends NavigatorObserver { ...@@ -959,7 +957,7 @@ class PickerObserver extends NavigatorObserver {
int pickerCount = 0; int pickerCount = 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')) {
pickerCount++; pickerCount++;
} }
...@@ -973,7 +971,7 @@ Future<void> mediaQueryBoilerplate( ...@@ -973,7 +971,7 @@ Future<void> mediaQueryBoilerplate(
TimeOfDay initialTime = const TimeOfDay(hour: 7, minute: 0), TimeOfDay initialTime = const TimeOfDay(hour: 7, minute: 0),
double textScaleFactor = 1.0, double textScaleFactor = 1.0,
TimePickerEntryMode entryMode = TimePickerEntryMode.dial, TimePickerEntryMode entryMode = TimePickerEntryMode.dial,
String helpText, String? helpText,
bool accessibleNavigation = false, bool accessibleNavigation = false,
}) async { }) async {
await tester.pumpWidget( await tester.pumpWidget(
......
...@@ -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/painting.dart'; import 'package:flutter/painting.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
...@@ -117,7 +115,7 @@ void main() { ...@@ -117,7 +115,7 @@ void main() {
final RenderParagraph hourText = _textRenderParagraph(tester, '7'); final RenderParagraph hourText = _textRenderParagraph(tester, '7');
expect( expect(
hourText.text.style, hourText.text.style,
Typography.material2014().englishLike.headline2 Typography.material2014().englishLike.headline2!
.merge(Typography.material2014().black.headline2) .merge(Typography.material2014().black.headline2)
.copyWith(color: defaultTheme.colorScheme.primary), .copyWith(color: defaultTheme.colorScheme.primary),
); );
...@@ -125,7 +123,7 @@ void main() { ...@@ -125,7 +123,7 @@ void main() {
final RenderParagraph minuteText = _textRenderParagraph(tester, '15'); final RenderParagraph minuteText = _textRenderParagraph(tester, '15');
expect( expect(
minuteText.text.style, minuteText.text.style,
Typography.material2014().englishLike.headline2 Typography.material2014().englishLike.headline2!
.merge(Typography.material2014().black.headline2) .merge(Typography.material2014().black.headline2)
.copyWith(color: defaultTheme.colorScheme.onSurface), .copyWith(color: defaultTheme.colorScheme.onSurface),
); );
...@@ -133,7 +131,7 @@ void main() { ...@@ -133,7 +131,7 @@ void main() {
final RenderParagraph amText = _textRenderParagraph(tester, 'AM'); final RenderParagraph amText = _textRenderParagraph(tester, 'AM');
expect( expect(
amText.text.style, amText.text.style,
Typography.material2014().englishLike.subtitle1 Typography.material2014().englishLike.subtitle1!
.merge(Typography.material2014().black.subtitle1) .merge(Typography.material2014().black.subtitle1)
.copyWith(color: defaultTheme.colorScheme.primary), .copyWith(color: defaultTheme.colorScheme.primary),
); );
...@@ -141,7 +139,7 @@ void main() { ...@@ -141,7 +139,7 @@ void main() {
final RenderParagraph pmText = _textRenderParagraph(tester, 'PM'); final RenderParagraph pmText = _textRenderParagraph(tester, 'PM');
expect( expect(
pmText.text.style, pmText.text.style,
Typography.material2014().englishLike.subtitle1 Typography.material2014().englishLike.subtitle1!
.merge(Typography.material2014().black.subtitle1) .merge(Typography.material2014().black.subtitle1)
.copyWith(color: defaultTheme.colorScheme.onSurface.withOpacity(0.6)), .copyWith(color: defaultTheme.colorScheme.onSurface.withOpacity(0.6)),
); );
...@@ -149,7 +147,7 @@ void main() { ...@@ -149,7 +147,7 @@ void main() {
final RenderParagraph helperText = _textRenderParagraph(tester, 'SELECT TIME'); final RenderParagraph helperText = _textRenderParagraph(tester, 'SELECT TIME');
expect( expect(
helperText.text.style, helperText.text.style,
Typography.material2014().englishLike.overline Typography.material2014().englishLike.overline!
.merge(Typography.material2014().black.overline), .merge(Typography.material2014().black.overline),
); );
...@@ -158,14 +156,14 @@ void main() { ...@@ -158,14 +156,14 @@ void main() {
final List<dynamic> primaryLabels = dialPainter.primaryLabels as List<dynamic>; final List<dynamic> primaryLabels = dialPainter.primaryLabels as List<dynamic>;
expect( expect(
primaryLabels.first.painter.text.style, primaryLabels.first.painter.text.style,
Typography.material2014().englishLike.bodyText1 Typography.material2014().englishLike.bodyText1!
.merge(Typography.material2014().black.bodyText1) .merge(Typography.material2014().black.bodyText1)
.copyWith(color: defaultTheme.colorScheme.onSurface), .copyWith(color: defaultTheme.colorScheme.onSurface),
); );
final List<dynamic> secondaryLabels = dialPainter.secondaryLabels as List<dynamic>; final List<dynamic> secondaryLabels = dialPainter.secondaryLabels as List<dynamic>;
expect( expect(
secondaryLabels.first.painter.text.style, secondaryLabels.first.painter.text.style,
Typography.material2014().englishLike.bodyText1 Typography.material2014().englishLike.bodyText1!
.merge(Typography.material2014().white.bodyText1) .merge(Typography.material2014().white.bodyText1)
.copyWith(color: defaultTheme.colorScheme.onPrimary), .copyWith(color: defaultTheme.colorScheme.onPrimary),
); );
...@@ -217,7 +215,7 @@ void main() { ...@@ -217,7 +215,7 @@ void main() {
await tester.tap(find.text('X')); await tester.tap(find.text('X'));
await tester.pumpAndSettle(const Duration(seconds: 1)); await tester.pumpAndSettle(const Duration(seconds: 1));
final InputDecoration hourDecoration = _textField(tester, '7').decoration; final InputDecoration hourDecoration = _textField(tester, '7').decoration!;
expect(hourDecoration.filled, true); expect(hourDecoration.filled, true);
expect(hourDecoration.fillColor, defaultTheme.colorScheme.onSurface.withOpacity(0.12)); expect(hourDecoration.fillColor, defaultTheme.colorScheme.onSurface.withOpacity(0.12));
expect(hourDecoration.enabledBorder, const OutlineInputBorder(borderSide: BorderSide(color: Colors.transparent))); expect(hourDecoration.enabledBorder, const OutlineInputBorder(borderSide: BorderSide(color: Colors.transparent)));
...@@ -226,8 +224,8 @@ void main() { ...@@ -226,8 +224,8 @@ void main() {
expect(hourDecoration.focusedErrorBorder, OutlineInputBorder(borderSide: BorderSide(color: defaultTheme.colorScheme.error, width: 2))); expect(hourDecoration.focusedErrorBorder, OutlineInputBorder(borderSide: BorderSide(color: defaultTheme.colorScheme.error, width: 2)));
expect( expect(
hourDecoration.hintStyle, hourDecoration.hintStyle,
Typography.material2014().englishLike.headline2 Typography.material2014().englishLike.headline2!
.merge(defaultTheme.textTheme.headline2.copyWith(color: defaultTheme.colorScheme.onSurface.withOpacity(0.36))), .merge(defaultTheme.textTheme.headline2!.copyWith(color: defaultTheme.colorScheme.onSurface.withOpacity(0.36))),
); );
}); });
...@@ -246,14 +244,14 @@ void main() { ...@@ -246,14 +244,14 @@ void main() {
expect( expect(
dial, dial,
paints paints
..circle(color: Color(timePickerTheme.dialBackgroundColor.value)) // Dial background color. ..circle(color: Color(timePickerTheme.dialBackgroundColor!.value)) // Dial background color.
..circle(color: Color(timePickerTheme.dialHandColor.value)), // Dial hand color. ..circle(color: Color(timePickerTheme.dialHandColor!.value)), // Dial hand color.
); );
final RenderParagraph hourText = _textRenderParagraph(tester, '7'); final RenderParagraph hourText = _textRenderParagraph(tester, '7');
expect( expect(
hourText.text.style, hourText.text.style,
Typography.material2014().englishLike.bodyText2 Typography.material2014().englishLike.bodyText2!
.merge(Typography.material2014().black.bodyText2) .merge(Typography.material2014().black.bodyText2)
.merge(timePickerTheme.hourMinuteTextStyle) .merge(timePickerTheme.hourMinuteTextStyle)
.copyWith(color: _selectedColor), .copyWith(color: _selectedColor),
...@@ -262,7 +260,7 @@ void main() { ...@@ -262,7 +260,7 @@ void main() {
final RenderParagraph minuteText = _textRenderParagraph(tester, '15'); final RenderParagraph minuteText = _textRenderParagraph(tester, '15');
expect( expect(
minuteText.text.style, minuteText.text.style,
Typography.material2014().englishLike.bodyText2 Typography.material2014().englishLike.bodyText2!
.merge(Typography.material2014().black.bodyText2) .merge(Typography.material2014().black.bodyText2)
.merge(timePickerTheme.hourMinuteTextStyle) .merge(timePickerTheme.hourMinuteTextStyle)
.copyWith(color: _unselectedColor), .copyWith(color: _unselectedColor),
...@@ -271,7 +269,7 @@ void main() { ...@@ -271,7 +269,7 @@ void main() {
final RenderParagraph amText = _textRenderParagraph(tester, 'AM'); final RenderParagraph amText = _textRenderParagraph(tester, 'AM');
expect( expect(
amText.text.style, amText.text.style,
Typography.material2014().englishLike.subtitle1 Typography.material2014().englishLike.subtitle1!
.merge(Typography.material2014().black.subtitle1) .merge(Typography.material2014().black.subtitle1)
.merge(timePickerTheme.dayPeriodTextStyle) .merge(timePickerTheme.dayPeriodTextStyle)
.copyWith(color: _selectedColor), .copyWith(color: _selectedColor),
...@@ -280,7 +278,7 @@ void main() { ...@@ -280,7 +278,7 @@ void main() {
final RenderParagraph pmText = _textRenderParagraph(tester, 'PM'); final RenderParagraph pmText = _textRenderParagraph(tester, 'PM');
expect( expect(
pmText.text.style, pmText.text.style,
Typography.material2014().englishLike.subtitle1 Typography.material2014().englishLike.subtitle1!
.merge(Typography.material2014().black.subtitle1) .merge(Typography.material2014().black.subtitle1)
.merge(timePickerTheme.dayPeriodTextStyle) .merge(timePickerTheme.dayPeriodTextStyle)
.copyWith(color: _unselectedColor), .copyWith(color: _unselectedColor),
...@@ -289,7 +287,7 @@ void main() { ...@@ -289,7 +287,7 @@ void main() {
final RenderParagraph helperText = _textRenderParagraph(tester, 'SELECT TIME'); final RenderParagraph helperText = _textRenderParagraph(tester, 'SELECT TIME');
expect( expect(
helperText.text.style, helperText.text.style,
Typography.material2014().englishLike.bodyText2 Typography.material2014().englishLike.bodyText2!
.merge(Typography.material2014().black.bodyText2) .merge(Typography.material2014().black.bodyText2)
.merge(timePickerTheme.helpTextStyle), .merge(timePickerTheme.helpTextStyle),
); );
...@@ -299,14 +297,14 @@ void main() { ...@@ -299,14 +297,14 @@ void main() {
final List<dynamic> primaryLabels = dialPainter.primaryLabels as List<dynamic>; final List<dynamic> primaryLabels = dialPainter.primaryLabels as List<dynamic>;
expect( expect(
primaryLabels.first.painter.text.style, primaryLabels.first.painter.text.style,
Typography.material2014().englishLike.bodyText1 Typography.material2014().englishLike.bodyText1!
.merge(Typography.material2014().black.bodyText1) .merge(Typography.material2014().black.bodyText1)
.copyWith(color: _unselectedColor), .copyWith(color: _unselectedColor),
); );
final List<dynamic> secondaryLabels = dialPainter.secondaryLabels as List<dynamic>; final List<dynamic> secondaryLabels = dialPainter.secondaryLabels as List<dynamic>;
expect( expect(
secondaryLabels.first.painter.text.style, secondaryLabels.first.painter.text.style,
Typography.material2014().englishLike.bodyText1 Typography.material2014().englishLike.bodyText1!
.merge(Typography.material2014().white.bodyText1) .merge(Typography.material2014().white.bodyText1)
.copyWith(color: _selectedColor), .copyWith(color: _selectedColor),
); );
...@@ -328,13 +326,13 @@ void main() { ...@@ -328,13 +326,13 @@ void main() {
final Material dayPeriodMaterial = _dayPeriodMaterial(tester); final Material dayPeriodMaterial = _dayPeriodMaterial(tester);
expect( expect(
dayPeriodMaterial.shape, dayPeriodMaterial.shape,
timePickerTheme.dayPeriodShape.copyWith(side: timePickerTheme.dayPeriodBorderSide), timePickerTheme.dayPeriodShape!.copyWith(side: timePickerTheme.dayPeriodBorderSide),
); );
final Container dayPeriodDivider = _dayPeriodDivider(tester); final Container dayPeriodDivider = _dayPeriodDivider(tester);
expect( expect(
dayPeriodDivider.decoration, dayPeriodDivider.decoration,
BoxDecoration(border: Border(left: timePickerTheme.dayPeriodBorderSide)), BoxDecoration(border: Border(left: timePickerTheme.dayPeriodBorderSide!)),
); );
final IconButton entryModeIconButton = _entryModeIconButton(tester); final IconButton entryModeIconButton = _entryModeIconButton(tester);
...@@ -351,14 +349,14 @@ void main() { ...@@ -351,14 +349,14 @@ void main() {
await tester.tap(find.text('X')); await tester.tap(find.text('X'));
await tester.pumpAndSettle(const Duration(seconds: 1)); await tester.pumpAndSettle(const Duration(seconds: 1));
final InputDecoration hourDecoration = _textField(tester, '7').decoration; final InputDecoration hourDecoration = _textField(tester, '7').decoration!;
expect(hourDecoration.filled, timePickerTheme.inputDecorationTheme.filled); expect(hourDecoration.filled, timePickerTheme.inputDecorationTheme!.filled);
expect(hourDecoration.fillColor, timePickerTheme.inputDecorationTheme.fillColor); expect(hourDecoration.fillColor, timePickerTheme.inputDecorationTheme!.fillColor);
expect(hourDecoration.enabledBorder, timePickerTheme.inputDecorationTheme.enabledBorder); expect(hourDecoration.enabledBorder, timePickerTheme.inputDecorationTheme!.enabledBorder);
expect(hourDecoration.errorBorder, timePickerTheme.inputDecorationTheme.errorBorder); expect(hourDecoration.errorBorder, timePickerTheme.inputDecorationTheme!.errorBorder);
expect(hourDecoration.focusedBorder, timePickerTheme.inputDecorationTheme.focusedBorder); expect(hourDecoration.focusedBorder, timePickerTheme.inputDecorationTheme!.focusedBorder);
expect(hourDecoration.focusedErrorBorder, timePickerTheme.inputDecorationTheme.focusedErrorBorder); expect(hourDecoration.focusedErrorBorder, timePickerTheme.inputDecorationTheme!.focusedErrorBorder);
expect(hourDecoration.hintStyle, timePickerTheme.inputDecorationTheme.hintStyle); expect(hourDecoration.hintStyle, timePickerTheme.inputDecorationTheme!.hintStyle);
}); });
testWidgets('Time picker uses values from TimePickerThemeData without InputDecorationTheme - input mode', (WidgetTester tester) async { testWidgets('Time picker uses values from TimePickerThemeData without InputDecorationTheme - input mode', (WidgetTester tester) async {
...@@ -368,13 +366,13 @@ void main() { ...@@ -368,13 +366,13 @@ void main() {
await tester.tap(find.text('X')); await tester.tap(find.text('X'));
await tester.pumpAndSettle(const Duration(seconds: 1)); await tester.pumpAndSettle(const Duration(seconds: 1));
final InputDecoration hourDecoration = _textField(tester, '7').decoration; final InputDecoration hourDecoration = _textField(tester, '7').decoration!;
expect(hourDecoration.fillColor, timePickerTheme.hourMinuteColor); expect(hourDecoration.fillColor, timePickerTheme.hourMinuteColor);
}); });
} }
final Color _selectedColor = Colors.green[100]; final Color _selectedColor = Colors.green[100]!;
final Color _unselectedColor = Colors.green[200]; final Color _unselectedColor = Colors.green[200]!;
TimePickerThemeData _timePickerTheme({bool includeInputDecoration = false}) { TimePickerThemeData _timePickerTheme({bool includeInputDecoration = false}) {
Color getColor(Set<MaterialState> states) { Color getColor(Set<MaterialState> states) {
...@@ -412,12 +410,12 @@ TimePickerThemeData _timePickerTheme({bool includeInputDecoration = false}) { ...@@ -412,12 +410,12 @@ TimePickerThemeData _timePickerTheme({bool includeInputDecoration = false}) {
class _TimePickerLauncher extends StatelessWidget { class _TimePickerLauncher extends StatelessWidget {
const _TimePickerLauncher({ const _TimePickerLauncher({
Key key, Key? key,
this.themeData, this.themeData,
this.entryMode = TimePickerEntryMode.dial, this.entryMode = TimePickerEntryMode.dial,
}) : super(key: key); }) : super(key: key);
final ThemeData themeData; final ThemeData? themeData;
final TimePickerEntryMode entryMode; final TimePickerEntryMode entryMode;
@override @override
...@@ -471,7 +469,7 @@ IconButton _entryModeIconButton(WidgetTester tester) { ...@@ -471,7 +469,7 @@ IconButton _entryModeIconButton(WidgetTester tester) {
} }
RenderParagraph _textRenderParagraph(WidgetTester tester, String text) { RenderParagraph _textRenderParagraph(WidgetTester tester, String text) {
return tester.element<StatelessElement>(find.text(text).first).renderObject as RenderParagraph; return tester.element<StatelessElement>(find.text(text).first).renderObject! as RenderParagraph;
} }
final Finder findDialPaint = find.descendant( final Finder findDialPaint = find.descendant(
......
...@@ -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