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: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,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