Unverified Commit 727cee6d authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Migrate More Material Tests (#67482)

parent bd2ec40c
...@@ -129,7 +129,7 @@ class Radio<T> extends StatefulWidget { ...@@ -129,7 +129,7 @@ class Radio<T> extends StatefulWidget {
/// ///
/// This radio button is considered selected if its [value] matches the /// This radio button is considered selected if its [value] matches the
/// [groupValue]. /// [groupValue].
final T groupValue; final T? groupValue;
/// Called when the user selects this radio button. /// Called when the user selects this radio button.
/// ///
......
...@@ -335,7 +335,7 @@ class RadioListTile<T> extends StatelessWidget { ...@@ -335,7 +335,7 @@ class RadioListTile<T> extends StatelessWidget {
/// ///
/// This radio button is considered selected if its [value] matches the /// This radio button is considered selected if its [value] matches the
/// [groupValue]. /// [groupValue].
final T groupValue; final T? groupValue;
/// Called when the user selects this radio button. /// Called when the user selects this radio button.
/// ///
......
...@@ -175,7 +175,7 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS ...@@ -175,7 +175,7 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
late Animation<Color?> _valueColor; late Animation<Color?> _valueColor;
_RefreshIndicatorMode? _mode; _RefreshIndicatorMode? _mode;
Future<void>? _pendingRefreshFuture; late Future<void> _pendingRefreshFuture;
bool? _isIndicatorAtTop; bool? _isIndicatorAtTop;
double? _dragOffset; double? _dragOffset;
...@@ -406,7 +406,7 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS ...@@ -406,7 +406,7 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
/// When initiated in this manner, the refresh indicator is independent of any /// When initiated in this manner, the refresh indicator is independent of any
/// actual scroll view. It defaults to showing the indicator at the top. To /// actual scroll view. It defaults to showing the indicator at the top. To
/// show it at the bottom, set `atTop` to false. /// show it at the bottom, set `atTop` to false.
Future<void>? show({ bool atTop = true }) { Future<void> show({ bool atTop = true }) {
if (_mode != _RefreshIndicatorMode.refresh && if (_mode != _RefreshIndicatorMode.refresh &&
_mode != _RefreshIndicatorMode.snap) { _mode != _RefreshIndicatorMode.snap) {
if (_mode == null) if (_mode == null)
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -298,8 +296,8 @@ void main() { ...@@ -298,8 +296,8 @@ void main() {
}); });
testWidgets('Determinate CircularProgressIndicator stops the animator', (WidgetTester tester) async { testWidgets('Determinate CircularProgressIndicator stops the animator', (WidgetTester tester) async {
double progressValue; double? progressValue;
StateSetter setState; late StateSetter setState;
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
......
...@@ -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/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -14,7 +12,7 @@ import 'package:flutter/material.dart'; ...@@ -14,7 +12,7 @@ import 'package:flutter/material.dart';
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
Widget wrap({Widget child}) { Widget wrap({Widget? child}) {
return MediaQuery( return MediaQuery(
data: const MediaQueryData(), data: const MediaQueryData(),
child: Directionality( child: Directionality(
...@@ -28,7 +26,7 @@ void main() { ...@@ -28,7 +26,7 @@ void main() {
testWidgets('RadioListTile should initialize according to groupValue', testWidgets('RadioListTile should initialize according to groupValue',
(WidgetTester tester) async { (WidgetTester tester) async {
final List<int> values = <int>[0, 1, 2]; final List<int> values = <int>[0, 1, 2];
int selectedValue; int? selectedValue;
// Constructor parameters are required for [RadioListTile], but they are // Constructor parameters are required for [RadioListTile], but they are
// irrelevant when searching with [find.byType]. // irrelevant when searching with [find.byType].
final Type radioListTileType = const RadioListTile<int>( final Type radioListTileType = const RadioListTile<int>(
...@@ -53,7 +51,7 @@ void main() { ...@@ -53,7 +51,7 @@ void main() {
body: ListView.builder( body: ListView.builder(
itemCount: values.length, itemCount: values.length,
itemBuilder: (BuildContext context, int index) => RadioListTile<int>( itemBuilder: (BuildContext context, int index) => RadioListTile<int>(
onChanged: (int value) { onChanged: (int? value) {
setState(() { setState(() {
selectedValue = value; selectedValue = value;
}); });
...@@ -89,7 +87,7 @@ void main() { ...@@ -89,7 +87,7 @@ void main() {
testWidgets('RadioListTile simple control test', (WidgetTester tester) async { testWidgets('RadioListTile simple control test', (WidgetTester tester) async {
final Key key = UniqueKey(); final Key key = UniqueKey();
final Key titleKey = UniqueKey(); final Key titleKey = UniqueKey();
final List<int> log = <int>[]; final List<int?> log = <int?>[];
await tester.pumpWidget( await tester.pumpWidget(
wrap( wrap(
...@@ -160,7 +158,7 @@ void main() { ...@@ -160,7 +158,7 @@ void main() {
testWidgets('RadioListTile control tests', (WidgetTester tester) async { testWidgets('RadioListTile control tests', (WidgetTester tester) async {
final List<int> values = <int>[0, 1, 2]; final List<int> values = <int>[0, 1, 2];
int selectedValue; int? selectedValue;
// Constructor parameters are required for [Radio], but they are irrelevant // Constructor parameters are required for [Radio], but they are irrelevant
// when searching with [find.byType]. // when searching with [find.byType].
final Type radioType = const Radio<int>( final Type radioType = const Radio<int>(
...@@ -178,7 +176,7 @@ void main() { ...@@ -178,7 +176,7 @@ void main() {
body: ListView.builder( body: ListView.builder(
itemCount: values.length, itemCount: values.length,
itemBuilder: (BuildContext context, int index) => RadioListTile<int>( itemBuilder: (BuildContext context, int index) => RadioListTile<int>(
onChanged: (int value) { onChanged: (int? value) {
log.add(value); log.add(value);
setState(() { setState(() {
selectedValue = value; selectedValue = value;
...@@ -228,7 +226,7 @@ void main() { ...@@ -228,7 +226,7 @@ void main() {
testWidgets('Selected RadioListTile should not trigger onChanged', (WidgetTester tester) async { testWidgets('Selected RadioListTile should not trigger onChanged', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/30311 // Regression test for https://github.com/flutter/flutter/issues/30311
final List<int> values = <int>[0, 1, 2]; final List<int> values = <int>[0, 1, 2];
int selectedValue; int? selectedValue;
// Constructor parameters are required for [Radio], but they are irrelevant // Constructor parameters are required for [Radio], but they are irrelevant
// when searching with [find.byType]. // when searching with [find.byType].
final Type radioType = const Radio<int>( final Type radioType = const Radio<int>(
...@@ -246,7 +244,7 @@ void main() { ...@@ -246,7 +244,7 @@ void main() {
body: ListView.builder( body: ListView.builder(
itemCount: values.length, itemCount: values.length,
itemBuilder: (BuildContext context, int index) => RadioListTile<int>( itemBuilder: (BuildContext context, int index) => RadioListTile<int>(
onChanged: (int value) { onChanged: (int? value) {
log.add(value); log.add(value);
setState(() { setState(() {
selectedValue = value; selectedValue = value;
...@@ -280,7 +278,7 @@ void main() { ...@@ -280,7 +278,7 @@ void main() {
testWidgets('Selected RadioListTile should trigger onChanged when toggleable', testWidgets('Selected RadioListTile should trigger onChanged when toggleable',
(WidgetTester tester) async { (WidgetTester tester) async {
final List<int> values = <int>[0, 1, 2]; final List<int> values = <int>[0, 1, 2];
int selectedValue; int? selectedValue;
// Constructor parameters are required for [Radio], but they are irrelevant // Constructor parameters are required for [Radio], but they are irrelevant
// when searching with [find.byType]. // when searching with [find.byType].
final Type radioType = const Radio<int>( final Type radioType = const Radio<int>(
...@@ -299,7 +297,7 @@ void main() { ...@@ -299,7 +297,7 @@ void main() {
itemCount: values.length, itemCount: values.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return RadioListTile<int>( return RadioListTile<int>(
onChanged: (int value) { onChanged: (int? value) {
log.add(value); log.add(value);
setState(() { setState(() {
selectedValue = value; selectedValue = value;
...@@ -325,16 +323,16 @@ void main() { ...@@ -325,16 +323,16 @@ void main() {
await tester.tap(find.text('0')); await tester.tap(find.text('0'));
await tester.pump(); await tester.pump();
expect(log, equals(<int>[0, null])); expect(log, equals(<int?>[0, null]));
await tester.tap(find.byType(radioType).at(0)); await tester.tap(find.byType(radioType).at(0));
await tester.pump(); await tester.pump();
expect(log, equals(<int>[0, null, 0])); expect(log, equals(<int?>[0, null, 0]));
}); });
testWidgets('RadioListTile can be toggled when toggleable is set', (WidgetTester tester) async { testWidgets('RadioListTile can be toggled when toggleable is set', (WidgetTester tester) async {
final Key key = UniqueKey(); final Key key = UniqueKey();
final List<int> log = <int>[]; final List<int?> log = <int?>[];
await tester.pumpWidget(Material( await tester.pumpWidget(Material(
child: Center( child: Center(
...@@ -367,7 +365,7 @@ void main() { ...@@ -367,7 +365,7 @@ void main() {
await tester.tap(find.byKey(key)); await tester.tap(find.byKey(key));
expect(log, equals(<int>[null])); expect(log, equals(<int?>[null]));
log.clear(); log.clear();
await tester.pumpWidget(Material( await tester.pumpWidget(Material(
...@@ -395,7 +393,7 @@ void main() { ...@@ -395,7 +393,7 @@ void main() {
child: RadioListTile<int>( child: RadioListTile<int>(
value: 1, value: 1,
groupValue: 2, groupValue: 2,
onChanged: (int i) {}, onChanged: (int? i) {},
title: const Text('Title'), title: const Text('Title'),
), ),
), ),
...@@ -431,7 +429,7 @@ void main() { ...@@ -431,7 +429,7 @@ void main() {
child: RadioListTile<int>( child: RadioListTile<int>(
value: 2, value: 2,
groupValue: 2, groupValue: 2,
onChanged: (int i) {}, onChanged: (int? i) {},
title: const Text('Title'), title: const Text('Title'),
), ),
), ),
...@@ -540,7 +538,7 @@ void main() { ...@@ -540,7 +538,7 @@ void main() {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
final Key key = UniqueKey(); final Key key = UniqueKey();
dynamic semanticEvent; dynamic semanticEvent;
int radioValue = 2; int? radioValue = 2;
SystemChannels.accessibility.setMockMessageHandler((dynamic message) async { SystemChannels.accessibility.setMockMessageHandler((dynamic message) async {
semanticEvent = message; semanticEvent = message;
}); });
...@@ -551,7 +549,7 @@ void main() { ...@@ -551,7 +549,7 @@ void main() {
key: key, key: key,
value: 1, value: 1,
groupValue: radioValue, groupValue: radioValue,
onChanged: (int i) { onChanged: (int? i) {
radioValue = i; radioValue = i;
}, },
title: const Text('Title'), title: const Text('Title'),
...@@ -566,10 +564,10 @@ void main() { ...@@ -566,10 +564,10 @@ void main() {
expect(radioValue, 1); expect(radioValue, 1);
expect(semanticEvent, <String, dynamic>{ expect(semanticEvent, <String, dynamic>{
'type': 'tap', 'type': 'tap',
'nodeId': object.debugSemantics.id, 'nodeId': object.debugSemantics!.id,
'data': <String, dynamic>{}, 'data': <String, dynamic>{},
}); });
expect(object.debugSemantics.getSemanticsData().hasAction(SemanticsAction.tap), true); expect(object.debugSemantics!.getSemanticsData().hasAction(SemanticsAction.tap), true);
semantics.dispose(); semantics.dispose();
SystemChannels.accessibility.setMockMessageHandler(null); SystemChannels.accessibility.setMockMessageHandler(null);
...@@ -591,7 +589,7 @@ void main() { ...@@ -591,7 +589,7 @@ void main() {
); );
await tester.pump(); await tester.pump();
expect(Focus.of(childKey.currentContext, nullOk: true).hasPrimaryFocus, isTrue); expect(Focus.of(childKey.currentContext!)!.hasPrimaryFocus, isTrue);
await tester.pumpWidget( await tester.pumpWidget(
wrap( wrap(
...@@ -606,6 +604,6 @@ void main() { ...@@ -606,6 +604,6 @@ void main() {
); );
await tester.pump(); await tester.pump();
expect(Focus.of(childKey.currentContext, nullOk: true).hasPrimaryFocus, isFalse); expect(Focus.of(childKey.currentContext!)!.hasPrimaryFocus, isFalse);
}); });
} }
...@@ -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/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -18,7 +16,7 @@ import '../widgets/semantics_tester.dart'; ...@@ -18,7 +16,7 @@ import '../widgets/semantics_tester.dart';
void main() { void main() {
testWidgets('Radio control test', (WidgetTester tester) async { testWidgets('Radio control test', (WidgetTester tester) async {
final Key key = UniqueKey(); final Key key = UniqueKey();
final List<int> log = <int>[]; final List<int?> log = <int?>[];
await tester.pumpWidget(Material( await tester.pumpWidget(Material(
child: Center( child: Center(
...@@ -70,7 +68,7 @@ void main() { ...@@ -70,7 +68,7 @@ void main() {
testWidgets('Radio can be toggled when toggleable is set', (WidgetTester tester) async { testWidgets('Radio can be toggled when toggleable is set', (WidgetTester tester) async {
final Key key = UniqueKey(); final Key key = UniqueKey();
final List<int> log = <int>[]; final List<int?> log = <int?>[];
await tester.pumpWidget(Material( await tester.pumpWidget(Material(
child: Center( child: Center(
...@@ -103,7 +101,7 @@ void main() { ...@@ -103,7 +101,7 @@ void main() {
await tester.tap(find.byKey(key)); await tester.tap(find.byKey(key));
expect(log, equals(<int>[null])); expect(log, equals(<int?>[null]));
log.clear(); log.clear();
await tester.pumpWidget(Material( await tester.pumpWidget(Material(
...@@ -136,7 +134,7 @@ void main() { ...@@ -136,7 +134,7 @@ void main() {
key: key1, key: key1,
groupValue: true, groupValue: true,
value: true, value: true,
onChanged: (bool newValue) { }, onChanged: (bool? newValue) { },
), ),
), ),
), ),
...@@ -158,7 +156,7 @@ void main() { ...@@ -158,7 +156,7 @@ void main() {
key: key2, key: key2,
groupValue: true, groupValue: true,
value: true, value: true,
onChanged: (bool newValue) { }, onChanged: (bool? newValue) { },
), ),
), ),
), ),
...@@ -177,7 +175,7 @@ void main() { ...@@ -177,7 +175,7 @@ void main() {
child: Radio<int>( child: Radio<int>(
value: 1, value: 1,
groupValue: 2, groupValue: 2,
onChanged: (int i) { }, onChanged: (int? i) { },
), ),
)); ));
...@@ -203,7 +201,7 @@ void main() { ...@@ -203,7 +201,7 @@ void main() {
child: Radio<int>( child: Radio<int>(
value: 2, value: 2,
groupValue: 2, groupValue: 2,
onChanged: (int i) { }, onChanged: (int? i) { },
), ),
)); ));
...@@ -293,7 +291,7 @@ void main() { ...@@ -293,7 +291,7 @@ void main() {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
final Key key = UniqueKey(); final Key key = UniqueKey();
dynamic semanticEvent; dynamic semanticEvent;
int radioValue = 2; int? radioValue = 2;
SystemChannels.accessibility.setMockMessageHandler((dynamic message) async { SystemChannels.accessibility.setMockMessageHandler((dynamic message) async {
semanticEvent = message; semanticEvent = message;
}); });
...@@ -303,7 +301,7 @@ void main() { ...@@ -303,7 +301,7 @@ void main() {
key: key, key: key,
value: 1, value: 1,
groupValue: radioValue, groupValue: radioValue,
onChanged: (int i) { onChanged: (int? i) {
radioValue = i; radioValue = i;
}, },
), ),
...@@ -315,10 +313,10 @@ void main() { ...@@ -315,10 +313,10 @@ void main() {
expect(radioValue, 1); expect(radioValue, 1);
expect(semanticEvent, <String, dynamic>{ expect(semanticEvent, <String, dynamic>{
'type': 'tap', 'type': 'tap',
'nodeId': object.debugSemantics.id, 'nodeId': object.debugSemantics!.id,
'data': <String, dynamic>{}, 'data': <String, dynamic>{},
}); });
expect(object.debugSemantics.getSemanticsData().hasAction(SemanticsAction.tap), true); expect(object.debugSemantics!.getSemanticsData().hasAction(SemanticsAction.tap), true);
semantics.dispose(); semantics.dispose();
SystemChannels.accessibility.setMockMessageHandler(null); SystemChannels.accessibility.setMockMessageHandler(null);
...@@ -342,7 +340,7 @@ void main() { ...@@ -342,7 +340,7 @@ void main() {
key: radioKey, key: radioKey,
value: 1, value: 1,
groupValue: 1, groupValue: 1,
onChanged: (int value) { }, onChanged: (int? value) { },
), ),
), ),
), ),
...@@ -361,7 +359,7 @@ void main() { ...@@ -361,7 +359,7 @@ void main() {
testWidgets('Radio is focusable and has correct focus color', (WidgetTester tester) async { testWidgets('Radio is focusable and has correct focus color', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'Radio'); final FocusNode focusNode = FocusNode(debugLabel: 'Radio');
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
int groupValue = 0; int? groupValue = 0;
const Key radioKey = Key('radio'); const Key radioKey = Key('radio');
Widget buildApp({bool enabled = true}) { Widget buildApp({bool enabled = true}) {
return MaterialApp( return MaterialApp(
...@@ -375,7 +373,7 @@ void main() { ...@@ -375,7 +373,7 @@ void main() {
child: Radio<int>( child: Radio<int>(
key: radioKey, key: radioKey,
value: 0, value: 0,
onChanged: enabled ? (int newValue) { onChanged: enabled ? (int? newValue) {
setState(() { setState(() {
groupValue = newValue; groupValue = newValue;
}); });
...@@ -439,7 +437,7 @@ void main() { ...@@ -439,7 +437,7 @@ void main() {
testWidgets('Radio can be hovered and has correct hover color', (WidgetTester tester) async { testWidgets('Radio can be hovered and has correct hover color', (WidgetTester tester) async {
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
int groupValue = 0; int? groupValue = 0;
const Key radioKey = Key('radio'); const Key radioKey = Key('radio');
Widget buildApp({bool enabled = true}) { Widget buildApp({bool enabled = true}) {
return MaterialApp( return MaterialApp(
...@@ -453,7 +451,7 @@ void main() { ...@@ -453,7 +451,7 @@ void main() {
child: Radio<int>( child: Radio<int>(
key: radioKey, key: radioKey,
value: 0, value: 0,
onChanged: enabled ? (int newValue) { onChanged: enabled ? (int? newValue) {
setState(() { setState(() {
groupValue = newValue; groupValue = newValue;
}); });
...@@ -519,7 +517,7 @@ void main() { ...@@ -519,7 +517,7 @@ void main() {
testWidgets('Radio can be controlled by keyboard shortcuts', (WidgetTester tester) async { testWidgets('Radio can be controlled by keyboard shortcuts', (WidgetTester tester) async {
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
int groupValue = 1; int? groupValue = 1;
const Key radioKey0 = Key('radio0'); const Key radioKey0 = Key('radio0');
const Key radioKey1 = Key('radio1'); const Key radioKey1 = Key('radio1');
const Key radioKey2 = Key('radio2'); const Key radioKey2 = Key('radio2');
...@@ -538,7 +536,7 @@ void main() { ...@@ -538,7 +536,7 @@ void main() {
Radio<int>( Radio<int>(
key: radioKey0, key: radioKey0,
value: 0, value: 0,
onChanged: enabled ? (int newValue) { onChanged: enabled ? (int? newValue) {
setState(() { setState(() {
groupValue = newValue; groupValue = newValue;
}); });
...@@ -550,7 +548,7 @@ void main() { ...@@ -550,7 +548,7 @@ void main() {
Radio<int>( Radio<int>(
key: radioKey1, key: radioKey1,
value: 1, value: 1,
onChanged: enabled ? (int newValue) { onChanged: enabled ? (int? newValue) {
setState(() { setState(() {
groupValue = newValue; groupValue = newValue;
}); });
...@@ -561,7 +559,7 @@ void main() { ...@@ -561,7 +559,7 @@ void main() {
Radio<int>( Radio<int>(
key: radioKey2, key: radioKey2,
value: 2, value: 2,
onChanged: enabled ? (int newValue) { onChanged: enabled ? (int? newValue) {
setState(() { setState(() {
groupValue = newValue; groupValue = newValue;
}); });
...@@ -605,7 +603,7 @@ void main() { ...@@ -605,7 +603,7 @@ void main() {
child: Radio<int>( child: Radio<int>(
visualDensity: visualDensity, visualDensity: visualDensity,
key: key, key: key,
onChanged: (int value) {}, onChanged: (int? value) {},
value: 0, value: 0,
groupValue: 0, groupValue: 0,
), ),
...@@ -648,7 +646,7 @@ void main() { ...@@ -648,7 +646,7 @@ void main() {
key: key, key: key,
mouseCursor: SystemMouseCursors.text, mouseCursor: SystemMouseCursors.text,
value: 1, value: 1,
onChanged: (int v) {}, onChanged: (int? v) {},
groupValue: 2, groupValue: 2,
), ),
), ),
...@@ -664,7 +662,7 @@ void main() { ...@@ -664,7 +662,7 @@ void main() {
await tester.pump(); await tester.pump();
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text); expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
// Test default cursor // Test default cursor
...@@ -678,7 +676,7 @@ void main() { ...@@ -678,7 +676,7 @@ void main() {
cursor: SystemMouseCursors.forbidden, cursor: SystemMouseCursors.forbidden,
child: Radio<int>( child: Radio<int>(
value: 1, value: 1,
onChanged: (int v) {}, onChanged: (int? v) {},
groupValue: 2, groupValue: 2,
), ),
), ),
...@@ -688,7 +686,7 @@ void main() { ...@@ -688,7 +686,7 @@ void main() {
), ),
); );
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click); expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click);
// Test default cursor when disabled // Test default cursor when disabled
await tester.pumpWidget( await tester.pumpWidget(
...@@ -711,6 +709,6 @@ void main() { ...@@ -711,6 +709,6 @@ void main() {
), ),
); );
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic); expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
}); });
} }
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -38,10 +36,10 @@ void main() { ...@@ -38,10 +36,10 @@ void main() {
expect(material.elevation, 2.0); expect(material.elevation, 2.0);
expect(material.shadowColor, null); expect(material.shadowColor, null);
expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(2.0))); expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(2.0)));
expect(material.textStyle.color, const Color(0xdd000000)); expect(material.textStyle!.color, const Color(0xdd000000));
expect(material.textStyle.fontFamily, 'Roboto'); expect(material.textStyle!.fontFamily, 'Roboto');
expect(material.textStyle.fontSize, 14); expect(material.textStyle!.fontSize, 14);
expect(material.textStyle.fontWeight, FontWeight.w500); expect(material.textStyle!.fontWeight, FontWeight.w500);
expect(material.type, MaterialType.button); expect(material.type, MaterialType.button);
final Offset center = tester.getCenter(find.byType(RaisedButton)); final Offset center = tester.getCenter(find.byType(RaisedButton));
...@@ -58,10 +56,10 @@ void main() { ...@@ -58,10 +56,10 @@ void main() {
expect(material.elevation, 8.0); expect(material.elevation, 8.0);
expect(material.shadowColor, null); expect(material.shadowColor, null);
expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(2.0))); expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(2.0)));
expect(material.textStyle.color, const Color(0xdd000000)); expect(material.textStyle!.color, const Color(0xdd000000));
expect(material.textStyle.fontFamily, 'Roboto'); expect(material.textStyle!.fontFamily, 'Roboto');
expect(material.textStyle.fontSize, 14); expect(material.textStyle!.fontSize, 14);
expect(material.textStyle.fontWeight, FontWeight.w500); expect(material.textStyle!.fontWeight, FontWeight.w500);
expect(material.type, MaterialType.button); expect(material.type, MaterialType.button);
// Disabled RaisedButton // Disabled RaisedButton
...@@ -83,10 +81,10 @@ void main() { ...@@ -83,10 +81,10 @@ void main() {
expect(material.elevation, 0.0); expect(material.elevation, 0.0);
expect(material.shadowColor, null); expect(material.shadowColor, null);
expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(2.0))); expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(2.0)));
expect(material.textStyle.color, const Color(0x61000000)); expect(material.textStyle!.color, const Color(0x61000000));
expect(material.textStyle.fontFamily, 'Roboto'); expect(material.textStyle!.fontFamily, 'Roboto');
expect(material.textStyle.fontSize, 14); expect(material.textStyle!.fontSize, 14);
expect(material.textStyle.fontWeight, FontWeight.w500); expect(material.textStyle!.fontWeight, FontWeight.w500);
expect(material.type, MaterialType.button); expect(material.type, MaterialType.button);
}); });
...@@ -198,7 +196,7 @@ void main() { ...@@ -198,7 +196,7 @@ void main() {
); );
Color textColor() { Color textColor() {
return tester.renderObject<RenderParagraph>(find.text('RaisedButton')).text.style.color; return tester.renderObject<RenderParagraph>(find.text('RaisedButton')).text.style!.color!;
} }
// Default, not disabled. // Default, not disabled.
...@@ -267,7 +265,7 @@ void main() { ...@@ -267,7 +265,7 @@ void main() {
), ),
); );
Color iconColor() => _iconStyle(tester, Icons.add).color; Color iconColor() => _iconStyle(tester, Icons.add).color!;
// Default, not disabled. // Default, not disabled.
expect(iconColor(), equals(defaultColor)); expect(iconColor(), equals(defaultColor));
...@@ -325,7 +323,7 @@ void main() { ...@@ -325,7 +323,7 @@ void main() {
); );
Color textColor() { Color textColor() {
return tester.renderObject<RenderParagraph>(find.text('RaisedButton')).text.style.color; return tester.renderObject<RenderParagraph>(find.text('RaisedButton')).text.style!.color!;
} }
// Disabled. // Disabled.
...@@ -338,7 +336,7 @@ void main() { ...@@ -338,7 +336,7 @@ void main() {
bool wasPressed; bool wasPressed;
Finder raisedButton; Finder raisedButton;
Widget buildFrame({ VoidCallback onPressed, VoidCallback onLongPress }) { Widget buildFrame({ VoidCallback? onPressed, VoidCallback? onLongPress }) {
return Directionality( return Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: RaisedButton( child: RaisedButton(
...@@ -454,7 +452,7 @@ void main() { ...@@ -454,7 +452,7 @@ void main() {
addTearDown(gesture.removePointer); addTearDown(gesture.removePointer);
await tester.pump(); await tester.pump();
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text); expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
...@@ -469,7 +467,7 @@ void main() { ...@@ -469,7 +467,7 @@ void main() {
), ),
); );
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text); expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
// Test default cursor // Test default cursor
await tester.pumpWidget( await tester.pumpWidget(
...@@ -484,7 +482,7 @@ void main() { ...@@ -484,7 +482,7 @@ void main() {
), ),
); );
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click); expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click);
// Test default cursor when disabled // Test default cursor when disabled
await tester.pumpWidget( await tester.pumpWidget(
...@@ -499,7 +497,7 @@ void main() { ...@@ -499,7 +497,7 @@ void main() {
), ),
); );
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic); expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
}); });
...@@ -735,5 +733,5 @@ TextStyle _iconStyle(WidgetTester tester, IconData icon) { ...@@ -735,5 +733,5 @@ TextStyle _iconStyle(WidgetTester tester, IconData icon) {
final RichText iconRichText = tester.widget<RichText>( final RichText iconRichText = tester.widget<RichText>(
find.descendant(of: find.byIcon(icon), matching: find.byType(RichText)), find.descendant(of: find.byIcon(icon), matching: find.byType(RichText)),
); );
return iconRichText.text.style; return iconRichText.text.style!;
} }
...@@ -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';
...@@ -886,8 +884,8 @@ void main() { ...@@ -886,8 +884,8 @@ void main() {
testWidgets('Range Slider onChangeEnd and onChangeStart are called on an interaction initiated by tap', (WidgetTester tester) async { testWidgets('Range Slider onChangeEnd and onChangeStart are called on an interaction initiated by tap', (WidgetTester tester) async {
RangeValues values = const RangeValues(30, 70); RangeValues values = const RangeValues(30, 70);
RangeValues startValues; RangeValues? startValues;
RangeValues endValues; RangeValues? endValues;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -934,18 +932,18 @@ void main() { ...@@ -934,18 +932,18 @@ void main() {
expect(startValues, null); expect(startValues, null);
expect(endValues, null); expect(endValues, null);
await tester.dragFrom(leftTarget, (bottomRight - topLeft) * 0.2); await tester.dragFrom(leftTarget, (bottomRight - topLeft) * 0.2);
expect(startValues.start, moreOrLessEquals(30, epsilon: 1)); expect(startValues!.start, moreOrLessEquals(30, epsilon: 1));
expect(startValues.end, moreOrLessEquals(70, epsilon: 1)); expect(startValues!.end, moreOrLessEquals(70, epsilon: 1));
expect(values.start, moreOrLessEquals(50, epsilon: 1)); expect(values.start, moreOrLessEquals(50, epsilon: 1));
expect(values.end, moreOrLessEquals(70, epsilon: 1)); expect(values.end, moreOrLessEquals(70, epsilon: 1));
expect(endValues.start, moreOrLessEquals(50, epsilon: 1)); expect(endValues!.start, moreOrLessEquals(50, epsilon: 1));
expect(endValues.end, moreOrLessEquals(70, epsilon: 1)); expect(endValues!.end, moreOrLessEquals(70, epsilon: 1));
}); });
testWidgets('Range Slider onChangeEnd and onChangeStart are called on an interaction initiated by drag', (WidgetTester tester) async { testWidgets('Range Slider onChangeEnd and onChangeStart are called on an interaction initiated by drag', (WidgetTester tester) async {
RangeValues values = const RangeValues(30, 70); RangeValues values = const RangeValues(30, 70);
RangeValues startValues; late RangeValues startValues;
RangeValues endValues; late RangeValues endValues;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -1029,14 +1027,14 @@ void main() { ...@@ -1029,14 +1027,14 @@ void main() {
} }
Widget _buildThemedApp({ Widget _buildThemedApp({
ThemeData theme, required ThemeData theme,
Color activeColor, Color? activeColor,
Color inactiveColor, Color? inactiveColor,
int divisions, int? divisions,
bool enabled = true, bool enabled = true,
}) { }) {
RangeValues values = const RangeValues(0.5, 0.75); RangeValues values = const RangeValues(0.5, 0.75);
final ValueChanged<RangeValues> onChanged = !enabled ? null : (RangeValues newValues) { final ValueChanged<RangeValues>? onChanged = !enabled ? null : (RangeValues newValues) {
values = newValues; values = newValues;
}; };
return MaterialApp( return MaterialApp(
...@@ -1287,12 +1285,12 @@ void main() { ...@@ -1287,12 +1285,12 @@ void main() {
RangeValues values = const RangeValues(0.5, 0.75); RangeValues values = const RangeValues(0.5, 0.75);
Widget buildApp({ Widget buildApp({
Color activeColor, Color? activeColor,
Color inactiveColor, Color? inactiveColor,
int divisions, int? divisions,
bool enabled = true, bool enabled = true,
}) { }) {
final ValueChanged<RangeValues> onChanged = !enabled ? null : (RangeValues newValues) { final ValueChanged<RangeValues>? onChanged = !enabled ? null : (RangeValues newValues) {
values = newValues; values = newValues;
}; };
return MaterialApp( return MaterialApp(
...@@ -1345,9 +1343,9 @@ void main() { ...@@ -1345,9 +1343,9 @@ void main() {
const Color fillColor = Color(0xf55f5f5f); const Color fillColor = Color(0xf55f5f5f);
Widget buildApp({ Widget buildApp({
Color activeColor, Color? activeColor,
Color inactiveColor, Color? inactiveColor,
int divisions, int? divisions,
bool enabled = true, bool enabled = true,
}) { }) {
final ValueChanged<RangeValues> onChanged = (RangeValues newValues) { final ValueChanged<RangeValues> onChanged = (RangeValues newValues) {
...@@ -1374,12 +1372,12 @@ void main() { ...@@ -1374,12 +1372,12 @@ void main() {
ElevatedButton( ElevatedButton(
child: const Text('Next'), child: const Text('Next'),
onPressed: () { onPressed: () {
Navigator.of(context).pushReplacement( Navigator.of(context)!.pushReplacement(
MaterialPageRoute<void>( MaterialPageRoute<void>(
builder: (BuildContext context) { builder: (BuildContext context) {
return ElevatedButton( return ElevatedButton(
child: const Text('Inner page'), child: const Text('Inner page'),
onPressed: () { Navigator.of(context).pop(); }, onPressed: () { Navigator.of(context)!.pop(); },
); );
}, },
), ),
...@@ -1943,7 +1941,7 @@ void main() { ...@@ -1943,7 +1941,7 @@ void main() {
await tester.pumpWidget(buildFrame(15)); await tester.pumpWidget(buildFrame(15));
await tester.pumpAndSettle(); // Finish the animation. await tester.pumpAndSettle(); // Finish the animation.
Rect activeTrackRect; late Rect activeTrackRect;
expect(renderObject, paints..something((Symbol method, List<dynamic> arguments) { expect(renderObject, paints..something((Symbol method, List<dynamic> arguments) {
if (method != #drawRect) if (method != #drawRect)
return false; return false;
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -443,7 +441,7 @@ void main() { ...@@ -443,7 +441,7 @@ void main() {
bool wasPressed; bool wasPressed;
Finder rawMaterialButton; Finder rawMaterialButton;
Widget buildFrame({ VoidCallback onPressed, VoidCallback onLongPress }) { Widget buildFrame({ VoidCallback? onPressed, VoidCallback? onLongPress }) {
return Directionality( return Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: RawMaterialButton( child: RawMaterialButton(
...@@ -593,7 +591,7 @@ void main() { ...@@ -593,7 +591,7 @@ void main() {
await tester.pump(); await tester.pump();
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text); expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
// Test default cursor // Test default cursor
await tester.pumpWidget( await tester.pumpWidget(
...@@ -608,7 +606,7 @@ void main() { ...@@ -608,7 +606,7 @@ void main() {
), ),
); );
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click); expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click);
// Test default cursor when disabled // Test default cursor when disabled
await tester.pumpWidget( await tester.pumpWidget(
...@@ -623,6 +621,6 @@ void main() { ...@@ -623,6 +621,6 @@ void main() {
), ),
); );
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic); expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
}); });
} }
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:async'; import 'dart:async';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -360,35 +358,6 @@ void main() { ...@@ -360,35 +358,6 @@ void main() {
expect(completed2, true); expect(completed2, true);
}); });
testWidgets('RefreshIndicator - onRefresh asserts', (WidgetTester tester) async {
refreshCalled = false;
await tester.pumpWidget(
MaterialApp(
home: RefreshIndicator(
onRefresh: () {
refreshCalled = true;
return null; // Missing a returned Future value here, should cause framework to throw.
},
child: ListView(
physics: const AlwaysScrollableScrollPhysics(),
children: <String>['A', 'B', 'C', 'D', 'E', 'F'].map<Widget>((String item) {
return SizedBox(
height: 200.0,
child: Text(item),
);
}).toList(),
),
),
),
);
await tester.fling(find.text('A'), const Offset(0.0, 300.0), 1000.0);
await tester.pump();
await tester.pump(const Duration(seconds: 1)); // finish the scroll animation
expect(refreshCalled, true);
expect(tester.takeException(), isFlutterError);
});
testWidgets('Refresh starts while scroll view moves back to 0.0 after overscroll', (WidgetTester tester) async { testWidgets('Refresh starts while scroll view moves back to 0.0 after overscroll', (WidgetTester tester) async {
refreshCalled = false; refreshCalled = false;
double lastScrollOffset; double lastScrollOffset;
...@@ -458,31 +427,6 @@ void main() { ...@@ -458,31 +427,6 @@ void main() {
expect(layoutCount, 1); expect(layoutCount, 1);
}); });
testWidgets('strokeWidth cannot be null in RefreshIndicator', (WidgetTester tester) async {
try {
await tester.pumpWidget(
MaterialApp(
home: RefreshIndicator(
onRefresh: () async {},
strokeWidth: null,
child: ListView(
physics: const AlwaysScrollableScrollPhysics(),
children: <String>['A', 'B', 'C', 'D', 'E', 'F'].map<Widget>((String item) {
return SizedBox(
height: 200.0,
child: Text(item),
);
}).toList(),
),
),
)
);
} on AssertionError catch(_) {
return;
}
fail('The assertion was not thrown when strokeWidth was null');
});
testWidgets('RefreshIndicator responds to strokeWidth', (WidgetTester tester) async { testWidgets('RefreshIndicator responds to strokeWidth', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart' show DragStartBehavior; import 'package:flutter/gestures.dart' show DragStartBehavior;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -298,7 +296,7 @@ void main() { ...@@ -298,7 +296,7 @@ void main() {
expect(renderBox.size.height, equals(appBarHeight)); expect(renderBox.size.height, equals(appBarHeight));
}); });
Widget _buildStatusBarTestApp(TargetPlatform platform) { Widget _buildStatusBarTestApp(TargetPlatform? platform) {
return MaterialApp( return MaterialApp(
theme: ThemeData(platform: platform), theme: ThemeData(platform: platform),
home: MediaQuery( home: MediaQuery(
...@@ -357,7 +355,7 @@ void main() { ...@@ -357,7 +355,7 @@ void main() {
builder: (BuildContext context) { builder: (BuildContext context) {
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
Scaffold.of(context).showBottomSheet<void>((BuildContext context) { Scaffold.of(context)!.showBottomSheet<void>((BuildContext context) {
return Container( return Container(
key: sheetKey, key: sheetKey,
color: Colors.blue[500], color: Colors.blue[500],
...@@ -519,7 +517,7 @@ void main() { ...@@ -519,7 +517,7 @@ void main() {
}; };
await tester.pumpWidget(MaterialApp(routes: routes)); await tester.pumpWidget(MaterialApp(routes: routes));
Navigator.pushNamed(rootKey.currentContext, '/scaffold'); Navigator.pushNamed(rootKey.currentContext!, '/scaffold');
await tester.pump(); await tester.pump();
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
...@@ -671,9 +669,9 @@ void main() { ...@@ -671,9 +669,9 @@ void main() {
testWidgets('body size with extendBody', (WidgetTester tester) async { testWidgets('body size with extendBody', (WidgetTester tester) async {
final Key bodyKey = UniqueKey(); final Key bodyKey = UniqueKey();
double mediaQueryBottom; late double mediaQueryBottom;
Widget buildFrame({ bool extendBody, bool resizeToAvoidBottomInset, double viewInsetBottom = 0.0 }) { Widget buildFrame({ required bool extendBody, bool? resizeToAvoidBottomInset, double viewInsetBottom = 0.0 }) {
return Directionality( return Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: MediaQuery( child: MediaQuery(
...@@ -685,7 +683,7 @@ void main() { ...@@ -685,7 +683,7 @@ void main() {
extendBody: extendBody, extendBody: extendBody,
body: Builder( body: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
mediaQueryBottom = MediaQuery.of(context).padding.bottom; mediaQueryBottom = MediaQuery.of(context)!.padding.bottom;
return Container(key: bodyKey); return Container(key: bodyKey);
}, },
), ),
...@@ -732,10 +730,10 @@ void main() { ...@@ -732,10 +730,10 @@ void main() {
const double appBarHeight = 100; const double appBarHeight = 100;
const double windowPaddingTop = 24; const double windowPaddingTop = 24;
bool fixedHeightAppBar; late bool fixedHeightAppBar;
double mediaQueryTop; late double mediaQueryTop;
Widget buildFrame({ bool extendBodyBehindAppBar, bool hasAppBar }) { Widget buildFrame({ required bool extendBodyBehindAppBar, required bool hasAppBar }) {
return Directionality( return Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: MediaQuery( child: MediaQuery(
...@@ -758,7 +756,7 @@ void main() { ...@@ -758,7 +756,7 @@ void main() {
), ),
body: Builder( body: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
mediaQueryTop = MediaQuery.of(context).padding.top; mediaQueryTop = MediaQuery.of(context)!.padding.top;
return Container(key: bodyKey); return Container(key: bodyKey);
} }
), ),
...@@ -1224,7 +1222,7 @@ void main() { ...@@ -1224,7 +1222,7 @@ void main() {
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
ScaffoldGeometry geometry = listenerState.cache.value; ScaffoldGeometry geometry = listenerState.cache.value;
final Rect transitioningFabRect = geometry.floatingActionButtonArea; final Rect transitioningFabRect = geometry.floatingActionButtonArea!;
final double transitioningRotation = tester.widget<RotationTransition>( final double transitioningRotation = tester.widget<RotationTransition>(
find.byType(RotationTransition), find.byType(RotationTransition),
...@@ -1249,17 +1247,17 @@ void main() { ...@@ -1249,17 +1247,17 @@ void main() {
); );
expect( expect(
geometry.floatingActionButtonArea.center, geometry.floatingActionButtonArea!.center,
transitioningFabRect.center, transitioningFabRect.center,
); );
expect( expect(
geometry.floatingActionButtonArea.width, geometry.floatingActionButtonArea!.width,
greaterThan(transitioningFabRect.width), greaterThan(transitioningFabRect.width),
); );
expect( expect(
geometry.floatingActionButtonArea.height, geometry.floatingActionButtonArea!.height,
greaterThan(transitioningFabRect.height), greaterThan(transitioningFabRect.height),
); );
}); });
...@@ -1672,12 +1670,12 @@ void main() { ...@@ -1672,12 +1670,12 @@ void main() {
}); });
testWidgets('End drawer does not open with a drag gesture when it is disabled', (WidgetTester tester) async { testWidgets('End drawer does not open with a drag gesture when it is disabled', (WidgetTester tester) async {
double screenWidth; late double screenWidth;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Builder( home: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
screenWidth = MediaQuery.of(context).size.width; screenWidth = MediaQuery.of(context)!.size.width;
return Scaffold( return Scaffold(
endDrawer: const Drawer( endDrawer: const Drawer(
child: Text('Drawer'), child: Text('Drawer'),
...@@ -1746,7 +1744,7 @@ void main() { ...@@ -1746,7 +1744,7 @@ void main() {
// Regression test for https://github.com/flutter/flutter/issues/20295 // Regression test for https://github.com/flutter/flutter/issues/20295
final Key bodyKey = UniqueKey(); final Key bodyKey = UniqueKey();
Widget buildFrame(bool innerResizeToAvoidBottomInset, bool outerResizeToAvoidBottomInset) { Widget buildFrame(bool? innerResizeToAvoidBottomInset, bool? outerResizeToAvoidBottomInset) {
return Directionality( return Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: MediaQuery( child: MediaQuery(
...@@ -1810,10 +1808,10 @@ void main() { ...@@ -1810,10 +1808,10 @@ void main() {
), ),
), ),
); );
FlutterError error; late FlutterError error;
try { try {
key.currentState.showBottomSheet<void>((BuildContext context) { key.currentState!.showBottomSheet<void>((BuildContext context) {
final ThemeData themeData = Theme.of(context); final ThemeData themeData = Theme.of(context)!;
return Container( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border(top: BorderSide(color: themeData.disabledColor)) border: Border(top: BorderSide(color: themeData.disabledColor))
...@@ -1872,7 +1870,7 @@ void main() { ...@@ -1872,7 +1870,7 @@ void main() {
), ),
), ),
); );
key.currentState.showBottomSheet<void>((_) => Container()); key.currentState!.showBottomSheet<void>((_) => Container());
await tester.tap(find.byKey(buttonKey)); await tester.tap(find.byKey(buttonKey));
await tester.pump(); await tester.pump();
expect(errors, isNotEmpty); expect(errors, isNotEmpty);
...@@ -1902,7 +1900,7 @@ void main() { ...@@ -1902,7 +1900,7 @@ void main() {
MaterialApp( MaterialApp(
home: Builder( home: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
Scaffold.of(context).showBottomSheet<void>((BuildContext context) { Scaffold.of(context)!.showBottomSheet<void>((BuildContext context) {
return Container(); return Container();
}); });
return Container(); return Container();
...@@ -1970,7 +1968,7 @@ void main() { ...@@ -1970,7 +1968,7 @@ void main() {
}); });
testWidgets('Call to Scaffold.geometryOf() without context', (WidgetTester tester) async { testWidgets('Call to Scaffold.geometryOf() without context', (WidgetTester tester) async {
ValueListenable<ScaffoldGeometry> geometry; ValueListenable<ScaffoldGeometry>? geometry;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Builder( home: Builder(
...@@ -2036,7 +2034,7 @@ void main() { ...@@ -2036,7 +2034,7 @@ void main() {
}); });
testWidgets('ScaffoldMessenger.of can return null', (WidgetTester tester) async { testWidgets('ScaffoldMessenger.of can return null', (WidgetTester tester) async {
ScaffoldMessengerState scaffoldMessenger; ScaffoldMessengerState? scaffoldMessenger;
const Key tapTarget = Key('tap-target'); const Key tapTarget = Key('tap-target');
await tester.pumpWidget(Directionality( await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -2070,7 +2068,7 @@ void main() { ...@@ -2070,7 +2068,7 @@ void main() {
const Key tapTarget = Key('tap-target'); const Key tapTarget = Key('tap-target');
final List<dynamic> exceptions = <dynamic>[]; final List<dynamic> exceptions = <dynamic>[];
final FlutterExceptionHandler oldHandler = FlutterError.onError; final FlutterExceptionHandler? oldHandler = FlutterError.onError;
FlutterError.onError = (FlutterErrorDetails details) { FlutterError.onError = (FlutterErrorDetails details) {
exceptions.add(details.exception); exceptions.add(details.exception);
}; };
...@@ -2161,8 +2159,8 @@ class _GeometryListenerState extends State<_GeometryListener> { ...@@ -2161,8 +2159,8 @@ class _GeometryListenerState extends State<_GeometryListener> {
} }
int numNotifications = 0; int numNotifications = 0;
ValueListenable<ScaffoldGeometry> geometryListenable; ValueListenable<ScaffoldGeometry>? geometryListenable;
_GeometryCachePainter cache; late _GeometryCachePainter cache;
@override @override
void didChangeDependencies() { void didChangeDependencies() {
...@@ -2172,11 +2170,11 @@ class _GeometryListenerState extends State<_GeometryListener> { ...@@ -2172,11 +2170,11 @@ class _GeometryListenerState extends State<_GeometryListener> {
return; return;
if (geometryListenable != null) if (geometryListenable != null)
geometryListenable.removeListener(onGeometryChanged); geometryListenable!.removeListener(onGeometryChanged);
geometryListenable = newListenable; geometryListenable = newListenable;
geometryListenable.addListener(onGeometryChanged); geometryListenable!.addListener(onGeometryChanged);
cache = _GeometryCachePainter(geometryListenable); cache = _GeometryCachePainter(geometryListenable!);
} }
void onGeometryChanged() { void onGeometryChanged() {
...@@ -2192,7 +2190,7 @@ class _GeometryCachePainter extends CustomPainter { ...@@ -2192,7 +2190,7 @@ class _GeometryCachePainter extends CustomPainter {
final ValueListenable<ScaffoldGeometry> geometryListenable; final ValueListenable<ScaffoldGeometry> geometryListenable;
ScaffoldGeometry value; late ScaffoldGeometry value;
@override @override
void paint(Canvas canvas, Size size) { void paint(Canvas canvas, Size size) {
value = geometryListenable.value; value = geometryListenable.value;
...@@ -2206,7 +2204,7 @@ class _GeometryCachePainter extends CustomPainter { ...@@ -2206,7 +2204,7 @@ class _GeometryCachePainter extends CustomPainter {
class _CustomPageRoute<T> extends PageRoute<T> { class _CustomPageRoute<T> extends PageRoute<T> {
_CustomPageRoute({ _CustomPageRoute({
@required this.builder, required this.builder,
RouteSettings settings = const RouteSettings(), RouteSettings settings = const RouteSettings(),
this.maintainState = true, this.maintainState = true,
bool fullscreenDialog = false, bool fullscreenDialog = false,
...@@ -2219,10 +2217,10 @@ class _CustomPageRoute<T> extends PageRoute<T> { ...@@ -2219,10 +2217,10 @@ class _CustomPageRoute<T> extends PageRoute<T> {
Duration get transitionDuration => const Duration(milliseconds: 300); Duration get transitionDuration => const Duration(milliseconds: 300);
@override @override
Color get barrierColor => null; Color? get barrierColor => null;
@override @override
String get barrierLabel => null; String? get barrierLabel => null;
@override @override
final bool maintainState; final bool maintainState;
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -12,7 +10,7 @@ import '../rendering/mock_canvas.dart'; ...@@ -12,7 +10,7 @@ import '../rendering/mock_canvas.dart';
Widget _buildSingleChildScrollViewWithScrollbar({ Widget _buildSingleChildScrollViewWithScrollbar({
TextDirection textDirection = TextDirection.ltr, TextDirection textDirection = TextDirection.ltr,
EdgeInsets padding = EdgeInsets.zero, EdgeInsets padding = EdgeInsets.zero,
Widget child, Widget? child,
}) { }) {
return Directionality( return Directionality(
textDirection: textDirection, textDirection: textDirection,
......
...@@ -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/material.dart'; import 'package:flutter/material.dart';
...@@ -13,20 +11,18 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -13,20 +11,18 @@ import 'package:flutter_test/flutter_test.dart';
import '../rendering/mock_canvas.dart'; import '../rendering/mock_canvas.dart';
class TestCanvas implements Canvas { class TestCanvas implements Canvas {
TestCanvas([this.invocations]); final List<Invocation> invocations = <Invocation>[];
final List<Invocation> invocations;
@override @override
void noSuchMethod(Invocation invocation) { void noSuchMethod(Invocation invocation) {
invocations?.add(invocation); invocations.add(invocation);
} }
} }
Widget _buildBoilerplate({ Widget _buildBoilerplate({
TextDirection textDirection = TextDirection.ltr, TextDirection textDirection = TextDirection.ltr,
EdgeInsets padding = EdgeInsets.zero, EdgeInsets padding = EdgeInsets.zero,
Widget child, required Widget child,
}) { }) {
return Directionality( return Directionality(
textDirection: textDirection, textDirection: textDirection,
...@@ -67,15 +63,15 @@ void main() { ...@@ -67,15 +63,15 @@ void main() {
), ),
); );
SchedulerBinding.instance.debugAssertNoTransientCallbacks('Building a list with a scrollbar triggered an animation.'); SchedulerBinding.instance!.debugAssertNoTransientCallbacks('Building a list with a scrollbar triggered an animation.');
await tester.tap(find.byType(ListView)); await tester.tap(find.byType(ListView));
SchedulerBinding.instance.debugAssertNoTransientCallbacks('Tapping a block with a scrollbar triggered an animation.'); SchedulerBinding.instance!.debugAssertNoTransientCallbacks('Tapping a block with a scrollbar triggered an animation.');
await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200));
await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200));
await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200));
await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200));
await tester.drag(find.byType(ListView), const Offset(0.0, -10.0)); await tester.drag(find.byType(ListView), const Offset(0.0, -10.0));
expect(SchedulerBinding.instance.transientCallbackCount, greaterThan(0)); expect(SchedulerBinding.instance!.transientCallbackCount, greaterThan(0));
await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200));
await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200));
await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200));
...@@ -116,12 +112,11 @@ void main() { ...@@ -116,12 +112,11 @@ void main() {
); );
scrollPainter.update(metrics, AxisDirection.down); scrollPainter.update(metrics, AxisDirection.down);
final List<Invocation> invocations = <Invocation>[]; final TestCanvas canvas = TestCanvas();
final TestCanvas canvas = TestCanvas(invocations);
scrollPainter.paint(canvas, const Size(10.0, 100.0)); scrollPainter.paint(canvas, const Size(10.0, 100.0));
// Scrollbar is not supposed to draw anything if there isn't enough content. // Scrollbar is not supposed to draw anything if there isn't enough content.
expect(invocations.isEmpty, isTrue); expect(canvas.invocations.isEmpty, isTrue);
}); });
testWidgets('Adaptive scrollbar', (WidgetTester tester) async { testWidgets('Adaptive scrollbar', (WidgetTester tester) async {
...@@ -174,7 +169,7 @@ void main() { ...@@ -174,7 +169,7 @@ void main() {
testWidgets('Scrollbar passes controller to CupertinoScrollbar', (WidgetTester tester) async { testWidgets('Scrollbar passes controller to CupertinoScrollbar', (WidgetTester tester) async {
final ScrollController controller = ScrollController(); final ScrollController controller = ScrollController();
Widget viewWithScroll(TargetPlatform platform) { Widget viewWithScroll(TargetPlatform? platform) {
return _buildBoilerplate( return _buildBoilerplate(
child: Theme( child: Theme(
data: ThemeData( data: ThemeData(
...@@ -517,7 +512,7 @@ void main() { ...@@ -517,7 +512,7 @@ void main() {
testWidgets('Scrollbar respects thickness and radius', (WidgetTester tester) async { testWidgets('Scrollbar respects thickness and radius', (WidgetTester tester) async {
final ScrollController controller = ScrollController(); final ScrollController controller = ScrollController();
Widget viewWithScroll({Radius radius}) { Widget viewWithScroll({Radius? radius}) {
return _buildBoilerplate( return _buildBoilerplate(
child: Theme( child: Theme(
data: ThemeData(), data: ThemeData(),
......
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