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

[NNBD] Migrate some Cupertino tests (#67086)

parent 2cdf2f00
...@@ -344,7 +344,7 @@ class CupertinoNavigationBar extends StatefulWidget implements ObstructingPrefer ...@@ -344,7 +344,7 @@ class CupertinoNavigationBar extends StatefulWidget implements ObstructingPrefer
/// ///
/// If a border is null, the navigation bar will not display a border. /// If a border is null, the navigation bar will not display a border.
/// {@endtemplate} /// {@endtemplate}
final Border border; final Border? border;
/// {@template flutter.cupertino.navBar.actionsForegroundColor} /// {@template flutter.cupertino.navBar.actionsForegroundColor}
/// Default color used for text and icons of the [leading] and [trailing] /// Default color used for text and icons of the [leading] and [trailing]
...@@ -652,7 +652,7 @@ class CupertinoSliverNavigationBar extends StatefulWidget { ...@@ -652,7 +652,7 @@ class CupertinoSliverNavigationBar extends StatefulWidget {
final EdgeInsetsDirectional? padding; final EdgeInsetsDirectional? padding;
/// {@macro flutter.cupertino.navBar.border} /// {@macro flutter.cupertino.navBar.border}
final Border border; final Border? border;
/// {@macro flutter.cupertino.navBar.actionsForegroundColor} /// {@macro flutter.cupertino.navBar.actionsForegroundColor}
/// ///
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
...@@ -63,7 +61,7 @@ void main() { ...@@ -63,7 +61,7 @@ void main() {
final DefaultTextStyle widget = tester.widget(find.widgetWithText(DefaultTextStyle, 'Ok')); final DefaultTextStyle widget = tester.widget(find.widgetWithText(DefaultTextStyle, 'Ok'));
expect(widget.style.color, const CupertinoDynamicColor.withBrightnessAndContrast( expect(widget.style!.color, const CupertinoDynamicColor.withBrightnessAndContrast(
color: Color.fromARGB(255, 255, 59, 48), color: Color.fromARGB(255, 255, 59, 48),
darkColor: Color.fromARGB(255, 255, 69, 58), darkColor: Color.fromARGB(255, 255, 69, 58),
highContrastColor: Color.fromARGB(255, 215, 0, 21), highContrastColor: Color.fromARGB(255, 215, 0, 21),
...@@ -78,7 +76,7 @@ void main() { ...@@ -78,7 +76,7 @@ void main() {
); );
Brightness brightness = Brightness.light; Brightness brightness = Brightness.light;
StateSetter stateSetter; late StateSetter stateSetter;
TextStyle actionTextStyle(String text) { TextStyle actionTextStyle(String text) {
return tester.widget<DefaultTextStyle>( return tester.widget<DefaultTextStyle>(
...@@ -86,7 +84,7 @@ void main() { ...@@ -86,7 +84,7 @@ void main() {
of: find.widgetWithText(CupertinoActionSheetAction, text), of: find.widgetWithText(CupertinoActionSheetAction, text),
matching: find.byType(DefaultTextStyle), matching: find.byType(DefaultTextStyle),
), ),
).style; ).style!;
} }
await tester.pumpWidget( await tester.pumpWidget(
...@@ -115,7 +113,7 @@ void main() { ...@@ -115,7 +113,7 @@ void main() {
await tester.pump(); await tester.pump();
expect( expect(
actionTextStyle('action').color.value, actionTextStyle('action').color!.value,
const Color.fromARGB(255, 0, 122, 255).value, const Color.fromARGB(255, 0, 122, 255).value,
); );
...@@ -123,7 +121,7 @@ void main() { ...@@ -123,7 +121,7 @@ void main() {
await tester.pump(); await tester.pump();
expect( expect(
actionTextStyle('action').color.value, actionTextStyle('action').color!.value,
const Color.fromARGB(255, 10, 132, 255).value, const Color.fromARGB(255, 10, 132, 255).value,
); );
}); });
...@@ -141,7 +139,7 @@ void main() { ...@@ -141,7 +139,7 @@ void main() {
final DefaultTextStyle widget = tester.widget(find.widgetWithText(DefaultTextStyle, 'Ok')); final DefaultTextStyle widget = tester.widget(find.widgetWithText(DefaultTextStyle, 'Ok'));
expect(widget.style.fontWeight, equals(FontWeight.w600)); expect(widget.style!.fontWeight, equals(FontWeight.w600));
}); });
testWidgets('Action sheet text styles are correct when both title and message are included', (WidgetTester tester) async { testWidgets('Action sheet text styles are correct when both title and message are included', (WidgetTester tester) async {
...@@ -162,8 +160,8 @@ void main() { ...@@ -162,8 +160,8 @@ void main() {
final DefaultTextStyle messageStyle = tester.firstWidget(find.widgetWithText(DefaultTextStyle, final DefaultTextStyle messageStyle = tester.firstWidget(find.widgetWithText(DefaultTextStyle,
'An action sheet')); 'An action sheet'));
expect(titleStyle.style.fontWeight, FontWeight.w600); expect(titleStyle.style!.fontWeight, FontWeight.w600);
expect(messageStyle.style.fontWeight, FontWeight.w400); expect(messageStyle.style!.fontWeight, FontWeight.w400);
}); });
testWidgets('Action sheet text styles are correct when title but no message is included', (WidgetTester tester) async { testWidgets('Action sheet text styles are correct when title but no message is included', (WidgetTester tester) async {
...@@ -181,7 +179,7 @@ void main() { ...@@ -181,7 +179,7 @@ void main() {
final DefaultTextStyle titleStyle = tester.firstWidget(find.widgetWithText(DefaultTextStyle, final DefaultTextStyle titleStyle = tester.firstWidget(find.widgetWithText(DefaultTextStyle,
'Action Sheet')); 'Action Sheet'));
expect(titleStyle.style.fontWeight, FontWeight.w400); expect(titleStyle.style!.fontWeight, FontWeight.w400);
}); });
testWidgets('Action sheet text styles are correct when message but no title is included', (WidgetTester tester) async { testWidgets('Action sheet text styles are correct when message but no title is included', (WidgetTester tester) async {
...@@ -199,7 +197,7 @@ void main() { ...@@ -199,7 +197,7 @@ void main() {
final DefaultTextStyle messageStyle = tester.firstWidget(find.widgetWithText(DefaultTextStyle, final DefaultTextStyle messageStyle = tester.firstWidget(find.widgetWithText(DefaultTextStyle,
'An action sheet')); 'An action sheet'));
expect(messageStyle.style.fontWeight, FontWeight.w600); expect(messageStyle.style!.fontWeight, FontWeight.w600);
}); });
testWidgets('Content section but no actions', (WidgetTester tester) async { testWidgets('Content section but no actions', (WidgetTester tester) async {
...@@ -285,7 +283,7 @@ void main() { ...@@ -285,7 +283,7 @@ void main() {
createAppWithButtonThatLaunchesActionSheet( createAppWithButtonThatLaunchesActionSheet(
Builder(builder: (BuildContext context) { Builder(builder: (BuildContext context) {
return MediaQuery( return MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: 3.0), data: MediaQuery.of(context)!.copyWith(textScaleFactor: 3.0),
child: CupertinoActionSheet( child: CupertinoActionSheet(
title: const Text('The title'), title: const Text('The title'),
message: const Text('The message.'), message: const Text('The message.'),
...@@ -346,13 +344,13 @@ void main() { ...@@ -346,13 +344,13 @@ void main() {
testWidgets('Content section is scrollable', (WidgetTester tester) async { testWidgets('Content section is scrollable', (WidgetTester tester) async {
final ScrollController messageScrollController = ScrollController(); final ScrollController messageScrollController = ScrollController();
double screenHeight; late double screenHeight;
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesActionSheet( createAppWithButtonThatLaunchesActionSheet(
Builder(builder: (BuildContext context) { Builder(builder: (BuildContext context) {
screenHeight = MediaQuery.of(context).size.height; screenHeight = MediaQuery.of(context)!.size.height;
return MediaQuery( return MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: 3.0), data: MediaQuery.of(context)!.copyWith(textScaleFactor: 3.0),
child: CupertinoActionSheet( child: CupertinoActionSheet(
title: const Text('The title'), title: const Text('The title'),
message: Text('Very long content' * 200), message: Text('Very long content' * 200),
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -14,18 +12,18 @@ void main() { ...@@ -14,18 +12,18 @@ void main() {
testWidgets('Activity indicator animate property works', testWidgets('Activity indicator animate property works',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget(buildCupertinoActivityIndicator()); await tester.pumpWidget(buildCupertinoActivityIndicator());
expect(SchedulerBinding.instance.transientCallbackCount, equals(1)); expect(SchedulerBinding.instance!.transientCallbackCount, equals(1));
await tester.pumpWidget(buildCupertinoActivityIndicator(false)); await tester.pumpWidget(buildCupertinoActivityIndicator(false));
expect(SchedulerBinding.instance.transientCallbackCount, equals(0)); expect(SchedulerBinding.instance!.transientCallbackCount, equals(0));
await tester.pumpWidget(Container()); await tester.pumpWidget(Container());
await tester.pumpWidget(buildCupertinoActivityIndicator(false)); await tester.pumpWidget(buildCupertinoActivityIndicator(false));
expect(SchedulerBinding.instance.transientCallbackCount, equals(0)); expect(SchedulerBinding.instance!.transientCallbackCount, equals(0));
await tester.pumpWidget(buildCupertinoActivityIndicator()); await tester.pumpWidget(buildCupertinoActivityIndicator());
expect(SchedulerBinding.instance.transientCallbackCount, equals(1)); expect(SchedulerBinding.instance!.transientCallbackCount, equals(1));
}); });
testWidgets('Activity indicator dark mode', (WidgetTester tester) async { testWidgets('Activity indicator dark mode', (WidgetTester tester) async {
...@@ -161,7 +159,7 @@ void main() { ...@@ -161,7 +159,7 @@ void main() {
}); });
} }
Widget buildCupertinoActivityIndicator([bool animating]) { Widget buildCupertinoActivityIndicator([bool? animating]) {
return MediaQuery( return MediaQuery(
data: const MediaQueryData(platformBrightness: Brightness.light), data: const MediaQueryData(platformBrightness: Brightness.light),
child: CupertinoActivityIndicator( child: CupertinoActivityIndicator(
......
...@@ -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/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -52,8 +50,8 @@ void main() { ...@@ -52,8 +50,8 @@ void main() {
builder: (BuildContext context) { builder: (BuildContext context) {
return Column( return Column(
children: <Widget>[ children: <Widget>[
Text(CupertinoLocalizations.of(context).selectAllButtonLabel), Text(CupertinoLocalizations.of(context)!.selectAllButtonLabel),
Text(CupertinoLocalizations.of(context).datePickerMediumDate( Text(CupertinoLocalizations.of(context)!.datePickerMediumDate(
DateTime(2018, 10, 4), DateTime(2018, 10, 4),
)), )),
], ],
...@@ -126,7 +124,7 @@ void main() { ...@@ -126,7 +124,7 @@ void main() {
expect(find.text('non-regular page one'), findsNothing); expect(find.text('non-regular page one'), findsNothing);
expect(find.text('regular page one'), findsNothing); expect(find.text('regular page one'), findsNothing);
expect(find.text('regular page two'), findsNothing); expect(find.text('regular page two'), 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);
...@@ -158,7 +156,7 @@ void main() { ...@@ -158,7 +156,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(
...@@ -176,7 +174,7 @@ void main() { ...@@ -176,7 +174,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);
}); });
...@@ -201,7 +199,7 @@ class SimpleRouteInformationParser extends RouteInformationParser<RouteInformati ...@@ -201,7 +199,7 @@ 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, this.onPopPage,
}); });
...@@ -209,14 +207,14 @@ class SimpleNavigatorRouterDelegate extends RouterDelegate<RouteInformation> wit ...@@ -209,14 +207,14 @@ class SimpleNavigatorRouterDelegate extends RouterDelegate<RouteInformation> wit
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; SimpleRouterDelegateBuilder builder;
SimpleNavigatorRouterDelegatePopPage<void> onPopPage; SimpleNavigatorRouterDelegatePopPage<void>? onPopPage;
@override @override
Future<void> setNewRoutePath(RouteInformation configuration) { Future<void> setNewRoutePath(RouteInformation configuration) {
...@@ -225,7 +223,7 @@ class SimpleNavigatorRouterDelegate extends RouterDelegate<RouteInformation> wit ...@@ -225,7 +223,7 @@ class SimpleNavigatorRouterDelegate extends RouterDelegate<RouteInformation> wit
} }
bool _handlePopPage(Route<void> route, void data) { bool _handlePopPage(Route<void> route, void data) {
return onPopPage(route, data, this); return onPopPage!(route, data, this);
} }
@override @override
...@@ -240,7 +238,7 @@ class SimpleNavigatorRouterDelegate extends RouterDelegate<RouteInformation> wit ...@@ -240,7 +238,7 @@ class SimpleNavigatorRouterDelegate extends RouterDelegate<RouteInformation> wit
child: Text('base'), child: Text('base'),
), ),
CupertinoPage<void>( CupertinoPage<void>(
key: ValueKey<String>(routeInformation?.location), key: ValueKey<String?>(routeInformation.location),
child: builder(context, routeInformation), child: builder(context, routeInformation),
) )
], ],
......
...@@ -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:typed_data'; import 'dart:typed_data';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
...@@ -72,13 +70,13 @@ Future<void> main() async { ...@@ -72,13 +70,13 @@ Future<void> main() async {
of: find.text('Tab 1'), of: find.text('Tab 1'),
matching: find.byType(RichText), matching: find.byType(RichText),
)); ));
expect(actualInactive.text.style.color, const Color(0xFF654321)); expect(actualInactive.text.style!.color, const Color(0xFF654321));
final RichText actualActive = tester.widget(find.descendant( final RichText actualActive = tester.widget(find.descendant(
of: find.text('Tab 2'), of: find.text('Tab 2'),
matching: find.byType(RichText), matching: find.byType(RichText),
)); ));
expect(actualActive.text.style.color, const Color(0xFF123456)); expect(actualActive.text.style!.color, const Color(0xFF123456));
}); });
...@@ -138,13 +136,13 @@ Future<void> main() async { ...@@ -138,13 +136,13 @@ Future<void> main() async {
of: find.text('Tab 1'), of: find.text('Tab 1'),
matching: find.byType(RichText), matching: find.byType(RichText),
)); ));
expect(actualInactive.text.style.color.value, 0xFF000002); expect(actualInactive.text.style!.color!.value, 0xFF000002);
RichText actualActive = tester.widget(find.descendant( RichText actualActive = tester.widget(find.descendant(
of: find.text('Tab 2'), of: find.text('Tab 2'),
matching: find.byType(RichText), matching: find.byType(RichText),
)); ));
expect(actualActive.text.style.color.value, 0xFF000000); expect(actualActive.text.style!.color!.value, 0xFF000000);
final RenderDecoratedBox renderDecoratedBox = tester.renderObject(find.descendant( final RenderDecoratedBox renderDecoratedBox = tester.renderObject(find.descendant(
of: find.byType(BackdropFilter), of: find.byType(BackdropFilter),
...@@ -153,7 +151,7 @@ Future<void> main() async { ...@@ -153,7 +151,7 @@ Future<void> main() async {
// Border color is resolved correctly. // Border color is resolved correctly.
final BoxDecoration decoration1 = renderDecoratedBox.decoration as BoxDecoration; final BoxDecoration decoration1 = renderDecoratedBox.decoration as BoxDecoration;
expect(decoration1.border.top.color.value, 0x4C000000); expect(decoration1.border!.top.color.value, 0x4C000000);
// Switch to dark mode. // Switch to dark mode.
await pumpWidgetWithBoilerplate(tester, MediaQuery( await pumpWidgetWithBoilerplate(tester, MediaQuery(
...@@ -179,17 +177,17 @@ Future<void> main() async { ...@@ -179,17 +177,17 @@ Future<void> main() async {
of: find.text('Tab 1'), of: find.text('Tab 1'),
matching: find.byType(RichText), matching: find.byType(RichText),
)); ));
expect(actualInactive.text.style.color.value, 0xFF000003); expect(actualInactive.text.style!.color!.value, 0xFF000003);
actualActive = tester.widget(find.descendant( actualActive = tester.widget(find.descendant(
of: find.text('Tab 2'), of: find.text('Tab 2'),
matching: find.byType(RichText), matching: find.byType(RichText),
)); ));
expect(actualActive.text.style.color.value, 0xFF000001); expect(actualActive.text.style!.color!.value, 0xFF000001);
// Border color is resolved correctly. // Border color is resolved correctly.
final BoxDecoration decoration2 = renderDecoratedBox.decoration as BoxDecoration; final BoxDecoration decoration2 = renderDecoratedBox.decoration as BoxDecoration;
expect(decoration2.border.top.color.value, 0x29000000); expect(decoration2.border!.top.color.value, 0x29000000);
}); });
testWidgets('Tabs respects themes', (WidgetTester tester) async { testWidgets('Tabs respects themes', (WidgetTester tester) async {
...@@ -215,13 +213,13 @@ Future<void> main() async { ...@@ -215,13 +213,13 @@ Future<void> main() async {
of: find.text('Tab 1'), of: find.text('Tab 1'),
matching: find.byType(RichText), matching: find.byType(RichText),
)); ));
expect(actualInactive.text.style.color.value, 0xFF999999); expect(actualInactive.text.style!.color!.value, 0xFF999999);
RichText actualActive = tester.widget(find.descendant( RichText actualActive = tester.widget(find.descendant(
of: find.text('Tab 2'), of: find.text('Tab 2'),
matching: find.byType(RichText), matching: find.byType(RichText),
)); ));
expect(actualActive.text.style.color, CupertinoColors.activeBlue); expect(actualActive.text.style!.color, CupertinoColors.activeBlue);
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
...@@ -246,14 +244,14 @@ Future<void> main() async { ...@@ -246,14 +244,14 @@ Future<void> main() async {
of: find.text('Tab 1'), of: find.text('Tab 1'),
matching: find.byType(RichText), matching: find.byType(RichText),
)); ));
expect(actualInactive.text.style.color.value, 0xFF757575); expect(actualInactive.text.style!.color!.value, 0xFF757575);
actualActive = tester.widget(find.descendant( actualActive = tester.widget(find.descendant(
of: find.text('Tab 2'), of: find.text('Tab 2'),
matching: find.byType(RichText), matching: find.byType(RichText),
)); ));
expect(actualActive.text.style.color, isSameColorAs(CupertinoColors.activeBlue.darkColor)); expect(actualActive.text.style!.color, isSameColorAs(CupertinoColors.activeBlue.darkColor));
}); });
testWidgets('Use active icon', (WidgetTester tester) async { testWidgets('Use active icon', (WidgetTester tester) async {
...@@ -368,7 +366,7 @@ Future<void> main() async { ...@@ -368,7 +366,7 @@ Future<void> main() async {
}); });
testWidgets('Tap callback', (WidgetTester tester) async { testWidgets('Tap callback', (WidgetTester tester) async {
int callbackTab; late int callbackTab;
await pumpWidgetWithBoilerplate(tester, MediaQuery( await pumpWidgetWithBoilerplate(tester, MediaQuery(
data: const MediaQueryData(), data: const MediaQueryData(),
......
...@@ -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/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
...@@ -151,11 +149,11 @@ void main() { ...@@ -151,11 +149,11 @@ void main() {
expect(value, isFalse); expect(value, isFalse);
// No animating by default. // No animating by default.
expect(SchedulerBinding.instance.transientCallbackCount, equals(0)); expect(SchedulerBinding.instance!.transientCallbackCount, equals(0));
await tester.tap(find.byType(CupertinoButton)); await tester.tap(find.byType(CupertinoButton));
expect(value, isTrue); expect(value, isTrue);
// Animates. // Animates.
expect(SchedulerBinding.instance.transientCallbackCount, equals(1)); expect(SchedulerBinding.instance!.transientCallbackCount, equals(1));
}); });
testWidgets("Disabled button doesn't animate", (WidgetTester tester) async { testWidgets("Disabled button doesn't animate", (WidgetTester tester) async {
...@@ -163,10 +161,10 @@ void main() { ...@@ -163,10 +161,10 @@ void main() {
child: Text('Tap me'), child: Text('Tap me'),
onPressed: null, onPressed: null,
))); )));
expect(SchedulerBinding.instance.transientCallbackCount, equals(0)); expect(SchedulerBinding.instance!.transientCallbackCount, equals(0));
await tester.tap(find.byType(CupertinoButton)); await tester.tap(find.byType(CupertinoButton));
// Still doesn't animate. // Still doesn't animate.
expect(SchedulerBinding.instance.transientCallbackCount, equals(0)); expect(SchedulerBinding.instance!.transientCallbackCount, equals(0));
}); });
testWidgets('pressedOpacity defaults to 0.1', (WidgetTester tester) async { testWidgets('pressedOpacity defaults to 0.1', (WidgetTester tester) async {
...@@ -295,7 +293,7 @@ void main() { ...@@ -295,7 +293,7 @@ void main() {
find.widgetWithText(DecoratedBox, 'Skeuomorph me') find.widgetWithText(DecoratedBox, 'Skeuomorph me')
).decoration as BoxDecoration; ).decoration as BoxDecoration;
expect(boxDecoration.color.value, 0xFF654321); expect(boxDecoration.color!.value, 0xFF654321);
await tester.pumpWidget( await tester.pumpWidget(
MediaQuery( MediaQuery(
...@@ -314,18 +312,18 @@ void main() { ...@@ -314,18 +312,18 @@ void main() {
).decoration as BoxDecoration; ).decoration as BoxDecoration;
// Disabled color. // Disabled color.
expect(boxDecoration.color.value, 0xFF111111); expect(boxDecoration.color!.value, 0xFF111111);
}); });
testWidgets('Button respects themes', (WidgetTester tester) async { testWidgets('Button respects themes', (WidgetTester tester) async {
TextStyle textStyle; late TextStyle textStyle;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoButton( home: CupertinoButton(
onPressed: () { }, onPressed: () { },
child: Builder(builder: (BuildContext context) { child: Builder(builder: (BuildContext context) {
textStyle = DefaultTextStyle.of(context).style; textStyle = DefaultTextStyle.of(context).style!;
return const Placeholder(); return const Placeholder();
}), }),
), ),
...@@ -339,7 +337,7 @@ void main() { ...@@ -339,7 +337,7 @@ void main() {
home: CupertinoButton.filled( home: CupertinoButton.filled(
onPressed: () { }, onPressed: () { },
child: Builder(builder: (BuildContext context) { child: Builder(builder: (BuildContext context) {
textStyle = DefaultTextStyle.of(context).style; textStyle = DefaultTextStyle.of(context).style!;
return const Placeholder(); return const Placeholder();
}), }),
), ),
...@@ -361,7 +359,7 @@ void main() { ...@@ -361,7 +359,7 @@ void main() {
home: CupertinoButton( home: CupertinoButton(
onPressed: () { }, onPressed: () { },
child: Builder(builder: (BuildContext context) { child: Builder(builder: (BuildContext context) {
textStyle = DefaultTextStyle.of(context).style; textStyle = DefaultTextStyle.of(context).style!;
return const Placeholder(); return const Placeholder();
}), }),
), ),
...@@ -375,7 +373,7 @@ void main() { ...@@ -375,7 +373,7 @@ void main() {
home: CupertinoButton.filled( home: CupertinoButton.filled(
onPressed: () { }, onPressed: () { },
child: Builder(builder: (BuildContext context) { child: Builder(builder: (BuildContext context) {
textStyle = DefaultTextStyle.of(context).style; textStyle = DefaultTextStyle.of(context).style!;
return const Placeholder(); return const Placeholder();
}), }),
), ),
...@@ -392,7 +390,7 @@ void main() { ...@@ -392,7 +390,7 @@ void main() {
}); });
} }
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 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.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';
...@@ -13,15 +11,15 @@ import '../rendering/mock_canvas.dart'; ...@@ -13,15 +11,15 @@ import '../rendering/mock_canvas.dart';
class DependentWidget extends StatelessWidget { class DependentWidget extends StatelessWidget {
const DependentWidget({ const DependentWidget({
Key key, Key? key,
this.color, required this.color,
}) : super(key: key); }) : super(key: key);
final Color color; final Color color;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final Color resolved = CupertinoDynamicColor.resolve(color, context, nullOk: false); final Color resolved = CupertinoDynamicColor.resolve(color, context, nullOk: false)!;
return DecoratedBox( return DecoratedBox(
decoration: BoxDecoration(color: resolved), decoration: BoxDecoration(color: resolved),
child: const SizedBox.expand(), child: const SizedBox.expand(),
...@@ -422,7 +420,7 @@ void main() { ...@@ -422,7 +420,7 @@ void main() {
}); });
testWidgets('CupertinoDynamicColor used in a CupertinoTheme', (WidgetTester tester) async { testWidgets('CupertinoDynamicColor used in a CupertinoTheme', (WidgetTester tester) async {
CupertinoDynamicColor color; late CupertinoDynamicColor color;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
theme: const CupertinoThemeData( theme: const CupertinoThemeData(
...@@ -503,7 +501,7 @@ void main() { ...@@ -503,7 +501,7 @@ void main() {
}); });
group('MaterialApp:', () { group('MaterialApp:', () {
Color color; Color? color;
setUp(() { color = null; }); setUp(() { color = null; });
testWidgets('dynamic color works in cupertino override theme', (WidgetTester tester) async { testWidgets('dynamic color works in cupertino override theme', (WidgetTester tester) async {
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
...@@ -15,7 +13,7 @@ void main() { ...@@ -15,7 +13,7 @@ void main() {
const Color _kDestructiveActionColor = CupertinoColors.destructiveRed; const Color _kDestructiveActionColor = CupertinoColors.destructiveRed;
const FontWeight _kDefaultActionWeight = FontWeight.w600; const FontWeight _kDefaultActionWeight = FontWeight.w600;
Widget _getApp({VoidCallback onPressed, bool isDestructiveAction = false, bool isDefaultAction = false}) { Widget _getApp({VoidCallback? onPressed, bool isDestructiveAction = false, bool isDefaultAction = false}) {
final UniqueKey actionKey = UniqueKey(); final UniqueKey actionKey = UniqueKey();
final CupertinoContextMenuAction action = CupertinoContextMenuAction( final CupertinoContextMenuAction action = CupertinoContextMenuAction(
key: actionKey, key: actionKey,
...@@ -52,7 +50,7 @@ void main() { ...@@ -52,7 +50,7 @@ void main() {
); );
expect(finder, findsOneWidget); expect(finder, findsOneWidget);
final DefaultTextStyle defaultStyle = tester.widget(finder); final DefaultTextStyle defaultStyle = tester.widget(finder);
return defaultStyle.style; return defaultStyle.style!;
} }
Icon _getIcon(WidgetTester tester) { Icon _getIcon(WidgetTester tester) {
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart' show kIsWeb; import 'package:flutter/foundation.dart' show kIsWeb;
...@@ -24,7 +22,7 @@ void main() { ...@@ -24,7 +22,7 @@ void main() {
Widget _getContextMenu({ Widget _getContextMenu({
Alignment alignment = Alignment.center, Alignment alignment = Alignment.center,
Size screenSize = const Size(800.0, 600.0), Size screenSize = const Size(800.0, 600.0),
Widget child, Widget? child,
}) { }) {
return CupertinoApp( return CupertinoApp(
home: CupertinoPageScaffold( home: CupertinoPageScaffold(
......
...@@ -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/cupertino.dart'; import 'package:flutter/cupertino.dart';
...@@ -16,15 +14,6 @@ const Offset _kRowOffset = Offset(0.0, -50.0); ...@@ -16,15 +14,6 @@ const Offset _kRowOffset = Offset(0.0, -50.0);
void main() { void main() {
group('Countdown timer picker', () { group('Countdown timer picker', () {
testWidgets('onTimerDurationChanged is not null', (WidgetTester tester) async {
expect(
() {
CupertinoTimerPicker(onTimerDurationChanged: null);
},
throwsAssertionError,
);
});
testWidgets('initialTimerDuration falls within limit', (WidgetTester tester) async { testWidgets('initialTimerDuration falls within limit', (WidgetTester tester) async {
expect( expect(
() { () {
...@@ -245,7 +234,7 @@ void main() { ...@@ -245,7 +234,7 @@ void main() {
}); });
testWidgets('picker honors minuteInterval and secondInterval', (WidgetTester tester) async { testWidgets('picker honors minuteInterval and secondInterval', (WidgetTester tester) async {
Duration duration; late Duration duration;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: SizedBox( home: SizedBox(
...@@ -277,31 +266,6 @@ void main() { ...@@ -277,31 +266,6 @@ void main() {
}); });
group('Date picker', () { group('Date picker', () {
testWidgets('mode is not null', (WidgetTester tester) async {
expect(
() {
CupertinoDatePicker(
mode: null,
onDateTimeChanged: (_) { },
initialDateTime: DateTime.now(),
);
},
throwsAssertionError,
);
});
testWidgets('onDateTimeChanged is not null', (WidgetTester tester) async {
expect(
() {
CupertinoDatePicker(
onDateTimeChanged: null,
initialDateTime: DateTime.now(),
);
},
throwsAssertionError,
);
});
testWidgets('initial date is set to default value', (WidgetTester tester) async { testWidgets('initial date is set to default value', (WidgetTester tester) async {
final CupertinoDatePicker picker = CupertinoDatePicker( final CupertinoDatePicker picker = CupertinoDatePicker(
onDateTimeChanged: (_) { }, onDateTimeChanged: (_) { },
...@@ -350,7 +314,7 @@ void main() { ...@@ -350,7 +314,7 @@ void main() {
}); });
testWidgets('initial date honors minuteInterval', (WidgetTester tester) async { testWidgets('initial date honors minuteInterval', (WidgetTester tester) async {
DateTime newDateTime; late DateTime newDateTime;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
...@@ -399,7 +363,7 @@ void main() { ...@@ -399,7 +363,7 @@ void main() {
}); });
testWidgets('changing initialDateTime after first build does not do anything', (WidgetTester tester) async { testWidgets('changing initialDateTime after first build does not do anything', (WidgetTester tester) async {
DateTime selectedDateTime; late DateTime selectedDateTime;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
...@@ -622,7 +586,7 @@ void main() { ...@@ -622,7 +586,7 @@ void main() {
}); });
testWidgets('picker automatically scrolls away from invalid date on month change', (WidgetTester tester) async { testWidgets('picker automatically scrolls away from invalid date on month change', (WidgetTester tester) async {
DateTime date; late DateTime date;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
...@@ -666,7 +630,7 @@ void main() { ...@@ -666,7 +630,7 @@ void main() {
'date picker automatically scrolls away from invalid date, ' 'date picker automatically scrolls away from invalid date, '
"and onDateTimeChanged doesn't report these dates", "and onDateTimeChanged doesn't report these dates",
(WidgetTester tester) async { (WidgetTester tester) async {
DateTime date; late DateTime date;
// 2016 is a leap year. // 2016 is a leap year.
final DateTime minimum = DateTime(2016, 2, 29); final DateTime minimum = DateTime(2016, 2, 29);
final DateTime maximum = DateTime(2018, 12, 31); final DateTime maximum = DateTime(2018, 12, 31);
...@@ -695,7 +659,7 @@ void main() { ...@@ -695,7 +659,7 @@ void main() {
// 2017 has 28 days in Feb so 29 is greyed out. // 2017 has 28 days in Feb so 29 is greyed out.
expect( expect(
tester.widget<Text>(find.text('29')).style.color, tester.widget<Text>(find.text('29')).style!.color,
isSameColorAs(CupertinoColors.inactiveGray.color), isSameColorAs(CupertinoColors.inactiveGray.color),
); );
...@@ -710,7 +674,7 @@ void main() { ...@@ -710,7 +674,7 @@ void main() {
// 2016 has 29 days in Feb so 29 is not greyed out. // 2016 has 29 days in Feb so 29 is not greyed out.
expect( expect(
tester.widget<Text>(find.text('29')).style.color, tester.widget<Text>(find.text('29')).style!.color,
isNot(isSameColorAs(CupertinoColors.inactiveGray.color)), isNot(isSameColorAs(CupertinoColors.inactiveGray.color)),
); );
...@@ -724,7 +688,7 @@ void main() { ...@@ -724,7 +688,7 @@ void main() {
); );
expect( expect(
tester.widget<Text>(find.text('29')).style.color, tester.widget<Text>(find.text('29')).style!.color,
isSameColorAs(CupertinoColors.inactiveGray.color), isSameColorAs(CupertinoColors.inactiveGray.color),
); );
}); });
...@@ -733,7 +697,7 @@ void main() { ...@@ -733,7 +697,7 @@ void main() {
'dateTime picker automatically scrolls away from invalid date, ' 'dateTime picker automatically scrolls away from invalid date, '
"and onDateTimeChanged doesn't report these dates", "and onDateTimeChanged doesn't report these dates",
(WidgetTester tester) async { (WidgetTester tester) async {
DateTime date; late DateTime date;
final DateTime minimum = DateTime(2019, 11, 11, 3, 30); final DateTime minimum = DateTime(2019, 11, 11, 3, 30);
final DateTime maximum = DateTime(2019, 11, 11, 14, 59, 59); final DateTime maximum = DateTime(2019, 11, 11, 14, 59, 59);
await tester.pumpWidget( await tester.pumpWidget(
...@@ -761,18 +725,18 @@ void main() { ...@@ -761,18 +725,18 @@ void main() {
// 3:00 is valid but 2:00 should be invalid. // 3:00 is valid but 2:00 should be invalid.
expect( expect(
tester.widget<Text>(find.text('3')).style.color, tester.widget<Text>(find.text('3')).style!.color,
isNot(isSameColorAs(CupertinoColors.inactiveGray.color)), isNot(isSameColorAs(CupertinoColors.inactiveGray.color)),
); );
expect( expect(
tester.widget<Text>(find.text('2')).style.color, tester.widget<Text>(find.text('2')).style!.color,
isSameColorAs(CupertinoColors.inactiveGray.color), isSameColorAs(CupertinoColors.inactiveGray.color),
); );
// 'PM' is greyed out. // 'PM' is greyed out.
expect( expect(
tester.widget<Text>(find.text('PM')).style.color, tester.widget<Text>(find.text('PM')).style!.color,
isSameColorAs(CupertinoColors.inactiveGray.color), isSameColorAs(CupertinoColors.inactiveGray.color),
); );
...@@ -787,11 +751,11 @@ void main() { ...@@ -787,11 +751,11 @@ void main() {
// 3'o clock and 'AM' are now greyed out. // 3'o clock and 'AM' are now greyed out.
expect( expect(
tester.widget<Text>(find.text('AM')).style.color, tester.widget<Text>(find.text('AM')).style!.color,
isSameColorAs(CupertinoColors.inactiveGray.color), isSameColorAs(CupertinoColors.inactiveGray.color),
); );
expect( expect(
tester.widget<Text>(find.text('3')).style.color, tester.widget<Text>(find.text('3')).style!.color,
isSameColorAs(CupertinoColors.inactiveGray.color), isSameColorAs(CupertinoColors.inactiveGray.color),
); );
...@@ -810,7 +774,7 @@ void main() { ...@@ -810,7 +774,7 @@ void main() {
'time picker automatically scrolls away from invalid date, ' 'time picker automatically scrolls away from invalid date, '
"and onDateTimeChanged doesn't report these dates", "and onDateTimeChanged doesn't report these dates",
(WidgetTester tester) async { (WidgetTester tester) async {
DateTime date; late DateTime date;
final DateTime minimum = DateTime(2019, 11, 11, 3, 30); final DateTime minimum = DateTime(2019, 11, 11, 3, 30);
final DateTime maximum = DateTime(2019, 11, 11, 14, 59, 59); final DateTime maximum = DateTime(2019, 11, 11, 14, 59, 59);
await tester.pumpWidget( await tester.pumpWidget(
...@@ -838,18 +802,18 @@ void main() { ...@@ -838,18 +802,18 @@ void main() {
// 3:00 is valid but 2:00 should be invalid. // 3:00 is valid but 2:00 should be invalid.
expect( expect(
tester.widget<Text>(find.text('3')).style.color, tester.widget<Text>(find.text('3')).style!.color,
isNot(isSameColorAs(CupertinoColors.inactiveGray.color)), isNot(isSameColorAs(CupertinoColors.inactiveGray.color)),
); );
expect( expect(
tester.widget<Text>(find.text('2')).style.color, tester.widget<Text>(find.text('2')).style!.color,
isSameColorAs(CupertinoColors.inactiveGray.color), isSameColorAs(CupertinoColors.inactiveGray.color),
); );
// 'PM' is greyed out. // 'PM' is greyed out.
expect( expect(
tester.widget<Text>(find.text('PM')).style.color, tester.widget<Text>(find.text('PM')).style!.color,
isSameColorAs(CupertinoColors.inactiveGray.color), isSameColorAs(CupertinoColors.inactiveGray.color),
); );
...@@ -864,11 +828,11 @@ void main() { ...@@ -864,11 +828,11 @@ void main() {
// 3'o clock and 'AM' are now greyed out. // 3'o clock and 'AM' are now greyed out.
expect( expect(
tester.widget<Text>(find.text('AM')).style.color, tester.widget<Text>(find.text('AM')).style!.color,
isSameColorAs(CupertinoColors.inactiveGray.color), isSameColorAs(CupertinoColors.inactiveGray.color),
); );
expect( expect(
tester.widget<Text>(find.text('3')).style.color, tester.widget<Text>(find.text('3')).style!.color,
isSameColorAs(CupertinoColors.inactiveGray.color), isSameColorAs(CupertinoColors.inactiveGray.color),
); );
...@@ -884,7 +848,7 @@ void main() { ...@@ -884,7 +848,7 @@ void main() {
}); });
testWidgets('picker automatically scrolls away from invalid date on day change', (WidgetTester tester) async { testWidgets('picker automatically scrolls away from invalid date on day change', (WidgetTester tester) async {
DateTime date; late DateTime date;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
...@@ -941,7 +905,7 @@ void main() { ...@@ -941,7 +905,7 @@ void main() {
'date picker should only take into account the date part of minimumDate and maximumDate', 'date picker should only take into account the date part of minimumDate and maximumDate',
(WidgetTester tester) async { (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/49606. // Regression test for https://github.com/flutter/flutter/issues/49606.
DateTime date; late DateTime date;
final DateTime minDate = DateTime(2020, 1, 1, 12); final DateTime minDate = DateTime(2020, 1, 1, 12);
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
...@@ -972,7 +936,7 @@ void main() { ...@@ -972,7 +936,7 @@ void main() {
group('Picker handles initial noon/midnight times', () { group('Picker handles initial noon/midnight times', () {
testWidgets('midnight', (WidgetTester tester) async { testWidgets('midnight', (WidgetTester tester) async {
DateTime date; late DateTime date;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
...@@ -1000,7 +964,7 @@ void main() { ...@@ -1000,7 +964,7 @@ void main() {
}); });
testWidgets('noon', (WidgetTester tester) async { testWidgets('noon', (WidgetTester tester) async {
DateTime date; late DateTime date;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
...@@ -1028,7 +992,7 @@ void main() { ...@@ -1028,7 +992,7 @@ void main() {
}); });
testWidgets('noon in 24 hour time', (WidgetTester tester) async { testWidgets('noon in 24 hour time', (WidgetTester tester) async {
DateTime date; late DateTime date;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
...@@ -1058,7 +1022,7 @@ void main() { ...@@ -1058,7 +1022,7 @@ void main() {
}); });
testWidgets('picker persists am/pm value when scrolling hours', (WidgetTester tester) async { testWidgets('picker persists am/pm value when scrolling hours', (WidgetTester tester) async {
DateTime date; late DateTime date;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
...@@ -1107,7 +1071,7 @@ void main() { ...@@ -1107,7 +1071,7 @@ void main() {
}); });
testWidgets('picker automatically scrolls the am/pm column when the hour column changes enough', (WidgetTester tester) async { testWidgets('picker automatically scrolls the am/pm column when the hour column changes enough', (WidgetTester tester) async {
DateTime date; late DateTime date;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
...@@ -1285,7 +1249,7 @@ void main() { ...@@ -1285,7 +1249,7 @@ void main() {
}); });
testWidgets('TimerPicker only changes hour label after scrolling stops', (WidgetTester tester) async { testWidgets('TimerPicker only changes hour label after scrolling stops', (WidgetTester tester) async {
Duration duration; Duration? duration;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
...@@ -1308,13 +1272,13 @@ void main() { ...@@ -1308,13 +1272,13 @@ void main() {
await tester.drag(find.text('2'), Offset(0, -_kRowOffset.dy)); await tester.drag(find.text('2'), Offset(0, -_kRowOffset.dy));
// Duration should change but not the label. // Duration should change but not the label.
expect(duration?.inHours, 1); expect(duration!.inHours, 1);
expect(find.text('hour'), findsNothing); expect(find.text('hour'), findsNothing);
expect(find.text('hours'), findsOneWidget); expect(find.text('hours'), findsOneWidget);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
// Now the label should change. // Now the label should change.
expect(duration?.inHours, 1); expect(duration!.inHours, 1);
expect(find.text('hours'), findsNothing); expect(find.text('hours'), findsNothing);
expect(find.text('hour'), findsOneWidget); expect(find.text('hour'), findsOneWidget);
}); });
...@@ -1368,7 +1332,7 @@ void main() { ...@@ -1368,7 +1332,7 @@ void main() {
testWidgets('scrollController can be removed or added', (WidgetTester tester) async { testWidgets('scrollController can be removed or added', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics(); final SemanticsHandle handle = tester.ensureSemantics();
int lastSelectedItem; late int lastSelectedItem;
void onSelectedItemChanged(int index) { void onSelectedItemChanged(int index) {
lastSelectedItem = index; lastSelectedItem = index;
} }
...@@ -1377,7 +1341,7 @@ void main() { ...@@ -1377,7 +1341,7 @@ void main() {
onSelectedItemChanged: onSelectedItemChanged, onSelectedItemChanged: onSelectedItemChanged,
)); ));
tester.binding.pipelineOwner.semanticsOwner.performAction(1, SemanticsAction.increase); tester.binding.pipelineOwner.semanticsOwner!.performAction(1, SemanticsAction.increase);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(lastSelectedItem, 1); expect(lastSelectedItem, 1);
...@@ -1385,7 +1349,7 @@ void main() { ...@@ -1385,7 +1349,7 @@ void main() {
onSelectedItemChanged: onSelectedItemChanged, onSelectedItemChanged: onSelectedItemChanged,
)); ));
tester.binding.pipelineOwner.semanticsOwner.performAction(1, SemanticsAction.increase); tester.binding.pipelineOwner.semanticsOwner!.performAction(1, SemanticsAction.increase);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(lastSelectedItem, 2); expect(lastSelectedItem, 2);
...@@ -1394,7 +1358,7 @@ void main() { ...@@ -1394,7 +1358,7 @@ void main() {
onSelectedItemChanged: onSelectedItemChanged, onSelectedItemChanged: onSelectedItemChanged,
)); ));
tester.binding.pipelineOwner.semanticsOwner.performAction(1, SemanticsAction.increase); tester.binding.pipelineOwner.semanticsOwner!.performAction(1, SemanticsAction.increase);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(lastSelectedItem, 3); expect(lastSelectedItem, 3);
...@@ -1404,7 +1368,7 @@ void main() { ...@@ -1404,7 +1368,7 @@ void main() {
testWidgets('CupertinoDataPicker does not provide invalid MediaQuery', (WidgetTester tester) async { testWidgets('CupertinoDataPicker does not provide invalid MediaQuery', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/47989. // Regression test for https://github.com/flutter/flutter/issues/47989.
Brightness brightness = Brightness.light; Brightness brightness = Brightness.light;
StateSetter setState; late StateSetter setState;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
...@@ -1421,7 +1385,7 @@ void main() { ...@@ -1421,7 +1385,7 @@ void main() {
home: StatefulBuilder(builder: (BuildContext context, StateSetter stateSetter) { home: StatefulBuilder(builder: (BuildContext context, StateSetter stateSetter) {
setState = stateSetter; setState = stateSetter;
return MediaQuery( return MediaQuery(
data: MediaQuery.of(context).copyWith(platformBrightness: brightness), data: MediaQuery.of(context)!.copyWith(platformBrightness: brightness),
child: CupertinoDatePicker( child: CupertinoDatePicker(
initialDateTime: DateTime(2019), initialDateTime: DateTime(2019),
mode: CupertinoDatePickerMode.date, mode: CupertinoDatePickerMode.date,
...@@ -1433,7 +1397,7 @@ void main() { ...@@ -1433,7 +1397,7 @@ void main() {
); );
expect( expect(
tester.widget<Text>(find.text('2019')).style.color, tester.widget<Text>(find.text('2019')).style!.color,
isSameColorAs(const Color(0xFFFFFFFF)), isSameColorAs(const Color(0xFFFFFFFF)),
); );
...@@ -1441,7 +1405,7 @@ void main() { ...@@ -1441,7 +1405,7 @@ void main() {
await tester.pump(); await tester.pump();
expect( expect(
tester.widget<Text>(find.text('2019')).style.color, tester.widget<Text>(find.text('2019')).style!.color,
isSameColorAs(const Color(0xFF000000)), isSameColorAs(const Color(0xFF000000)),
); );
}); });
...@@ -1449,7 +1413,7 @@ void main() { ...@@ -1449,7 +1413,7 @@ void main() {
testWidgets('picker exports semantics', (WidgetTester tester) async { testWidgets('picker exports semantics', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics(); final SemanticsHandle handle = tester.ensureSemantics();
debugResetSemanticsIdCounter(); debugResetSemanticsIdCounter();
int lastSelectedItem; int? lastSelectedItem;
await tester.pumpWidget(_buildPicker(onSelectedItemChanged: (int index) { await tester.pumpWidget(_buildPicker(onSelectedItemChanged: (int index) {
lastSelectedItem = index; lastSelectedItem = index;
})); }));
...@@ -1466,7 +1430,7 @@ void main() { ...@@ -1466,7 +1430,7 @@ void main() {
], ],
)); ));
tester.binding.pipelineOwner.semanticsOwner.performAction(1, SemanticsAction.increase); tester.binding.pipelineOwner.semanticsOwner!.performAction(1, SemanticsAction.increase);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(tester.getSemantics(find.byType(CupertinoPicker)), matchesSemantics( expect(tester.getSemantics(find.byType(CupertinoPicker)), matchesSemantics(
...@@ -1486,7 +1450,10 @@ void main() { ...@@ -1486,7 +1450,10 @@ void main() {
}); });
} }
Widget _buildPicker({ FixedExtentScrollController controller, ValueChanged<int> onSelectedItemChanged }) { Widget _buildPicker({
FixedExtentScrollController? controller,
required ValueChanged<int> onSelectedItemChanged,
}) {
return Directionality( return Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: CupertinoPicker( child: CupertinoPicker(
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:math'; import 'dart:math';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
...@@ -118,7 +116,7 @@ void main() { ...@@ -118,7 +116,7 @@ void main() {
final DefaultTextStyle widget = tester.widget(find.byType(DefaultTextStyle)); final DefaultTextStyle widget = tester.widget(find.byType(DefaultTextStyle));
expect(widget.style.color.withAlpha(255), CupertinoColors.systemRed.color); expect(widget.style!.color!.withAlpha(255), CupertinoColors.systemRed.color);
}); });
testWidgets('Dialog dark theme', (WidgetTester tester) async { testWidgets('Dialog dark theme', (WidgetTester tester) async {
...@@ -143,7 +141,7 @@ void main() { ...@@ -143,7 +141,7 @@ void main() {
); );
expect( expect(
cancelText.text.style.color.value, cancelText.text.style!.color!.value,
0xFF0A84FF, // dark elevated color of systemBlue. 0xFF0A84FF, // dark elevated color of systemBlue.
); );
...@@ -233,7 +231,7 @@ void main() { ...@@ -233,7 +231,7 @@ void main() {
final DefaultTextStyle widget = tester.widget(find.byType(DefaultTextStyle)); final DefaultTextStyle widget = tester.widget(find.byType(DefaultTextStyle));
expect(widget.style.fontWeight, equals(FontWeight.w600)); expect(widget.style!.fontWeight, equals(FontWeight.w600));
}); });
testWidgets('Dialog default and destructive action styles', (WidgetTester tester) async { testWidgets('Dialog default and destructive action styles', (WidgetTester tester) async {
...@@ -245,8 +243,8 @@ void main() { ...@@ -245,8 +243,8 @@ void main() {
final DefaultTextStyle widget = tester.widget(find.byType(DefaultTextStyle)); final DefaultTextStyle widget = tester.widget(find.byType(DefaultTextStyle));
expect(widget.style.color.withAlpha(255), CupertinoColors.systemRed.color); expect(widget.style!.color!.withAlpha(255), CupertinoColors.systemRed.color);
expect(widget.style.fontWeight, equals(FontWeight.w600)); expect(widget.style!.fontWeight, equals(FontWeight.w600));
}); });
testWidgets('Dialog disabled action style', (WidgetTester tester) async { testWidgets('Dialog disabled action style', (WidgetTester tester) async {
...@@ -256,8 +254,8 @@ void main() { ...@@ -256,8 +254,8 @@ void main() {
final DefaultTextStyle widget = tester.widget(find.byType(DefaultTextStyle)); final DefaultTextStyle widget = tester.widget(find.byType(DefaultTextStyle));
expect(widget.style.color.opacity, greaterThanOrEqualTo(127 / 255)); expect(widget.style!.color!.opacity, greaterThanOrEqualTo(127 / 255));
expect(widget.style.color.opacity, lessThanOrEqualTo(128 / 255)); expect(widget.style!.color!.opacity, lessThanOrEqualTo(128 / 255));
}); });
testWidgets('Dialog enabled action style', (WidgetTester tester) async { testWidgets('Dialog enabled action style', (WidgetTester tester) async {
...@@ -268,7 +266,7 @@ void main() { ...@@ -268,7 +266,7 @@ void main() {
final DefaultTextStyle widget = tester.widget(find.byType(DefaultTextStyle)); final DefaultTextStyle widget = tester.widget(find.byType(DefaultTextStyle));
expect(widget.style.color.opacity, equals(1.0)); expect(widget.style!.color!.opacity, equals(1.0));
}); });
testWidgets('Message is scrollable, has correct padding with large text sizes', (WidgetTester tester) async { testWidgets('Message is scrollable, has correct padding with large text sizes', (WidgetTester tester) async {
...@@ -277,7 +275,7 @@ void main() { ...@@ -277,7 +275,7 @@ void main() {
createAppWithButtonThatLaunchesDialog( createAppWithButtonThatLaunchesDialog(
dialogBuilder: (BuildContext context) { dialogBuilder: (BuildContext context) {
return MediaQuery( return MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: 3.0), data: MediaQuery.of(context)!.copyWith(textScaleFactor: 3.0),
child: CupertinoAlertDialog( child: CupertinoAlertDialog(
title: const Text('The Title'), title: const Text('The Title'),
content: Text('Very long content ' * 20), content: Text('Very long content ' * 20),
...@@ -377,7 +375,7 @@ void main() { ...@@ -377,7 +375,7 @@ void main() {
createAppWithButtonThatLaunchesDialog( createAppWithButtonThatLaunchesDialog(
dialogBuilder: (BuildContext context) { dialogBuilder: (BuildContext context) {
return MediaQuery( return MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: 3.0), data: MediaQuery.of(context)!.copyWith(textScaleFactor: 3.0),
child: CupertinoAlertDialog( child: CupertinoAlertDialog(
title: const Text('The title'), title: const Text('The title'),
content: const Text('The content.'), content: const Text('The content.'),
...@@ -438,7 +436,7 @@ void main() { ...@@ -438,7 +436,7 @@ void main() {
createAppWithButtonThatLaunchesDialog( createAppWithButtonThatLaunchesDialog(
dialogBuilder: (BuildContext context) { dialogBuilder: (BuildContext context) {
return MediaQuery( return MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: textScaleFactor), data: MediaQuery.of(context)!.copyWith(textScaleFactor: textScaleFactor),
child: CupertinoAlertDialog( child: CupertinoAlertDialog(
actions: const <Widget>[ actions: const <Widget>[
CupertinoDialogAction( CupertinoDialogAction(
...@@ -489,7 +487,7 @@ void main() { ...@@ -489,7 +487,7 @@ void main() {
createAppWithButtonThatLaunchesDialog( createAppWithButtonThatLaunchesDialog(
dialogBuilder: (BuildContext context) { dialogBuilder: (BuildContext context) {
return MediaQuery( return MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: textScaleFactor), data: MediaQuery.of(context)!.copyWith(textScaleFactor: textScaleFactor),
child: CupertinoAlertDialog( child: CupertinoAlertDialog(
title: const Text('The title'), title: const Text('The title'),
content: const Text('The content.'), content: const Text('The content.'),
...@@ -554,11 +552,11 @@ void main() { ...@@ -554,11 +552,11 @@ void main() {
testWidgets('Actions section height for 2 side-by-side buttons is height of tallest button.', (WidgetTester tester) async { testWidgets('Actions section height for 2 side-by-side buttons is height of tallest button.', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
double dividerWidth; // Will be set when the dialog builder runs. Needs a BuildContext. late double dividerWidth; // Will be set when the dialog builder runs. Needs a BuildContext.
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesDialog( createAppWithButtonThatLaunchesDialog(
dialogBuilder: (BuildContext context) { dialogBuilder: (BuildContext context) {
dividerWidth = 1.0 / MediaQuery.of(context).devicePixelRatio; dividerWidth = 1.0 / MediaQuery.of(context)!.devicePixelRatio;
return CupertinoAlertDialog( return CupertinoAlertDialog(
title: const Text('The Title'), title: const Text('The Title'),
content: const Text('The message'), content: const Text('The message'),
...@@ -599,11 +597,11 @@ void main() { ...@@ -599,11 +597,11 @@ void main() {
testWidgets('Actions section height for 2 stacked buttons with enough room is height of both buttons.', (WidgetTester tester) async { testWidgets('Actions section height for 2 stacked buttons with enough room is height of both buttons.', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
double dividerThickness; // Will be set when the dialog builder runs. Needs a BuildContext. late double dividerThickness; // Will be set when the dialog builder runs. Needs a BuildContext.
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesDialog( createAppWithButtonThatLaunchesDialog(
dialogBuilder: (BuildContext context) { dialogBuilder: (BuildContext context) {
dividerThickness = 1.0 / MediaQuery.of(context).devicePixelRatio; dividerThickness = 1.0 / MediaQuery.of(context)!.devicePixelRatio;
return CupertinoAlertDialog( return CupertinoAlertDialog(
title: const Text('The Title'), title: const Text('The Title'),
content: const Text('The message'), content: const Text('The message'),
...@@ -679,7 +677,7 @@ void main() { ...@@ -679,7 +677,7 @@ void main() {
createAppWithButtonThatLaunchesDialog( createAppWithButtonThatLaunchesDialog(
dialogBuilder: (BuildContext context) { dialogBuilder: (BuildContext context) {
return MediaQuery( return MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: 3.0), data: MediaQuery.of(context)!.copyWith(textScaleFactor: 3.0),
child: CupertinoAlertDialog( child: CupertinoAlertDialog(
title: const Text('The Title'), title: const Text('The Title'),
content: Text('The message\n' * 20), content: Text('The message\n' * 20),
...@@ -807,11 +805,11 @@ void main() { ...@@ -807,11 +805,11 @@ void main() {
testWidgets('Pressed button changes appearance and dividers disappear.', (WidgetTester tester) async { testWidgets('Pressed button changes appearance and dividers disappear.', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
double dividerThickness; // Will be set when the dialog builder runs. Needs a BuildContext. late double dividerThickness; // Will be set when the dialog builder runs. Needs a BuildContext.
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesDialog( createAppWithButtonThatLaunchesDialog(
dialogBuilder: (BuildContext context) { dialogBuilder: (BuildContext context) {
dividerThickness = 1.0 / MediaQuery.of(context).devicePixelRatio; dividerThickness = 1.0 / MediaQuery.of(context)!.devicePixelRatio;
return CupertinoAlertDialog( return CupertinoAlertDialog(
title: const Text('The Title'), title: const Text('The Title'),
content: const Text('The message'), content: const Text('The message'),
...@@ -1153,7 +1151,7 @@ void main() { ...@@ -1153,7 +1151,7 @@ void main() {
createAppWithButtonThatLaunchesDialog( createAppWithButtonThatLaunchesDialog(
dialogBuilder: (BuildContext context) { dialogBuilder: (BuildContext context) {
return MediaQuery( return MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: 3.0), data: MediaQuery.of(context)!.copyWith(textScaleFactor: 3.0),
child: const RepaintBoundary( child: const RepaintBoundary(
child: CupertinoAlertDialog( child: CupertinoAlertDialog(
title: Text('Title'), title: Text('Title'),
...@@ -1195,7 +1193,9 @@ RenderBox findScrollableActionsSectionRenderBox(WidgetTester tester) { ...@@ -1195,7 +1193,9 @@ RenderBox findScrollableActionsSectionRenderBox(WidgetTester tester) {
return actionsSection as RenderBox; return actionsSection as RenderBox;
} }
Widget createAppWithButtonThatLaunchesDialog({ WidgetBuilder dialogBuilder }) { Widget createAppWithButtonThatLaunchesDialog({
required WidgetBuilder dialogBuilder
}) {
return MaterialApp( return MaterialApp(
home: Material( home: Material(
child: Center( child: Center(
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -11,7 +9,7 @@ void main() { ...@@ -11,7 +9,7 @@ void main() {
testWidgets('IconTheme.of works', (WidgetTester tester) async { testWidgets('IconTheme.of works', (WidgetTester tester) async {
const IconThemeData data = IconThemeData(color: Color(0xAAAAAAAA), opacity: 0.5, size: 16.0); const IconThemeData data = IconThemeData(color: Color(0xAAAAAAAA), opacity: 0.5, size: 16.0);
IconThemeData retrieved; late IconThemeData retrieved;
await tester.pumpWidget( await tester.pumpWidget(
IconTheme(data: data, child: Builder(builder: (BuildContext context) { IconTheme(data: data, child: Builder(builder: (BuildContext context) {
retrieved = IconTheme.of(context); retrieved = IconTheme.of(context);
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
...@@ -394,11 +392,11 @@ void main() { ...@@ -394,11 +392,11 @@ void main() {
..sort((Element a, Element b) { ..sort((Element a, Element b) {
final RenderParagraph aParagraph = a.renderObject as RenderParagraph; final RenderParagraph aParagraph = a.renderObject as RenderParagraph;
final RenderParagraph bParagraph = b.renderObject as RenderParagraph; final RenderParagraph bParagraph = b.renderObject as RenderParagraph;
return aParagraph.text.style.fontSize.compareTo(bParagraph.text.style.fontSize); return aParagraph.text.style!.fontSize!.compareTo(bParagraph.text.style!.fontSize!);
}); });
Iterable<double> opacities = titles.map<double>((Element element) { Iterable<double> opacities = titles.map<double>((Element element) {
final RenderAnimatedOpacity renderOpacity = element.findAncestorRenderObjectOfType<RenderAnimatedOpacity>(); final RenderAnimatedOpacity renderOpacity = element.findAncestorRenderObjectOfType<RenderAnimatedOpacity>()!;
return renderOpacity.opacity.value; return renderOpacity.opacity.value;
}); });
...@@ -419,11 +417,11 @@ void main() { ...@@ -419,11 +417,11 @@ void main() {
..sort((Element a, Element b) { ..sort((Element a, Element b) {
final RenderParagraph aParagraph = a.renderObject as RenderParagraph; final RenderParagraph aParagraph = a.renderObject as RenderParagraph;
final RenderParagraph bParagraph = b.renderObject as RenderParagraph; final RenderParagraph bParagraph = b.renderObject as RenderParagraph;
return aParagraph.text.style.fontSize.compareTo(bParagraph.text.style.fontSize); return aParagraph.text.style!.fontSize!.compareTo(bParagraph.text.style!.fontSize!);
}); });
opacities = titles.map<double>((Element element) { opacities = titles.map<double>((Element element) {
final RenderAnimatedOpacity renderOpacity = element.findAncestorRenderObjectOfType<RenderAnimatedOpacity>(); final RenderAnimatedOpacity renderOpacity = element.findAncestorRenderObjectOfType<RenderAnimatedOpacity>()!;
return renderOpacity.opacity.value; return renderOpacity.opacity.value;
}); });
...@@ -531,7 +529,7 @@ void main() { ...@@ -531,7 +529,7 @@ void main() {
expect(find.text('Different title'), findsOneWidget); expect(find.text('Different title'), findsOneWidget);
RenderAnimatedOpacity largeTitleOpacity = RenderAnimatedOpacity largeTitleOpacity =
tester.element(find.text('Title')).findAncestorRenderObjectOfType<RenderAnimatedOpacity>(); tester.element(find.text('Title')).findAncestorRenderObjectOfType<RenderAnimatedOpacity>()!;
// Large title initially visible. // Large title initially visible.
expect( expect(
largeTitleOpacity.opacity.value, largeTitleOpacity.opacity.value,
...@@ -550,7 +548,7 @@ void main() { ...@@ -550,7 +548,7 @@ void main() {
await tester.pump(const Duration(milliseconds: 300)); await tester.pump(const Duration(milliseconds: 300));
largeTitleOpacity = largeTitleOpacity =
tester.element(find.text('Title')).findAncestorRenderObjectOfType<RenderAnimatedOpacity>(); tester.element(find.text('Title')).findAncestorRenderObjectOfType<RenderAnimatedOpacity>()!;
// Large title no longer visible. // Large title no longer visible.
expect( expect(
largeTitleOpacity.opacity.value, largeTitleOpacity.opacity.value,
...@@ -680,7 +678,7 @@ void main() { ...@@ -680,7 +678,7 @@ void main() {
final BoxDecoration decoration = decoratedBox.decoration as BoxDecoration; final BoxDecoration decoration = decoratedBox.decoration as BoxDecoration;
expect(decoration.border, isNotNull); expect(decoration.border, isNotNull);
final BorderSide side = decoration.border.bottom; final BorderSide side = decoration.border!.bottom;
expect(side, isNotNull); expect(side, isNotNull);
}); });
...@@ -708,7 +706,7 @@ void main() { ...@@ -708,7 +706,7 @@ void main() {
final BoxDecoration decoration = decoratedBox.decoration as BoxDecoration; final BoxDecoration decoration = decoratedBox.decoration as BoxDecoration;
expect(decoration.border, isNotNull); expect(decoration.border, isNotNull);
final BorderSide side = decoration.border.bottom; final BorderSide side = decoration.border!.bottom;
expect(side, isNotNull); expect(side, isNotNull);
expect(side.color, const Color(0xFFAABBCC)); expect(side.color, const Color(0xFFAABBCC));
}); });
...@@ -757,7 +755,7 @@ void main() { ...@@ -757,7 +755,7 @@ void main() {
final BoxDecoration decoration = decoratedBox.decoration as BoxDecoration; final BoxDecoration decoration = decoratedBox.decoration as BoxDecoration;
expect(decoration.border, isNotNull); expect(decoration.border, isNotNull);
final BorderSide bottom = decoration.border.bottom; final BorderSide bottom = decoration.border!.bottom;
expect(bottom, isNotNull); expect(bottom, isNotNull);
}); });
...@@ -863,10 +861,10 @@ void main() { ...@@ -863,10 +861,10 @@ void main() {
final BoxDecoration decoration = decoratedBox.decoration as BoxDecoration; final BoxDecoration decoration = decoratedBox.decoration as BoxDecoration;
expect(decoration.border, isNotNull); expect(decoration.border, isNotNull);
final BorderSide top = decoration.border.top; final BorderSide top = decoration.border!.top;
expect(top, isNotNull); expect(top, isNotNull);
expect(top, BorderSide.none); expect(top, BorderSide.none);
final BorderSide bottom = decoration.border.bottom; final BorderSide bottom = decoration.border!.bottom;
expect(bottom, isNotNull); expect(bottom, isNotNull);
expect(bottom.color, const Color(0xFFAABBCC)); expect(bottom.color, const Color(0xFFAABBCC));
}); });
...@@ -1108,7 +1106,7 @@ void main() { ...@@ -1108,7 +1106,7 @@ void main() {
CupertinoApp( CupertinoApp(
home: Builder(builder: (BuildContext context) { home: Builder(builder: (BuildContext context) {
return MediaQuery( return MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: 99), data: MediaQuery.of(context)!.copyWith(textScaleFactor: 99),
child: CupertinoPageScaffold( child: CupertinoPageScaffold(
child: CustomScrollView( child: CustomScrollView(
slivers: <Widget>[ slivers: <Widget>[
...@@ -1156,7 +1154,7 @@ void main() { ...@@ -1156,7 +1154,7 @@ void main() {
title: 'title', title: 'title',
builder: (BuildContext context) { builder: (BuildContext context) {
return MediaQuery( return MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: 99), data: MediaQuery.of(context)!.copyWith(textScaleFactor: 99),
child: Container( child: Container(
child: const CupertinoPageScaffold( child: const CupertinoPageScaffold(
child: CustomScrollView( child: CustomScrollView(
...@@ -1190,14 +1188,17 @@ void main() { ...@@ -1190,14 +1188,17 @@ void main() {
} }
class _ExpectStyles extends StatelessWidget { class _ExpectStyles extends StatelessWidget {
const _ExpectStyles({ this.color, this.index }); const _ExpectStyles({
required this.color,
required this.index
});
final Color color; final Color color;
final int index; final int index;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final TextStyle style = DefaultTextStyle.of(context).style; final TextStyle style = DefaultTextStyle.of(context).style!;
expect(style.color, isSameColorAs(color)); expect(style.color, isSameColorAs(color));
expect(style.fontFamily, '.SF Pro Text'); expect(style.fontFamily, '.SF Pro Text');
expect(style.fontSize, 17.0); expect(style.fontSize, 17.0);
......
...@@ -2,28 +2,26 @@ ...@@ -2,28 +2,26 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
Future<void> startTransitionBetween( Future<void> startTransitionBetween(
WidgetTester tester, { WidgetTester tester, {
Widget from, Widget? from,
Widget to, Widget? to,
String fromTitle, String? fromTitle,
String toTitle, String? toTitle,
TextDirection textDirection = TextDirection.ltr, TextDirection textDirection = TextDirection.ltr,
CupertinoThemeData theme, CupertinoThemeData? theme,
}) async { }) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
theme: theme, theme: theme,
builder: (BuildContext context, Widget navigator) { builder: (BuildContext context, Widget? navigator) {
return Directionality( return Directionality(
textDirection: textDirection, textDirection: textDirection,
child: navigator, child: navigator!,
); );
}, },
home: const Placeholder(), home: const Placeholder(),
...@@ -34,7 +32,7 @@ Future<void> startTransitionBetween( ...@@ -34,7 +32,7 @@ Future<void> startTransitionBetween(
.state<NavigatorState>(find.byType(Navigator)) .state<NavigatorState>(find.byType(Navigator))
.push(CupertinoPageRoute<void>( .push(CupertinoPageRoute<void>(
title: fromTitle, title: fromTitle,
builder: (BuildContext context) => scaffoldForNavBar(from), builder: (BuildContext context) => scaffoldForNavBar(from)!,
)); ));
await tester.pump(); await tester.pump();
...@@ -44,16 +42,16 @@ Future<void> startTransitionBetween( ...@@ -44,16 +42,16 @@ Future<void> startTransitionBetween(
.state<NavigatorState>(find.byType(Navigator)) .state<NavigatorState>(find.byType(Navigator))
.push(CupertinoPageRoute<void>( .push(CupertinoPageRoute<void>(
title: toTitle, title: toTitle,
builder: (BuildContext context) => scaffoldForNavBar(to), builder: (BuildContext context) => scaffoldForNavBar(to)!,
)); ));
await tester.pump(); await tester.pump();
} }
CupertinoPageScaffold scaffoldForNavBar(Widget navBar) { CupertinoPageScaffold? scaffoldForNavBar(Widget? navBar) {
if (navBar is CupertinoNavigationBar || navBar == null) { if (navBar is CupertinoNavigationBar || navBar == null) {
return CupertinoPageScaffold( return CupertinoPageScaffold(
navigationBar: navBar as CupertinoNavigationBar ?? const CupertinoNavigationBar(), navigationBar: navBar as CupertinoNavigationBar? ?? const CupertinoNavigationBar(),
child: const Placeholder(), child: const Placeholder(),
); );
} else if (navBar is CupertinoSliverNavigationBar) { } else if (navBar is CupertinoSliverNavigationBar) {
...@@ -175,10 +173,10 @@ void main() { ...@@ -175,10 +173,10 @@ void main() {
// The transition's stack is ordered. The bottom middle is inserted first. // The transition's stack is ordered. The bottom middle is inserted first.
final RenderParagraph bottomMiddle = final RenderParagraph bottomMiddle =
tester.renderObject(flying(tester, find.text('Page 1')).first); tester.renderObject(flying(tester, find.text('Page 1')).first);
expect(bottomMiddle.text.style.color, const Color(0xff00050a)); expect(bottomMiddle.text.style!.color, const Color(0xff00050a));
expect(bottomMiddle.text.style.fontWeight, FontWeight.w600); expect(bottomMiddle.text.style!.fontWeight, FontWeight.w600);
expect(bottomMiddle.text.style.fontFamily, '.SF Pro Text'); expect(bottomMiddle.text.style!.fontFamily, '.SF Pro Text');
expect(bottomMiddle.text.style.letterSpacing, -0.41); expect(bottomMiddle.text.style!.letterSpacing, -0.41);
checkOpacity( checkOpacity(
tester, flying(tester, find.text('Page 1')).first, 0.9004602432250977); tester, flying(tester, find.text('Page 1')).first, 0.9004602432250977);
...@@ -187,26 +185,26 @@ void main() { ...@@ -187,26 +185,26 @@ void main() {
// are flipped. // are flipped.
final RenderParagraph topBackLabel = final RenderParagraph topBackLabel =
tester.renderObject(flying(tester, find.text('Page 1')).last); tester.renderObject(flying(tester, find.text('Page 1')).last);
expect(topBackLabel.text.style.color, const Color(0xff00050a)); expect(topBackLabel.text.style!.color, const Color(0xff00050a));
expect(topBackLabel.text.style.fontWeight, FontWeight.w600); expect(topBackLabel.text.style!.fontWeight, FontWeight.w600);
expect(topBackLabel.text.style.fontFamily, '.SF Pro Text'); expect(topBackLabel.text.style!.fontFamily, '.SF Pro Text');
expect(topBackLabel.text.style.letterSpacing, -0.41); expect(topBackLabel.text.style!.letterSpacing, -0.41);
checkOpacity(tester, flying(tester, find.text('Page 1')).last, 0.0); checkOpacity(tester, flying(tester, find.text('Page 1')).last, 0.0);
// Move animation further a bit. // Move animation further a bit.
await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200));
expect(bottomMiddle.text.style.color, const Color(0xff006de4)); expect(bottomMiddle.text.style!.color, const Color(0xff006de4));
expect(bottomMiddle.text.style.fontWeight, FontWeight.w400); expect(bottomMiddle.text.style!.fontWeight, FontWeight.w400);
expect(bottomMiddle.text.style.fontFamily, '.SF Pro Text'); expect(bottomMiddle.text.style!.fontFamily, '.SF Pro Text');
expect(bottomMiddle.text.style.letterSpacing, -0.41); expect(bottomMiddle.text.style!.letterSpacing, -0.41);
checkOpacity(tester, flying(tester, find.text('Page 1')).first, 0.0); checkOpacity(tester, flying(tester, find.text('Page 1')).first, 0.0);
expect(topBackLabel.text.style.color, const Color(0xff006de4)); expect(topBackLabel.text.style!.color, const Color(0xff006de4));
expect(topBackLabel.text.style.fontWeight, FontWeight.w400); expect(topBackLabel.text.style!.fontWeight, FontWeight.w400);
expect(topBackLabel.text.style.fontFamily, '.SF Pro Text'); expect(topBackLabel.text.style!.fontFamily, '.SF Pro Text');
expect(topBackLabel.text.style.letterSpacing, -0.41); expect(topBackLabel.text.style!.letterSpacing, -0.41);
checkOpacity( checkOpacity(
tester, flying(tester, find.text('Page 1')).last, 0.7630139589309692); tester, flying(tester, find.text('Page 1')).last, 0.7630139589309692);
...@@ -225,10 +223,10 @@ void main() { ...@@ -225,10 +223,10 @@ void main() {
// The transition's stack is ordered. The bottom middle is inserted first. // The transition's stack is ordered. The bottom middle is inserted first.
final RenderParagraph bottomMiddle = final RenderParagraph bottomMiddle =
tester.renderObject(flying(tester, find.text('Page 1')).first); tester.renderObject(flying(tester, find.text('Page 1')).first);
expect(bottomMiddle.text.style.color, const Color(0xFFF4F9FF)); expect(bottomMiddle.text.style!.color, const Color(0xFFF4F9FF));
expect(bottomMiddle.text.style.fontWeight, FontWeight.w600); expect(bottomMiddle.text.style!.fontWeight, FontWeight.w600);
expect(bottomMiddle.text.style.fontFamily, '.SF Pro Text'); expect(bottomMiddle.text.style!.fontFamily, '.SF Pro Text');
expect(bottomMiddle.text.style.letterSpacing, -0.41); expect(bottomMiddle.text.style!.letterSpacing, -0.41);
checkOpacity(tester, flying(tester, find.text('Page 1')).first, 0.9004602432250977); checkOpacity(tester, flying(tester, find.text('Page 1')).first, 0.9004602432250977);
...@@ -236,26 +234,26 @@ void main() { ...@@ -236,26 +234,26 @@ void main() {
// are flipped. // are flipped.
final RenderParagraph topBackLabel = final RenderParagraph topBackLabel =
tester.renderObject(flying(tester, find.text('Page 1')).last); tester.renderObject(flying(tester, find.text('Page 1')).last);
expect(topBackLabel.text.style.color, const Color(0xFFF4F9FF)); expect(topBackLabel.text.style!.color, const Color(0xFFF4F9FF));
expect(topBackLabel.text.style.fontWeight, FontWeight.w600); expect(topBackLabel.text.style!.fontWeight, FontWeight.w600);
expect(topBackLabel.text.style.fontFamily, '.SF Pro Text'); expect(topBackLabel.text.style!.fontFamily, '.SF Pro Text');
expect(topBackLabel.text.style.letterSpacing, -0.41); expect(topBackLabel.text.style!.letterSpacing, -0.41);
checkOpacity(tester, flying(tester, find.text('Page 1')).last, 0.0); checkOpacity(tester, flying(tester, find.text('Page 1')).last, 0.0);
// Move animation further a bit. // Move animation further a bit.
await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200));
expect(bottomMiddle.text.style.color, const Color(0xFF2390FF)); expect(bottomMiddle.text.style!.color, const Color(0xFF2390FF));
expect(bottomMiddle.text.style.fontWeight, FontWeight.w400); expect(bottomMiddle.text.style!.fontWeight, FontWeight.w400);
expect(bottomMiddle.text.style.fontFamily, '.SF Pro Text'); expect(bottomMiddle.text.style!.fontFamily, '.SF Pro Text');
expect(bottomMiddle.text.style.letterSpacing, -0.41); expect(bottomMiddle.text.style!.letterSpacing, -0.41);
checkOpacity(tester, flying(tester, find.text('Page 1')).first, 0.0); checkOpacity(tester, flying(tester, find.text('Page 1')).first, 0.0);
expect(topBackLabel.text.style.color, const Color(0xFF2390FF)); expect(topBackLabel.text.style!.color, const Color(0xFF2390FF));
expect(topBackLabel.text.style.fontWeight, FontWeight.w400); expect(topBackLabel.text.style!.fontWeight, FontWeight.w400);
expect(topBackLabel.text.style.fontFamily, '.SF Pro Text'); expect(topBackLabel.text.style!.fontFamily, '.SF Pro Text');
expect(topBackLabel.text.style.letterSpacing, -0.41); expect(topBackLabel.text.style!.letterSpacing, -0.41);
checkOpacity(tester, flying(tester, find.text('Page 1')).last, 0.7630139589309692); checkOpacity(tester, flying(tester, find.text('Page 1')).last, 0.7630139589309692);
}); });
...@@ -271,7 +269,7 @@ void main() { ...@@ -271,7 +269,7 @@ void main() {
.state<NavigatorState>(find.byType(Navigator)) .state<NavigatorState>(find.byType(Navigator))
.push(CupertinoPageRoute<void>( .push(CupertinoPageRoute<void>(
title: 'Page 1', title: 'Page 1',
builder: (BuildContext context) => scaffoldForNavBar(null), builder: (BuildContext context) => scaffoldForNavBar(null)!,
)); ));
await tester.pump(); await tester.pump();
...@@ -282,7 +280,7 @@ void main() { ...@@ -282,7 +280,7 @@ void main() {
.push(CupertinoPageRoute<void>( .push(CupertinoPageRoute<void>(
title: 'Page 2', title: 'Page 2',
fullscreenDialog: true, fullscreenDialog: true,
builder: (BuildContext context) => scaffoldForNavBar(null), builder: (BuildContext context) => scaffoldForNavBar(null)!,
)); ));
await tester.pump(); await tester.pump();
...@@ -328,7 +326,7 @@ void main() { ...@@ -328,7 +326,7 @@ void main() {
// The transition's stack is ordered. The bottom middle is inserted first. // The transition's stack is ordered. The bottom middle is inserted first.
final RenderParagraph bottomMiddle = final RenderParagraph bottomMiddle =
tester.renderObject(flying(tester, find.text('Page 1')).first); tester.renderObject(flying(tester, find.text('Page 1')).first);
expect(bottomMiddle.text.style.color, const Color(0xff00050a)); expect(bottomMiddle.text.style!.color, const Color(0xff00050a));
expect( expect(
tester.getTopLeft(flying(tester, find.text('Page 1')).first), tester.getTopLeft(flying(tester, find.text('Page 1')).first),
const Offset(337.0234375, 13.5), const Offset(337.0234375, 13.5),
...@@ -338,7 +336,7 @@ void main() { ...@@ -338,7 +336,7 @@ void main() {
// are flipped. // are flipped.
final RenderParagraph topBackLabel = final RenderParagraph topBackLabel =
tester.renderObject(flying(tester, find.text('Page 1')).last); tester.renderObject(flying(tester, find.text('Page 1')).last);
expect(topBackLabel.text.style.color, const Color(0xff00050a)); expect(topBackLabel.text.style!.color, const Color(0xff00050a));
expect( expect(
tester.getTopLeft(flying(tester, find.text('Page 1')).last), tester.getTopLeft(flying(tester, find.text('Page 1')).last),
const Offset(337.0234375, 13.5), const Offset(337.0234375, 13.5),
...@@ -373,7 +371,7 @@ void main() { ...@@ -373,7 +371,7 @@ void main() {
// The transition's stack is ordered. The bottom middle is inserted first. // The transition's stack is ordered. The bottom middle is inserted first.
final RenderParagraph bottomMiddle = final RenderParagraph bottomMiddle =
tester.renderObject(flying(tester, find.text('Page 1')).first); tester.renderObject(flying(tester, find.text('Page 1')).first);
expect(bottomMiddle.text.style.color, const Color(0xff00050a)); expect(bottomMiddle.text.style!.color, const Color(0xff00050a));
expect( expect(
tester.getTopLeft(flying(tester, find.text('Page 1')).first), tester.getTopLeft(flying(tester, find.text('Page 1')).first),
const Offset(362.9765625, 13.5), const Offset(362.9765625, 13.5),
...@@ -383,7 +381,7 @@ void main() { ...@@ -383,7 +381,7 @@ void main() {
// are flipped. // are flipped.
final RenderParagraph topBackLabel = final RenderParagraph topBackLabel =
tester.renderObject(flying(tester, find.text('Page 1')).last); tester.renderObject(flying(tester, find.text('Page 1')).last);
expect(topBackLabel.text.style.color, const Color(0xff00050a)); expect(topBackLabel.text.style!.color, const Color(0xff00050a));
expect( expect(
tester.getTopLeft(flying(tester, find.text('Page 1')).last), tester.getTopLeft(flying(tester, find.text('Page 1')).last),
const Offset(362.9765625, 13.5), const Offset(362.9765625, 13.5),
...@@ -584,7 +582,7 @@ void main() { ...@@ -584,7 +582,7 @@ void main() {
.state<NavigatorState>(find.byType(Navigator)) .state<NavigatorState>(find.byType(Navigator))
.push(CupertinoPageRoute<void>( .push(CupertinoPageRoute<void>(
title: 'Page 1', title: 'Page 1',
builder: (BuildContext context) => scaffoldForNavBar(null), builder: (BuildContext context) => scaffoldForNavBar(null)!,
)); ));
await tester.pump(); await tester.pump();
...@@ -612,10 +610,10 @@ void main() { ...@@ -612,10 +610,10 @@ void main() {
testWidgets('First appearance of back chevron fades in from the left in RTL', (WidgetTester tester) async { testWidgets('First appearance of back chevron fades in from the left in RTL', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
builder: (BuildContext context, Widget navigator) { builder: (BuildContext context, Widget? navigator) {
return Directionality( return Directionality(
textDirection: TextDirection.rtl, textDirection: TextDirection.rtl,
child: navigator, child: navigator!,
); );
}, },
home: scaffoldForNavBar(null), home: scaffoldForNavBar(null),
...@@ -626,7 +624,7 @@ void main() { ...@@ -626,7 +624,7 @@ void main() {
.state<NavigatorState>(find.byType(Navigator)) .state<NavigatorState>(find.byType(Navigator))
.push(CupertinoPageRoute<void>( .push(CupertinoPageRoute<void>(
title: 'Page 1', title: 'Page 1',
builder: (BuildContext context) => scaffoldForNavBar(null), builder: (BuildContext context) => scaffoldForNavBar(null)!,
)); ));
await tester.pump(); await tester.pump();
...@@ -778,7 +776,7 @@ void main() { ...@@ -778,7 +776,7 @@ void main() {
.state<NavigatorState>(find.byType(Navigator)) .state<NavigatorState>(find.byType(Navigator))
.push(CupertinoPageRoute<void>( .push(CupertinoPageRoute<void>(
title: 'Page 3', title: 'Page 3',
builder: (BuildContext context) => scaffoldForNavBar(null), builder: (BuildContext context) => scaffoldForNavBar(null)!,
)); ));
await tester.pump(); await tester.pump();
...@@ -815,7 +813,7 @@ void main() { ...@@ -815,7 +813,7 @@ void main() {
.state<NavigatorState>(find.byType(Navigator)) .state<NavigatorState>(find.byType(Navigator))
.push(CupertinoPageRoute<void>( .push(CupertinoPageRoute<void>(
title: 'Page 3', title: 'Page 3',
builder: (BuildContext context) => scaffoldForNavBar(null), builder: (BuildContext context) => scaffoldForNavBar(null)!,
)); ));
await tester.pump(); await tester.pump();
...@@ -931,30 +929,30 @@ void main() { ...@@ -931,30 +929,30 @@ void main() {
// The transition's stack is ordered. The bottom large title is inserted first. // The transition's stack is ordered. The bottom large title is inserted first.
final RenderParagraph bottomLargeTitle = final RenderParagraph bottomLargeTitle =
tester.renderObject(flying(tester, find.text('Page 1')).first); tester.renderObject(flying(tester, find.text('Page 1')).first);
expect(bottomLargeTitle.text.style.color, const Color(0xff00050a)); expect(bottomLargeTitle.text.style!.color, const Color(0xff00050a));
expect(bottomLargeTitle.text.style.fontWeight, FontWeight.w700); expect(bottomLargeTitle.text.style!.fontWeight, FontWeight.w700);
expect(bottomLargeTitle.text.style.fontFamily, '.SF Pro Display'); expect(bottomLargeTitle.text.style!.fontFamily, '.SF Pro Display');
expect(bottomLargeTitle.text.style.letterSpacing, moreOrLessEquals(0.374765625)); expect(bottomLargeTitle.text.style!.letterSpacing, moreOrLessEquals(0.374765625));
// The top back label is styled exactly the same way. // The top back label is styled exactly the same way.
final RenderParagraph topBackLabel = final RenderParagraph topBackLabel =
tester.renderObject(flying(tester, find.text('Page 1')).last); tester.renderObject(flying(tester, find.text('Page 1')).last);
expect(topBackLabel.text.style.color, const Color(0xff00050a)); expect(topBackLabel.text.style!.color, const Color(0xff00050a));
expect(topBackLabel.text.style.fontWeight, FontWeight.w700); expect(topBackLabel.text.style!.fontWeight, FontWeight.w700);
expect(topBackLabel.text.style.fontFamily, '.SF Pro Display'); expect(topBackLabel.text.style!.fontFamily, '.SF Pro Display');
expect(topBackLabel.text.style.letterSpacing, moreOrLessEquals(0.374765625)); expect(topBackLabel.text.style!.letterSpacing, moreOrLessEquals(0.374765625));
// Move animation further a bit. // Move animation further a bit.
await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200));
expect(bottomLargeTitle.text.style.color, const Color(0xff006de4)); expect(bottomLargeTitle.text.style!.color, const Color(0xff006de4));
expect(bottomLargeTitle.text.style.fontWeight, FontWeight.w400); expect(bottomLargeTitle.text.style!.fontWeight, FontWeight.w400);
expect(bottomLargeTitle.text.style.fontFamily, '.SF Pro Text'); expect(bottomLargeTitle.text.style!.fontFamily, '.SF Pro Text');
expect(bottomLargeTitle.text.style.letterSpacing, moreOrLessEquals(-0.32379547566175454)); expect(bottomLargeTitle.text.style!.letterSpacing, moreOrLessEquals(-0.32379547566175454));
expect(topBackLabel.text.style.color, const Color(0xff006de4)); expect(topBackLabel.text.style!.color, const Color(0xff006de4));
expect(topBackLabel.text.style.fontWeight, FontWeight.w400); expect(topBackLabel.text.style!.fontWeight, FontWeight.w400);
expect(topBackLabel.text.style.fontFamily, '.SF Pro Text'); expect(topBackLabel.text.style!.fontFamily, '.SF Pro Text');
expect(topBackLabel.text.style.letterSpacing, moreOrLessEquals(-0.32379547566175454)); expect(topBackLabel.text.style!.letterSpacing, moreOrLessEquals(-0.32379547566175454));
}); });
testWidgets('Top middle fades in and slides in from the right', (WidgetTester tester) async { testWidgets('Top middle fades in and slides in from the right', (WidgetTester tester) async {
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -276,10 +274,10 @@ void main() { ...@@ -276,10 +274,10 @@ void main() {
testWidgets('test edge swipes work with media query padding (LTR)', (WidgetTester tester) async { testWidgets('test edge swipes work with media query padding (LTR)', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
builder: (BuildContext context, Widget navigator) { builder: (BuildContext context, Widget? navigator) {
return MediaQuery( return MediaQuery(
data: const MediaQueryData(padding: EdgeInsets.only(left: 40)), data: const MediaQueryData(padding: EdgeInsets.only(left: 40)),
child: navigator, child: navigator!,
); );
}, },
home: const Placeholder(), home: const Placeholder(),
...@@ -320,12 +318,12 @@ void main() { ...@@ -320,12 +318,12 @@ void main() {
testWidgets('test edge swipes work with media query padding (RLT)', (WidgetTester tester) async { testWidgets('test edge swipes work with media query padding (RLT)', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
builder: (BuildContext context, Widget navigator) { builder: (BuildContext context, Widget? navigator) {
return Directionality( return Directionality(
textDirection: TextDirection.rtl, textDirection: TextDirection.rtl,
child: MediaQuery( child: MediaQuery(
data: const MediaQueryData(padding: EdgeInsets.only(right: 40)), data: const MediaQueryData(padding: EdgeInsets.only(right: 40)),
child: navigator, child: navigator!,
), ),
); );
}, },
...@@ -471,7 +469,7 @@ void main() { ...@@ -471,7 +469,7 @@ void main() {
expect(find.text('subpage'), findsOneWidget); expect(find.text('subpage'), findsOneWidget);
expect(find.text('home'), findsNothing); expect(find.text('home'), findsNothing);
navigator.currentState.pop(); navigator.currentState!.pop();
await tester.pump(); await tester.pump();
expect(find.text('subpage'), findsOneWidget); expect(find.text('subpage'), findsOneWidget);
...@@ -498,14 +496,14 @@ class RtlOverrideWidgetsLocalization implements WidgetsLocalizations { ...@@ -498,14 +496,14 @@ class RtlOverrideWidgetsLocalization implements WidgetsLocalizations {
class KeepsStateTestWidget extends StatefulWidget { class KeepsStateTestWidget extends StatefulWidget {
const KeepsStateTestWidget({this.navigatorKey}); const KeepsStateTestWidget({this.navigatorKey});
final Key navigatorKey; final Key? navigatorKey;
@override @override
State<KeepsStateTestWidget> createState() => _KeepsStateTestWidgetState(); State<KeepsStateTestWidget> createState() => _KeepsStateTestWidgetState();
} }
class _KeepsStateTestWidgetState extends State<KeepsStateTestWidget> { class _KeepsStateTestWidgetState extends State<KeepsStateTestWidget> {
String _subpage = 'subpage'; String? _subpage = 'subpage';
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -514,7 +512,7 @@ class _KeepsStateTestWidgetState extends State<KeepsStateTestWidget> { ...@@ -514,7 +512,7 @@ class _KeepsStateTestWidgetState extends State<KeepsStateTestWidget> {
key: widget.navigatorKey, key: widget.navigatorKey,
pages: <Page<void>>[ pages: <Page<void>>[
const CupertinoPage<void>(child: Text('home')), const CupertinoPage<void>(child: Text('home')),
if (_subpage != null) CupertinoPage<void>(child: Text(_subpage)), if (_subpage != null) CupertinoPage<void>(child: Text(_subpage!)),
], ],
onPopPage: (Route<dynamic> route, dynamic result) { onPopPage: (Route<dynamic> route, dynamic result) {
if (!route.didPop(result)) { if (!route.didPop(result)) {
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
...@@ -39,8 +37,8 @@ void main() { ...@@ -39,8 +37,8 @@ void main() {
final RenderParagraph paragraph = tester.renderObject(find.text('1')); final RenderParagraph paragraph = tester.renderObject(find.text('1'));
expect(paragraph.text.style.color, isSameColorAs(CupertinoColors.black)); expect(paragraph.text.style!.color, isSameColorAs(CupertinoColors.black));
expect(paragraph.text.style.copyWith(color: CupertinoColors.black), const TextStyle( expect(paragraph.text.style!.copyWith(color: CupertinoColors.black), const TextStyle(
inherit: false, inherit: false,
fontFamily: '.SF Pro Display', fontFamily: '.SF Pro Display',
fontSize: 21.0, fontSize: 21.0,
......
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