mirror of
https://github.com/flutter/flutter
synced 2024-10-13 19:52:53 +00:00
Migrate More Material Tests (#67482)
This commit is contained in:
parent
bd2ec40c08
commit
727cee6d87
|
@ -129,7 +129,7 @@ class Radio<T> extends StatefulWidget {
|
|||
///
|
||||
/// This radio button is considered selected if its [value] matches the
|
||||
/// [groupValue].
|
||||
final T groupValue;
|
||||
final T? groupValue;
|
||||
|
||||
/// Called when the user selects this radio button.
|
||||
///
|
||||
|
|
|
@ -335,7 +335,7 @@ class RadioListTile<T> extends StatelessWidget {
|
|||
///
|
||||
/// This radio button is considered selected if its [value] matches the
|
||||
/// [groupValue].
|
||||
final T groupValue;
|
||||
final T? groupValue;
|
||||
|
||||
/// Called when the user selects this radio button.
|
||||
///
|
||||
|
|
|
@ -175,7 +175,7 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
|
|||
late Animation<Color?> _valueColor;
|
||||
|
||||
_RefreshIndicatorMode? _mode;
|
||||
Future<void>? _pendingRefreshFuture;
|
||||
late Future<void> _pendingRefreshFuture;
|
||||
bool? _isIndicatorAtTop;
|
||||
double? _dragOffset;
|
||||
|
||||
|
@ -406,7 +406,7 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
|
|||
/// 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
|
||||
/// 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 &&
|
||||
_mode != _RefreshIndicatorMode.snap) {
|
||||
if (_mode == null)
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -298,8 +296,8 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('Determinate CircularProgressIndicator stops the animator', (WidgetTester tester) async {
|
||||
double progressValue;
|
||||
StateSetter setState;
|
||||
double? progressValue;
|
||||
late StateSetter setState;
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
@ -14,7 +12,7 @@ import 'package:flutter/material.dart';
|
|||
|
||||
import '../widgets/semantics_tester.dart';
|
||||
|
||||
Widget wrap({Widget child}) {
|
||||
Widget wrap({Widget? child}) {
|
||||
return MediaQuery(
|
||||
data: const MediaQueryData(),
|
||||
child: Directionality(
|
||||
|
@ -28,7 +26,7 @@ void main() {
|
|||
testWidgets('RadioListTile should initialize according to groupValue',
|
||||
(WidgetTester tester) async {
|
||||
final List<int> values = <int>[0, 1, 2];
|
||||
int selectedValue;
|
||||
int? selectedValue;
|
||||
// Constructor parameters are required for [RadioListTile], but they are
|
||||
// irrelevant when searching with [find.byType].
|
||||
final Type radioListTileType = const RadioListTile<int>(
|
||||
|
@ -53,7 +51,7 @@ void main() {
|
|||
body: ListView.builder(
|
||||
itemCount: values.length,
|
||||
itemBuilder: (BuildContext context, int index) => RadioListTile<int>(
|
||||
onChanged: (int value) {
|
||||
onChanged: (int? value) {
|
||||
setState(() {
|
||||
selectedValue = value;
|
||||
});
|
||||
|
@ -89,7 +87,7 @@ void main() {
|
|||
testWidgets('RadioListTile simple control test', (WidgetTester tester) async {
|
||||
final Key key = UniqueKey();
|
||||
final Key titleKey = UniqueKey();
|
||||
final List<int> log = <int>[];
|
||||
final List<int?> log = <int?>[];
|
||||
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
|
@ -160,7 +158,7 @@ void main() {
|
|||
|
||||
testWidgets('RadioListTile control tests', (WidgetTester tester) async {
|
||||
final List<int> values = <int>[0, 1, 2];
|
||||
int selectedValue;
|
||||
int? selectedValue;
|
||||
// Constructor parameters are required for [Radio], but they are irrelevant
|
||||
// when searching with [find.byType].
|
||||
final Type radioType = const Radio<int>(
|
||||
|
@ -178,7 +176,7 @@ void main() {
|
|||
body: ListView.builder(
|
||||
itemCount: values.length,
|
||||
itemBuilder: (BuildContext context, int index) => RadioListTile<int>(
|
||||
onChanged: (int value) {
|
||||
onChanged: (int? value) {
|
||||
log.add(value);
|
||||
setState(() {
|
||||
selectedValue = value;
|
||||
|
@ -228,7 +226,7 @@ void main() {
|
|||
testWidgets('Selected RadioListTile should not trigger onChanged', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/30311
|
||||
final List<int> values = <int>[0, 1, 2];
|
||||
int selectedValue;
|
||||
int? selectedValue;
|
||||
// Constructor parameters are required for [Radio], but they are irrelevant
|
||||
// when searching with [find.byType].
|
||||
final Type radioType = const Radio<int>(
|
||||
|
@ -246,7 +244,7 @@ void main() {
|
|||
body: ListView.builder(
|
||||
itemCount: values.length,
|
||||
itemBuilder: (BuildContext context, int index) => RadioListTile<int>(
|
||||
onChanged: (int value) {
|
||||
onChanged: (int? value) {
|
||||
log.add(value);
|
||||
setState(() {
|
||||
selectedValue = value;
|
||||
|
@ -280,7 +278,7 @@ void main() {
|
|||
testWidgets('Selected RadioListTile should trigger onChanged when toggleable',
|
||||
(WidgetTester tester) async {
|
||||
final List<int> values = <int>[0, 1, 2];
|
||||
int selectedValue;
|
||||
int? selectedValue;
|
||||
// Constructor parameters are required for [Radio], but they are irrelevant
|
||||
// when searching with [find.byType].
|
||||
final Type radioType = const Radio<int>(
|
||||
|
@ -299,7 +297,7 @@ void main() {
|
|||
itemCount: values.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return RadioListTile<int>(
|
||||
onChanged: (int value) {
|
||||
onChanged: (int? value) {
|
||||
log.add(value);
|
||||
setState(() {
|
||||
selectedValue = value;
|
||||
|
@ -325,16 +323,16 @@ void main() {
|
|||
|
||||
await tester.tap(find.text('0'));
|
||||
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.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 {
|
||||
final Key key = UniqueKey();
|
||||
final List<int> log = <int>[];
|
||||
final List<int?> log = <int?>[];
|
||||
|
||||
await tester.pumpWidget(Material(
|
||||
child: Center(
|
||||
|
@ -367,7 +365,7 @@ void main() {
|
|||
|
||||
await tester.tap(find.byKey(key));
|
||||
|
||||
expect(log, equals(<int>[null]));
|
||||
expect(log, equals(<int?>[null]));
|
||||
log.clear();
|
||||
|
||||
await tester.pumpWidget(Material(
|
||||
|
@ -395,7 +393,7 @@ void main() {
|
|||
child: RadioListTile<int>(
|
||||
value: 1,
|
||||
groupValue: 2,
|
||||
onChanged: (int i) {},
|
||||
onChanged: (int? i) {},
|
||||
title: const Text('Title'),
|
||||
),
|
||||
),
|
||||
|
@ -431,7 +429,7 @@ void main() {
|
|||
child: RadioListTile<int>(
|
||||
value: 2,
|
||||
groupValue: 2,
|
||||
onChanged: (int i) {},
|
||||
onChanged: (int? i) {},
|
||||
title: const Text('Title'),
|
||||
),
|
||||
),
|
||||
|
@ -540,7 +538,7 @@ void main() {
|
|||
final SemanticsTester semantics = SemanticsTester(tester);
|
||||
final Key key = UniqueKey();
|
||||
dynamic semanticEvent;
|
||||
int radioValue = 2;
|
||||
int? radioValue = 2;
|
||||
SystemChannels.accessibility.setMockMessageHandler((dynamic message) async {
|
||||
semanticEvent = message;
|
||||
});
|
||||
|
@ -551,7 +549,7 @@ void main() {
|
|||
key: key,
|
||||
value: 1,
|
||||
groupValue: radioValue,
|
||||
onChanged: (int i) {
|
||||
onChanged: (int? i) {
|
||||
radioValue = i;
|
||||
},
|
||||
title: const Text('Title'),
|
||||
|
@ -566,10 +564,10 @@ void main() {
|
|||
expect(radioValue, 1);
|
||||
expect(semanticEvent, <String, dynamic>{
|
||||
'type': 'tap',
|
||||
'nodeId': object.debugSemantics.id,
|
||||
'nodeId': object.debugSemantics!.id,
|
||||
'data': <String, dynamic>{},
|
||||
});
|
||||
expect(object.debugSemantics.getSemanticsData().hasAction(SemanticsAction.tap), true);
|
||||
expect(object.debugSemantics!.getSemanticsData().hasAction(SemanticsAction.tap), true);
|
||||
|
||||
semantics.dispose();
|
||||
SystemChannels.accessibility.setMockMessageHandler(null);
|
||||
|
@ -591,7 +589,7 @@ void main() {
|
|||
);
|
||||
|
||||
await tester.pump();
|
||||
expect(Focus.of(childKey.currentContext, nullOk: true).hasPrimaryFocus, isTrue);
|
||||
expect(Focus.of(childKey.currentContext!)!.hasPrimaryFocus, isTrue);
|
||||
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
|
@ -606,6 +604,6 @@ void main() {
|
|||
);
|
||||
|
||||
await tester.pump();
|
||||
expect(Focus.of(childKey.currentContext, nullOk: true).hasPrimaryFocus, isFalse);
|
||||
expect(Focus.of(childKey.currentContext!)!.hasPrimaryFocus, isFalse);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
@ -18,7 +16,7 @@ import '../widgets/semantics_tester.dart';
|
|||
void main() {
|
||||
testWidgets('Radio control test', (WidgetTester tester) async {
|
||||
final Key key = UniqueKey();
|
||||
final List<int> log = <int>[];
|
||||
final List<int?> log = <int?>[];
|
||||
|
||||
await tester.pumpWidget(Material(
|
||||
child: Center(
|
||||
|
@ -70,7 +68,7 @@ void main() {
|
|||
|
||||
testWidgets('Radio can be toggled when toggleable is set', (WidgetTester tester) async {
|
||||
final Key key = UniqueKey();
|
||||
final List<int> log = <int>[];
|
||||
final List<int?> log = <int?>[];
|
||||
|
||||
await tester.pumpWidget(Material(
|
||||
child: Center(
|
||||
|
@ -103,7 +101,7 @@ void main() {
|
|||
|
||||
await tester.tap(find.byKey(key));
|
||||
|
||||
expect(log, equals(<int>[null]));
|
||||
expect(log, equals(<int?>[null]));
|
||||
log.clear();
|
||||
|
||||
await tester.pumpWidget(Material(
|
||||
|
@ -136,7 +134,7 @@ void main() {
|
|||
key: key1,
|
||||
groupValue: true,
|
||||
value: true,
|
||||
onChanged: (bool newValue) { },
|
||||
onChanged: (bool? newValue) { },
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -158,7 +156,7 @@ void main() {
|
|||
key: key2,
|
||||
groupValue: true,
|
||||
value: true,
|
||||
onChanged: (bool newValue) { },
|
||||
onChanged: (bool? newValue) { },
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -177,7 +175,7 @@ void main() {
|
|||
child: Radio<int>(
|
||||
value: 1,
|
||||
groupValue: 2,
|
||||
onChanged: (int i) { },
|
||||
onChanged: (int? i) { },
|
||||
),
|
||||
));
|
||||
|
||||
|
@ -203,7 +201,7 @@ void main() {
|
|||
child: Radio<int>(
|
||||
value: 2,
|
||||
groupValue: 2,
|
||||
onChanged: (int i) { },
|
||||
onChanged: (int? i) { },
|
||||
),
|
||||
));
|
||||
|
||||
|
@ -293,7 +291,7 @@ void main() {
|
|||
final SemanticsTester semantics = SemanticsTester(tester);
|
||||
final Key key = UniqueKey();
|
||||
dynamic semanticEvent;
|
||||
int radioValue = 2;
|
||||
int? radioValue = 2;
|
||||
SystemChannels.accessibility.setMockMessageHandler((dynamic message) async {
|
||||
semanticEvent = message;
|
||||
});
|
||||
|
@ -303,7 +301,7 @@ void main() {
|
|||
key: key,
|
||||
value: 1,
|
||||
groupValue: radioValue,
|
||||
onChanged: (int i) {
|
||||
onChanged: (int? i) {
|
||||
radioValue = i;
|
||||
},
|
||||
),
|
||||
|
@ -315,10 +313,10 @@ void main() {
|
|||
expect(radioValue, 1);
|
||||
expect(semanticEvent, <String, dynamic>{
|
||||
'type': 'tap',
|
||||
'nodeId': object.debugSemantics.id,
|
||||
'nodeId': object.debugSemantics!.id,
|
||||
'data': <String, dynamic>{},
|
||||
});
|
||||
expect(object.debugSemantics.getSemanticsData().hasAction(SemanticsAction.tap), true);
|
||||
expect(object.debugSemantics!.getSemanticsData().hasAction(SemanticsAction.tap), true);
|
||||
|
||||
semantics.dispose();
|
||||
SystemChannels.accessibility.setMockMessageHandler(null);
|
||||
|
@ -342,7 +340,7 @@ void main() {
|
|||
key: radioKey,
|
||||
value: 1,
|
||||
groupValue: 1,
|
||||
onChanged: (int value) { },
|
||||
onChanged: (int? value) { },
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -361,7 +359,7 @@ void main() {
|
|||
testWidgets('Radio is focusable and has correct focus color', (WidgetTester tester) async {
|
||||
final FocusNode focusNode = FocusNode(debugLabel: 'Radio');
|
||||
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||
int groupValue = 0;
|
||||
int? groupValue = 0;
|
||||
const Key radioKey = Key('radio');
|
||||
Widget buildApp({bool enabled = true}) {
|
||||
return MaterialApp(
|
||||
|
@ -375,7 +373,7 @@ void main() {
|
|||
child: Radio<int>(
|
||||
key: radioKey,
|
||||
value: 0,
|
||||
onChanged: enabled ? (int newValue) {
|
||||
onChanged: enabled ? (int? newValue) {
|
||||
setState(() {
|
||||
groupValue = newValue;
|
||||
});
|
||||
|
@ -439,7 +437,7 @@ void main() {
|
|||
|
||||
testWidgets('Radio can be hovered and has correct hover color', (WidgetTester tester) async {
|
||||
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||
int groupValue = 0;
|
||||
int? groupValue = 0;
|
||||
const Key radioKey = Key('radio');
|
||||
Widget buildApp({bool enabled = true}) {
|
||||
return MaterialApp(
|
||||
|
@ -453,7 +451,7 @@ void main() {
|
|||
child: Radio<int>(
|
||||
key: radioKey,
|
||||
value: 0,
|
||||
onChanged: enabled ? (int newValue) {
|
||||
onChanged: enabled ? (int? newValue) {
|
||||
setState(() {
|
||||
groupValue = newValue;
|
||||
});
|
||||
|
@ -519,7 +517,7 @@ void main() {
|
|||
|
||||
testWidgets('Radio can be controlled by keyboard shortcuts', (WidgetTester tester) async {
|
||||
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||
int groupValue = 1;
|
||||
int? groupValue = 1;
|
||||
const Key radioKey0 = Key('radio0');
|
||||
const Key radioKey1 = Key('radio1');
|
||||
const Key radioKey2 = Key('radio2');
|
||||
|
@ -538,7 +536,7 @@ void main() {
|
|||
Radio<int>(
|
||||
key: radioKey0,
|
||||
value: 0,
|
||||
onChanged: enabled ? (int newValue) {
|
||||
onChanged: enabled ? (int? newValue) {
|
||||
setState(() {
|
||||
groupValue = newValue;
|
||||
});
|
||||
|
@ -550,7 +548,7 @@ void main() {
|
|||
Radio<int>(
|
||||
key: radioKey1,
|
||||
value: 1,
|
||||
onChanged: enabled ? (int newValue) {
|
||||
onChanged: enabled ? (int? newValue) {
|
||||
setState(() {
|
||||
groupValue = newValue;
|
||||
});
|
||||
|
@ -561,7 +559,7 @@ void main() {
|
|||
Radio<int>(
|
||||
key: radioKey2,
|
||||
value: 2,
|
||||
onChanged: enabled ? (int newValue) {
|
||||
onChanged: enabled ? (int? newValue) {
|
||||
setState(() {
|
||||
groupValue = newValue;
|
||||
});
|
||||
|
@ -605,7 +603,7 @@ void main() {
|
|||
child: Radio<int>(
|
||||
visualDensity: visualDensity,
|
||||
key: key,
|
||||
onChanged: (int value) {},
|
||||
onChanged: (int? value) {},
|
||||
value: 0,
|
||||
groupValue: 0,
|
||||
),
|
||||
|
@ -648,7 +646,7 @@ void main() {
|
|||
key: key,
|
||||
mouseCursor: SystemMouseCursors.text,
|
||||
value: 1,
|
||||
onChanged: (int v) {},
|
||||
onChanged: (int? v) {},
|
||||
groupValue: 2,
|
||||
),
|
||||
),
|
||||
|
@ -664,7 +662,7 @@ void main() {
|
|||
|
||||
await tester.pump();
|
||||
|
||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
|
||||
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
|
||||
|
||||
|
||||
// Test default cursor
|
||||
|
@ -678,7 +676,7 @@ void main() {
|
|||
cursor: SystemMouseCursors.forbidden,
|
||||
child: Radio<int>(
|
||||
value: 1,
|
||||
onChanged: (int v) {},
|
||||
onChanged: (int? v) {},
|
||||
groupValue: 2,
|
||||
),
|
||||
),
|
||||
|
@ -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
|
||||
await tester.pumpWidget(
|
||||
|
@ -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 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
@ -38,10 +36,10 @@ void main() {
|
|||
expect(material.elevation, 2.0);
|
||||
expect(material.shadowColor, null);
|
||||
expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(2.0)));
|
||||
expect(material.textStyle.color, const Color(0xdd000000));
|
||||
expect(material.textStyle.fontFamily, 'Roboto');
|
||||
expect(material.textStyle.fontSize, 14);
|
||||
expect(material.textStyle.fontWeight, FontWeight.w500);
|
||||
expect(material.textStyle!.color, const Color(0xdd000000));
|
||||
expect(material.textStyle!.fontFamily, 'Roboto');
|
||||
expect(material.textStyle!.fontSize, 14);
|
||||
expect(material.textStyle!.fontWeight, FontWeight.w500);
|
||||
expect(material.type, MaterialType.button);
|
||||
|
||||
final Offset center = tester.getCenter(find.byType(RaisedButton));
|
||||
|
@ -58,10 +56,10 @@ void main() {
|
|||
expect(material.elevation, 8.0);
|
||||
expect(material.shadowColor, null);
|
||||
expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(2.0)));
|
||||
expect(material.textStyle.color, const Color(0xdd000000));
|
||||
expect(material.textStyle.fontFamily, 'Roboto');
|
||||
expect(material.textStyle.fontSize, 14);
|
||||
expect(material.textStyle.fontWeight, FontWeight.w500);
|
||||
expect(material.textStyle!.color, const Color(0xdd000000));
|
||||
expect(material.textStyle!.fontFamily, 'Roboto');
|
||||
expect(material.textStyle!.fontSize, 14);
|
||||
expect(material.textStyle!.fontWeight, FontWeight.w500);
|
||||
expect(material.type, MaterialType.button);
|
||||
|
||||
// Disabled RaisedButton
|
||||
|
@ -83,10 +81,10 @@ void main() {
|
|||
expect(material.elevation, 0.0);
|
||||
expect(material.shadowColor, null);
|
||||
expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(2.0)));
|
||||
expect(material.textStyle.color, const Color(0x61000000));
|
||||
expect(material.textStyle.fontFamily, 'Roboto');
|
||||
expect(material.textStyle.fontSize, 14);
|
||||
expect(material.textStyle.fontWeight, FontWeight.w500);
|
||||
expect(material.textStyle!.color, const Color(0x61000000));
|
||||
expect(material.textStyle!.fontFamily, 'Roboto');
|
||||
expect(material.textStyle!.fontSize, 14);
|
||||
expect(material.textStyle!.fontWeight, FontWeight.w500);
|
||||
expect(material.type, MaterialType.button);
|
||||
});
|
||||
|
||||
|
@ -198,7 +196,7 @@ void main() {
|
|||
);
|
||||
|
||||
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.
|
||||
|
@ -267,7 +265,7 @@ void main() {
|
|||
),
|
||||
);
|
||||
|
||||
Color iconColor() => _iconStyle(tester, Icons.add).color;
|
||||
Color iconColor() => _iconStyle(tester, Icons.add).color!;
|
||||
// Default, not disabled.
|
||||
expect(iconColor(), equals(defaultColor));
|
||||
|
||||
|
@ -325,7 +323,7 @@ void main() {
|
|||
);
|
||||
|
||||
Color textColor() {
|
||||
return tester.renderObject<RenderParagraph>(find.text('RaisedButton')).text.style.color;
|
||||
return tester.renderObject<RenderParagraph>(find.text('RaisedButton')).text.style!.color!;
|
||||
}
|
||||
|
||||
// Disabled.
|
||||
|
@ -338,7 +336,7 @@ void main() {
|
|||
bool wasPressed;
|
||||
Finder raisedButton;
|
||||
|
||||
Widget buildFrame({ VoidCallback onPressed, VoidCallback onLongPress }) {
|
||||
Widget buildFrame({ VoidCallback? onPressed, VoidCallback? onLongPress }) {
|
||||
return Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: RaisedButton(
|
||||
|
@ -454,7 +452,7 @@ void main() {
|
|||
addTearDown(gesture.removePointer);
|
||||
|
||||
await tester.pump();
|
||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
|
||||
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
|
||||
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
|
@ -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
|
||||
await tester.pumpWidget(
|
||||
|
@ -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
|
||||
await tester.pumpWidget(
|
||||
|
@ -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) {
|
|||
final RichText iconRichText = tester.widget<RichText>(
|
||||
find.descendant(of: find.byIcon(icon), matching: find.byType(RichText)),
|
||||
);
|
||||
return iconRichText.text.style;
|
||||
return iconRichText.text.style!;
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
@ -886,8 +884,8 @@ void main() {
|
|||
|
||||
testWidgets('Range Slider onChangeEnd and onChangeStart are called on an interaction initiated by tap', (WidgetTester tester) async {
|
||||
RangeValues values = const RangeValues(30, 70);
|
||||
RangeValues startValues;
|
||||
RangeValues endValues;
|
||||
RangeValues? startValues;
|
||||
RangeValues? endValues;
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
|
@ -934,18 +932,18 @@ void main() {
|
|||
expect(startValues, null);
|
||||
expect(endValues, null);
|
||||
await tester.dragFrom(leftTarget, (bottomRight - topLeft) * 0.2);
|
||||
expect(startValues.start, moreOrLessEquals(30, epsilon: 1));
|
||||
expect(startValues.end, moreOrLessEquals(70, epsilon: 1));
|
||||
expect(startValues!.start, moreOrLessEquals(30, epsilon: 1));
|
||||
expect(startValues!.end, moreOrLessEquals(70, epsilon: 1));
|
||||
expect(values.start, moreOrLessEquals(50, epsilon: 1));
|
||||
expect(values.end, moreOrLessEquals(70, epsilon: 1));
|
||||
expect(endValues.start, moreOrLessEquals(50, epsilon: 1));
|
||||
expect(endValues.end, moreOrLessEquals(70, epsilon: 1));
|
||||
expect(endValues!.start, moreOrLessEquals(50, 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 {
|
||||
RangeValues values = const RangeValues(30, 70);
|
||||
RangeValues startValues;
|
||||
RangeValues endValues;
|
||||
late RangeValues startValues;
|
||||
late RangeValues endValues;
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
|
@ -1029,14 +1027,14 @@ void main() {
|
|||
}
|
||||
|
||||
Widget _buildThemedApp({
|
||||
ThemeData theme,
|
||||
Color activeColor,
|
||||
Color inactiveColor,
|
||||
int divisions,
|
||||
required ThemeData theme,
|
||||
Color? activeColor,
|
||||
Color? inactiveColor,
|
||||
int? divisions,
|
||||
bool enabled = true,
|
||||
}) {
|
||||
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;
|
||||
};
|
||||
return MaterialApp(
|
||||
|
@ -1287,12 +1285,12 @@ void main() {
|
|||
RangeValues values = const RangeValues(0.5, 0.75);
|
||||
|
||||
Widget buildApp({
|
||||
Color activeColor,
|
||||
Color inactiveColor,
|
||||
int divisions,
|
||||
Color? activeColor,
|
||||
Color? inactiveColor,
|
||||
int? divisions,
|
||||
bool enabled = true,
|
||||
}) {
|
||||
final ValueChanged<RangeValues> onChanged = !enabled ? null : (RangeValues newValues) {
|
||||
final ValueChanged<RangeValues>? onChanged = !enabled ? null : (RangeValues newValues) {
|
||||
values = newValues;
|
||||
};
|
||||
return MaterialApp(
|
||||
|
@ -1345,9 +1343,9 @@ void main() {
|
|||
const Color fillColor = Color(0xf55f5f5f);
|
||||
|
||||
Widget buildApp({
|
||||
Color activeColor,
|
||||
Color inactiveColor,
|
||||
int divisions,
|
||||
Color? activeColor,
|
||||
Color? inactiveColor,
|
||||
int? divisions,
|
||||
bool enabled = true,
|
||||
}) {
|
||||
final ValueChanged<RangeValues> onChanged = (RangeValues newValues) {
|
||||
|
@ -1374,12 +1372,12 @@ void main() {
|
|||
ElevatedButton(
|
||||
child: const Text('Next'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushReplacement(
|
||||
Navigator.of(context)!.pushReplacement(
|
||||
MaterialPageRoute<void>(
|
||||
builder: (BuildContext context) {
|
||||
return ElevatedButton(
|
||||
child: const Text('Inner page'),
|
||||
onPressed: () { Navigator.of(context).pop(); },
|
||||
onPressed: () { Navigator.of(context)!.pop(); },
|
||||
);
|
||||
},
|
||||
),
|
||||
|
@ -1943,7 +1941,7 @@ void main() {
|
|||
await tester.pumpWidget(buildFrame(15));
|
||||
await tester.pumpAndSettle(); // Finish the animation.
|
||||
|
||||
Rect activeTrackRect;
|
||||
late Rect activeTrackRect;
|
||||
expect(renderObject, paints..something((Symbol method, List<dynamic> arguments) {
|
||||
if (method != #drawRect)
|
||||
return false;
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -443,7 +441,7 @@ void main() {
|
|||
bool wasPressed;
|
||||
Finder rawMaterialButton;
|
||||
|
||||
Widget buildFrame({ VoidCallback onPressed, VoidCallback onLongPress }) {
|
||||
Widget buildFrame({ VoidCallback? onPressed, VoidCallback? onLongPress }) {
|
||||
return Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: RawMaterialButton(
|
||||
|
@ -593,7 +591,7 @@ void main() {
|
|||
|
||||
await tester.pump();
|
||||
|
||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
|
||||
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
|
||||
|
||||
// Test default cursor
|
||||
await tester.pumpWidget(
|
||||
|
@ -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
|
||||
await tester.pumpWidget(
|
||||
|
@ -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 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
@ -360,35 +358,6 @@ void main() {
|
|||
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 {
|
||||
refreshCalled = false;
|
||||
double lastScrollOffset;
|
||||
|
@ -458,31 +427,6 @@ void main() {
|
|||
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 {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/semantics.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
@ -13,7 +11,7 @@ void main() {
|
|||
group('$ReorderableListView', () {
|
||||
const double itemHeight = 48.0;
|
||||
const List<String> originalListItems = <String>['Item 1', 'Item 2', 'Item 3', 'Item 4'];
|
||||
List<String> listItems;
|
||||
late List<String> listItems;
|
||||
|
||||
void onReorder(int oldIndex, int newIndex) {
|
||||
if (oldIndex < newIndex) {
|
||||
|
@ -32,7 +30,7 @@ void main() {
|
|||
);
|
||||
}
|
||||
|
||||
Widget build({ Widget header, Axis scrollDirection = Axis.vertical, TextDirection textDirection = TextDirection.ltr }) {
|
||||
Widget build({ Widget? header, Axis scrollDirection = Axis.vertical, TextDirection textDirection = TextDirection.ltr }) {
|
||||
return MaterialApp(
|
||||
home: Directionality(
|
||||
textDirection: textDirection,
|
||||
|
@ -172,43 +170,43 @@ void main() {
|
|||
|
||||
Element getContentElement() {
|
||||
final SingleChildScrollView listScrollView = tester.widget(find.byType(SingleChildScrollView));
|
||||
final Widget scrollContents = listScrollView.child;
|
||||
final Widget scrollContents = listScrollView.child!;
|
||||
final Element contentElement = tester.element(find.byElementPredicate((Element element) => element.widget == scrollContents));
|
||||
return contentElement;
|
||||
}
|
||||
|
||||
const double kDraggingListHeight = 292.0;
|
||||
// Drag a normal text item
|
||||
expect(getContentElement().size.height, kDraggingListHeight);
|
||||
expect(getContentElement().size!.height, kDraggingListHeight);
|
||||
TestGesture drag = await tester.startGesture(tester.getCenter(find.text('Normal item')));
|
||||
await tester.pump(kLongPressTimeout + kPressTimeout);
|
||||
await tester.pumpAndSettle();
|
||||
expect(getContentElement().size.height, kDraggingListHeight);
|
||||
expect(getContentElement().size!.height, kDraggingListHeight);
|
||||
|
||||
// Move it
|
||||
await drag.moveTo(tester.getCenter(find.text('Last item')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(getContentElement().size.height, kDraggingListHeight);
|
||||
expect(getContentElement().size!.height, kDraggingListHeight);
|
||||
|
||||
// Drop it
|
||||
await drag.up();
|
||||
await tester.pumpAndSettle();
|
||||
expect(getContentElement().size.height, kDraggingListHeight);
|
||||
expect(getContentElement().size!.height, kDraggingListHeight);
|
||||
|
||||
// Drag a tall item
|
||||
drag = await tester.startGesture(tester.getCenter(find.text('Tall item')));
|
||||
await tester.pump(kLongPressTimeout + kPressTimeout);
|
||||
await tester.pumpAndSettle();
|
||||
expect(getContentElement().size.height, kDraggingListHeight);
|
||||
expect(getContentElement().size!.height, kDraggingListHeight);
|
||||
// Move it
|
||||
await drag.moveTo(tester.getCenter(find.text('Last item')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(getContentElement().size.height, kDraggingListHeight);
|
||||
expect(getContentElement().size!.height, kDraggingListHeight);
|
||||
|
||||
// Drop it
|
||||
await drag.up();
|
||||
await tester.pumpAndSettle();
|
||||
expect(getContentElement().size.height, kDraggingListHeight);
|
||||
expect(getContentElement().size!.height, kDraggingListHeight);
|
||||
});
|
||||
|
||||
testWidgets('Vertical drop area golden', (WidgetTester tester) async {
|
||||
|
@ -257,7 +255,7 @@ void main() {
|
|||
return find.byElementPredicate((Element element) => element.findAncestorWidgetOfExactType<_Stateful>()?.key == key)
|
||||
.evaluate()
|
||||
.first
|
||||
.findAncestorStateOfType<_StatefulState>();
|
||||
.findAncestorStateOfType<_StatefulState>()!;
|
||||
}
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: ReorderableListView(
|
||||
|
@ -461,7 +459,7 @@ void main() {
|
|||
of: find.byKey(Key(listItems[index])),
|
||||
matching: find.byType(Semantics),
|
||||
).evaluate().first.widget as Semantics;
|
||||
return semantics.properties.customSemanticsActions;
|
||||
return semantics.properties.customSemanticsActions!;
|
||||
}
|
||||
|
||||
const CustomSemanticsAction moveToStart = CustomSemanticsAction(label: 'Move to the start');
|
||||
|
@ -511,14 +509,14 @@ void main() {
|
|||
// Test out move to end: move Item 1 to the end of the list.
|
||||
await tester.pumpWidget(build());
|
||||
Map<CustomSemanticsAction, VoidCallback> firstSemanticsActions = getSemanticsActions(0);
|
||||
firstSemanticsActions[moveToEnd]();
|
||||
firstSemanticsActions[moveToEnd]!();
|
||||
await tester.pumpAndSettle();
|
||||
expect(listItems, orderedEquals(<String>['Item 2', 'Item 3', 'Item 4', 'Item 1']));
|
||||
|
||||
// Test out move after: move Item 2 (the current first item) one space down.
|
||||
await tester.pumpWidget(build());
|
||||
firstSemanticsActions = getSemanticsActions(0);
|
||||
firstSemanticsActions[moveDown]();
|
||||
firstSemanticsActions[moveDown]!();
|
||||
await tester.pumpAndSettle();
|
||||
expect(listItems, orderedEquals(<String>['Item 3', 'Item 2', 'Item 4', 'Item 1']));
|
||||
|
||||
|
@ -532,28 +530,28 @@ void main() {
|
|||
// Test out move to end: move Item 2 to the end of the list.
|
||||
await tester.pumpWidget(build());
|
||||
Map<CustomSemanticsAction, VoidCallback> middleSemanticsActions = getSemanticsActions(1);
|
||||
middleSemanticsActions[moveToEnd]();
|
||||
middleSemanticsActions[moveToEnd]!();
|
||||
await tester.pumpAndSettle();
|
||||
expect(listItems, orderedEquals(<String>['Item 1', 'Item 3', 'Item 4', 'Item 2']));
|
||||
|
||||
// Test out move after: move Item 3 (the current second item) one space down.
|
||||
await tester.pumpWidget(build());
|
||||
middleSemanticsActions = getSemanticsActions(1);
|
||||
middleSemanticsActions[moveDown]();
|
||||
middleSemanticsActions[moveDown]!();
|
||||
await tester.pumpAndSettle();
|
||||
expect(listItems, orderedEquals(<String>['Item 1', 'Item 4', 'Item 3', 'Item 2']));
|
||||
|
||||
// Test out move after: move Item 3 (the current third item) one space up.
|
||||
await tester.pumpWidget(build());
|
||||
middleSemanticsActions = getSemanticsActions(2);
|
||||
middleSemanticsActions[moveUp]();
|
||||
middleSemanticsActions[moveUp]!();
|
||||
await tester.pumpAndSettle();
|
||||
expect(listItems, orderedEquals(<String>['Item 1', 'Item 3', 'Item 4', 'Item 2']));
|
||||
|
||||
// Test out move to start: move Item 4 (the current third item) to the start of the list.
|
||||
await tester.pumpWidget(build());
|
||||
middleSemanticsActions = getSemanticsActions(2);
|
||||
middleSemanticsActions[moveToStart]();
|
||||
middleSemanticsActions[moveToStart]!();
|
||||
await tester.pumpAndSettle();
|
||||
expect(listItems, orderedEquals(<String>['Item 4', 'Item 1', 'Item 3', 'Item 2']));
|
||||
|
||||
|
@ -567,14 +565,14 @@ void main() {
|
|||
// Test out move to start: move Item 4 to the start of the list.
|
||||
await tester.pumpWidget(build());
|
||||
Map<CustomSemanticsAction, VoidCallback> lastSemanticsActions = getSemanticsActions(listItems.length - 1);
|
||||
lastSemanticsActions[moveToStart]();
|
||||
lastSemanticsActions[moveToStart]!();
|
||||
await tester.pumpAndSettle();
|
||||
expect(listItems, orderedEquals(<String>['Item 4', 'Item 1', 'Item 2', 'Item 3']));
|
||||
|
||||
// Test out move up: move Item 3 (the current last item) one space up.
|
||||
await tester.pumpWidget(build());
|
||||
lastSemanticsActions = getSemanticsActions(listItems.length - 1);
|
||||
lastSemanticsActions[moveUp]();
|
||||
lastSemanticsActions[moveUp]!();
|
||||
await tester.pumpAndSettle();
|
||||
expect(listItems, orderedEquals(<String>['Item 4', 'Item 1', 'Item 3', 'Item 2']));
|
||||
|
||||
|
@ -597,7 +595,7 @@ void main() {
|
|||
child: SwitchListTile(
|
||||
title: const Text('Switch tile'),
|
||||
value: true,
|
||||
onChanged: (bool newValue) { },
|
||||
onChanged: (bool? newValue) { },
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -755,43 +753,43 @@ void main() {
|
|||
|
||||
Element getContentElement() {
|
||||
final SingleChildScrollView listScrollView = tester.widget(find.byType(SingleChildScrollView));
|
||||
final Widget scrollContents = listScrollView.child;
|
||||
final Widget scrollContents = listScrollView.child!;
|
||||
final Element contentElement = tester.element(find.byElementPredicate((Element element) => element.widget == scrollContents));
|
||||
return contentElement;
|
||||
}
|
||||
|
||||
const double kDraggingListWidth = 292.0;
|
||||
// Drag a normal text item
|
||||
expect(getContentElement().size.width, kDraggingListWidth);
|
||||
expect(getContentElement().size!.width, kDraggingListWidth);
|
||||
TestGesture drag = await tester.startGesture(tester.getCenter(find.text('Normal item')));
|
||||
await tester.pump(kLongPressTimeout + kPressTimeout);
|
||||
await tester.pumpAndSettle();
|
||||
expect(getContentElement().size.width, kDraggingListWidth);
|
||||
expect(getContentElement().size!.width, kDraggingListWidth);
|
||||
|
||||
// Move it
|
||||
await drag.moveTo(tester.getCenter(find.text('Last item')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(getContentElement().size.width, kDraggingListWidth);
|
||||
expect(getContentElement().size!.width, kDraggingListWidth);
|
||||
|
||||
// Drop it
|
||||
await drag.up();
|
||||
await tester.pumpAndSettle();
|
||||
expect(getContentElement().size.width, kDraggingListWidth);
|
||||
expect(getContentElement().size!.width, kDraggingListWidth);
|
||||
|
||||
// Drag a tall item
|
||||
drag = await tester.startGesture(tester.getCenter(find.text('Tall item')));
|
||||
await tester.pump(kLongPressTimeout + kPressTimeout);
|
||||
await tester.pumpAndSettle();
|
||||
expect(getContentElement().size.width, kDraggingListWidth);
|
||||
expect(getContentElement().size!.width, kDraggingListWidth);
|
||||
// Move it
|
||||
await drag.moveTo(tester.getCenter(find.text('Last item')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(getContentElement().size.width, kDraggingListWidth);
|
||||
expect(getContentElement().size!.width, kDraggingListWidth);
|
||||
|
||||
// Drop it
|
||||
await drag.up();
|
||||
await tester.pumpAndSettle();
|
||||
expect(getContentElement().size.width, kDraggingListWidth);
|
||||
expect(getContentElement().size!.width, kDraggingListWidth);
|
||||
});
|
||||
|
||||
testWidgets('Horizontal drop area golden', (WidgetTester tester) async {
|
||||
|
@ -840,7 +838,7 @@ void main() {
|
|||
return find.byElementPredicate((Element element) => element.findAncestorWidgetOfExactType<_Stateful>()?.key == key)
|
||||
.evaluate()
|
||||
.first
|
||||
.findAncestorStateOfType<_StatefulState>();
|
||||
.findAncestorStateOfType<_StatefulState>()!;
|
||||
}
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: ReorderableListView(
|
||||
|
@ -912,7 +910,7 @@ void main() {
|
|||
of: find.byKey(Key(listItems[index])),
|
||||
matching: find.byType(Semantics),
|
||||
).evaluate().first.widget as Semantics;
|
||||
return semantics.properties.customSemanticsActions;
|
||||
return semantics.properties.customSemanticsActions!;
|
||||
}
|
||||
|
||||
const CustomSemanticsAction moveToStart = CustomSemanticsAction(label: 'Move to the start');
|
||||
|
@ -995,14 +993,14 @@ void main() {
|
|||
// Test out move to end: move Item 1 to the end of the list.
|
||||
await tester.pumpWidget(build(scrollDirection: Axis.horizontal));
|
||||
Map<CustomSemanticsAction, VoidCallback> firstSemanticsActions = getSemanticsActions(0);
|
||||
firstSemanticsActions[moveToEnd]();
|
||||
firstSemanticsActions[moveToEnd]!();
|
||||
await tester.pumpAndSettle();
|
||||
expect(listItems, orderedEquals(<String>['Item 2', 'Item 3', 'Item 4', 'Item 1']));
|
||||
|
||||
// Test out move after: move Item 2 (the current first item) one space to the right.
|
||||
await tester.pumpWidget(build(scrollDirection: Axis.horizontal));
|
||||
firstSemanticsActions = getSemanticsActions(0);
|
||||
firstSemanticsActions[moveRight]();
|
||||
firstSemanticsActions[moveRight]!();
|
||||
await tester.pumpAndSettle();
|
||||
expect(listItems, orderedEquals(<String>['Item 3', 'Item 2', 'Item 4', 'Item 1']));
|
||||
|
||||
|
@ -1018,14 +1016,14 @@ void main() {
|
|||
// Test out move to end: move Item 1 to the end of the list.
|
||||
await tester.pumpWidget(build(scrollDirection: Axis.horizontal, textDirection: TextDirection.rtl));
|
||||
Map<CustomSemanticsAction, VoidCallback> firstSemanticsActions = getSemanticsActions(0);
|
||||
firstSemanticsActions[moveToEnd]();
|
||||
firstSemanticsActions[moveToEnd]!();
|
||||
await tester.pumpAndSettle();
|
||||
expect(listItems, orderedEquals(<String>['Item 2', 'Item 3', 'Item 4', 'Item 1']));
|
||||
|
||||
// Test out move after: move Item 2 (the current first item) one space to the left.
|
||||
await tester.pumpWidget(build(scrollDirection: Axis.horizontal, textDirection: TextDirection.rtl));
|
||||
firstSemanticsActions = getSemanticsActions(0);
|
||||
firstSemanticsActions[moveLeft]();
|
||||
firstSemanticsActions[moveLeft]!();
|
||||
await tester.pumpAndSettle();
|
||||
expect(listItems, orderedEquals(<String>['Item 3', 'Item 2', 'Item 4', 'Item 1']));
|
||||
|
||||
|
@ -1039,28 +1037,28 @@ void main() {
|
|||
// Test out move to end: move Item 2 to the end of the list.
|
||||
await tester.pumpWidget(build(scrollDirection: Axis.horizontal));
|
||||
Map<CustomSemanticsAction, VoidCallback> middleSemanticsActions = getSemanticsActions(1);
|
||||
middleSemanticsActions[moveToEnd]();
|
||||
middleSemanticsActions[moveToEnd]!();
|
||||
await tester.pumpAndSettle();
|
||||
expect(listItems, orderedEquals(<String>['Item 1', 'Item 3', 'Item 4', 'Item 2']));
|
||||
|
||||
// Test out move after: move Item 3 (the current second item) one space to the right.
|
||||
await tester.pumpWidget(build(scrollDirection: Axis.horizontal));
|
||||
middleSemanticsActions = getSemanticsActions(1);
|
||||
middleSemanticsActions[moveRight]();
|
||||
middleSemanticsActions[moveRight]!();
|
||||
await tester.pumpAndSettle();
|
||||
expect(listItems, orderedEquals(<String>['Item 1', 'Item 4', 'Item 3', 'Item 2']));
|
||||
|
||||
// Test out move after: move Item 3 (the current third item) one space to the left.
|
||||
await tester.pumpWidget(build(scrollDirection: Axis.horizontal));
|
||||
middleSemanticsActions = getSemanticsActions(2);
|
||||
middleSemanticsActions[moveLeft]();
|
||||
middleSemanticsActions[moveLeft]!();
|
||||
await tester.pumpAndSettle();
|
||||
expect(listItems, orderedEquals(<String>['Item 1', 'Item 3', 'Item 4', 'Item 2']));
|
||||
|
||||
// Test out move to start: move Item 4 (the current third item) to the start of the list.
|
||||
await tester.pumpWidget(build(scrollDirection: Axis.horizontal));
|
||||
middleSemanticsActions = getSemanticsActions(2);
|
||||
middleSemanticsActions[moveToStart]();
|
||||
middleSemanticsActions[moveToStart]!();
|
||||
await tester.pumpAndSettle();
|
||||
expect(listItems, orderedEquals(<String>['Item 4', 'Item 1', 'Item 3', 'Item 2']));
|
||||
|
||||
|
@ -1076,28 +1074,28 @@ void main() {
|
|||
// Test out move to end: move Item 2 to the end of the list.
|
||||
await tester.pumpWidget(build(scrollDirection: Axis.horizontal, textDirection: TextDirection.rtl));
|
||||
Map<CustomSemanticsAction, VoidCallback> middleSemanticsActions = getSemanticsActions(1);
|
||||
middleSemanticsActions[moveToEnd]();
|
||||
middleSemanticsActions[moveToEnd]!();
|
||||
await tester.pumpAndSettle();
|
||||
expect(listItems, orderedEquals(<String>['Item 1', 'Item 3', 'Item 4', 'Item 2']));
|
||||
|
||||
// Test out move after: move Item 3 (the current second item) one space to the left.
|
||||
await tester.pumpWidget(build(scrollDirection: Axis.horizontal, textDirection: TextDirection.rtl));
|
||||
middleSemanticsActions = getSemanticsActions(1);
|
||||
middleSemanticsActions[moveLeft]();
|
||||
middleSemanticsActions[moveLeft]!();
|
||||
await tester.pumpAndSettle();
|
||||
expect(listItems, orderedEquals(<String>['Item 1', 'Item 4', 'Item 3', 'Item 2']));
|
||||
|
||||
// Test out move after: move Item 3 (the current third item) one space to the right.
|
||||
await tester.pumpWidget(build(scrollDirection: Axis.horizontal, textDirection: TextDirection.rtl));
|
||||
middleSemanticsActions = getSemanticsActions(2);
|
||||
middleSemanticsActions[moveRight]();
|
||||
middleSemanticsActions[moveRight]!();
|
||||
await tester.pumpAndSettle();
|
||||
expect(listItems, orderedEquals(<String>['Item 1', 'Item 3', 'Item 4', 'Item 2']));
|
||||
|
||||
// Test out move to start: move Item 4 (the current third item) to the start of the list.
|
||||
await tester.pumpWidget(build(scrollDirection: Axis.horizontal, textDirection: TextDirection.rtl));
|
||||
middleSemanticsActions = getSemanticsActions(2);
|
||||
middleSemanticsActions[moveToStart]();
|
||||
middleSemanticsActions[moveToStart]!();
|
||||
await tester.pumpAndSettle();
|
||||
expect(listItems, orderedEquals(<String>['Item 4', 'Item 1', 'Item 3', 'Item 2']));
|
||||
|
||||
|
@ -1111,14 +1109,14 @@ void main() {
|
|||
// Test out move to start: move Item 4 to the start of the list.
|
||||
await tester.pumpWidget(build(scrollDirection: Axis.horizontal));
|
||||
Map<CustomSemanticsAction, VoidCallback> lastSemanticsActions = getSemanticsActions(listItems.length - 1);
|
||||
lastSemanticsActions[moveToStart]();
|
||||
lastSemanticsActions[moveToStart]!();
|
||||
await tester.pumpAndSettle();
|
||||
expect(listItems, orderedEquals(<String>['Item 4', 'Item 1', 'Item 2', 'Item 3']));
|
||||
|
||||
// Test out move before: move Item 3 (the current last item) one space to the left.
|
||||
await tester.pumpWidget(build(scrollDirection: Axis.horizontal));
|
||||
lastSemanticsActions = getSemanticsActions(listItems.length - 1);
|
||||
lastSemanticsActions[moveLeft]();
|
||||
lastSemanticsActions[moveLeft]!();
|
||||
await tester.pumpAndSettle();
|
||||
expect(listItems, orderedEquals(<String>['Item 4', 'Item 1', 'Item 3', 'Item 2']));
|
||||
|
||||
|
@ -1134,14 +1132,14 @@ void main() {
|
|||
// Test out move to start: move Item 4 to the start of the list.
|
||||
await tester.pumpWidget(build(scrollDirection: Axis.horizontal, textDirection: TextDirection.rtl));
|
||||
Map<CustomSemanticsAction, VoidCallback> lastSemanticsActions = getSemanticsActions(listItems.length - 1);
|
||||
lastSemanticsActions[moveToStart]();
|
||||
lastSemanticsActions[moveToStart]!();
|
||||
await tester.pumpAndSettle();
|
||||
expect(listItems, orderedEquals(<String>['Item 4', 'Item 1', 'Item 2', 'Item 3']));
|
||||
|
||||
// Test out move before: move Item 3 (the current last item) one space to the right.
|
||||
await tester.pumpWidget(build(scrollDirection: Axis.horizontal, textDirection: TextDirection.rtl));
|
||||
lastSemanticsActions = getSemanticsActions(listItems.length - 1);
|
||||
lastSemanticsActions[moveRight]();
|
||||
lastSemanticsActions[moveRight]!();
|
||||
await tester.pumpAndSettle();
|
||||
expect(listItems, orderedEquals(<String>['Item 4', 'Item 1', 'Item 3', 'Item 2']));
|
||||
|
||||
|
@ -1190,14 +1188,14 @@ Future<void> longPressDrag(WidgetTester tester, Offset start, Offset end) async
|
|||
class _Stateful extends StatefulWidget {
|
||||
// Ignoring the preference for const constructors because we want to test with regular non-const instances.
|
||||
// ignore:prefer_const_constructors_in_immutables
|
||||
_Stateful({Key key}) : super(key: key);
|
||||
_Stateful({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _StatefulState();
|
||||
}
|
||||
|
||||
class _StatefulState extends State<_Stateful> {
|
||||
bool checked = false;
|
||||
bool? checked = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -1207,7 +1205,7 @@ class _StatefulState extends State<_Stateful> {
|
|||
child: Material(
|
||||
child: Checkbox(
|
||||
value: checked,
|
||||
onChanged: (bool newValue) => checked = newValue,
|
||||
onChanged: (bool? newValue) => checked = newValue,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/gestures.dart' show DragStartBehavior;
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -298,7 +296,7 @@ void main() {
|
|||
expect(renderBox.size.height, equals(appBarHeight));
|
||||
});
|
||||
|
||||
Widget _buildStatusBarTestApp(TargetPlatform platform) {
|
||||
Widget _buildStatusBarTestApp(TargetPlatform? platform) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(platform: platform),
|
||||
home: MediaQuery(
|
||||
|
@ -357,7 +355,7 @@ void main() {
|
|||
builder: (BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
Scaffold.of(context).showBottomSheet<void>((BuildContext context) {
|
||||
Scaffold.of(context)!.showBottomSheet<void>((BuildContext context) {
|
||||
return Container(
|
||||
key: sheetKey,
|
||||
color: Colors.blue[500],
|
||||
|
@ -519,7 +517,7 @@ void main() {
|
|||
};
|
||||
await tester.pumpWidget(MaterialApp(routes: routes));
|
||||
|
||||
Navigator.pushNamed(rootKey.currentContext, '/scaffold');
|
||||
Navigator.pushNamed(rootKey.currentContext!, '/scaffold');
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
|
||||
|
@ -671,9 +669,9 @@ void main() {
|
|||
|
||||
testWidgets('body size with extendBody', (WidgetTester tester) async {
|
||||
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(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: MediaQuery(
|
||||
|
@ -685,7 +683,7 @@ void main() {
|
|||
extendBody: extendBody,
|
||||
body: Builder(
|
||||
builder: (BuildContext context) {
|
||||
mediaQueryBottom = MediaQuery.of(context).padding.bottom;
|
||||
mediaQueryBottom = MediaQuery.of(context)!.padding.bottom;
|
||||
return Container(key: bodyKey);
|
||||
},
|
||||
),
|
||||
|
@ -732,10 +730,10 @@ void main() {
|
|||
|
||||
const double appBarHeight = 100;
|
||||
const double windowPaddingTop = 24;
|
||||
bool fixedHeightAppBar;
|
||||
double mediaQueryTop;
|
||||
late bool fixedHeightAppBar;
|
||||
late double mediaQueryTop;
|
||||
|
||||
Widget buildFrame({ bool extendBodyBehindAppBar, bool hasAppBar }) {
|
||||
Widget buildFrame({ required bool extendBodyBehindAppBar, required bool hasAppBar }) {
|
||||
return Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: MediaQuery(
|
||||
|
@ -758,7 +756,7 @@ void main() {
|
|||
),
|
||||
body: Builder(
|
||||
builder: (BuildContext context) {
|
||||
mediaQueryTop = MediaQuery.of(context).padding.top;
|
||||
mediaQueryTop = MediaQuery.of(context)!.padding.top;
|
||||
return Container(key: bodyKey);
|
||||
}
|
||||
),
|
||||
|
@ -1224,7 +1222,7 @@ void main() {
|
|||
await tester.pump(const Duration(milliseconds: 50));
|
||||
|
||||
ScaffoldGeometry geometry = listenerState.cache.value;
|
||||
final Rect transitioningFabRect = geometry.floatingActionButtonArea;
|
||||
final Rect transitioningFabRect = geometry.floatingActionButtonArea!;
|
||||
|
||||
final double transitioningRotation = tester.widget<RotationTransition>(
|
||||
find.byType(RotationTransition),
|
||||
|
@ -1249,17 +1247,17 @@ void main() {
|
|||
);
|
||||
|
||||
expect(
|
||||
geometry.floatingActionButtonArea.center,
|
||||
geometry.floatingActionButtonArea!.center,
|
||||
transitioningFabRect.center,
|
||||
);
|
||||
|
||||
expect(
|
||||
geometry.floatingActionButtonArea.width,
|
||||
geometry.floatingActionButtonArea!.width,
|
||||
greaterThan(transitioningFabRect.width),
|
||||
);
|
||||
|
||||
expect(
|
||||
geometry.floatingActionButtonArea.height,
|
||||
geometry.floatingActionButtonArea!.height,
|
||||
greaterThan(transitioningFabRect.height),
|
||||
);
|
||||
});
|
||||
|
@ -1672,12 +1670,12 @@ void main() {
|
|||
});
|
||||
|
||||
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(
|
||||
MaterialApp(
|
||||
home: Builder(
|
||||
builder: (BuildContext context) {
|
||||
screenWidth = MediaQuery.of(context).size.width;
|
||||
screenWidth = MediaQuery.of(context)!.size.width;
|
||||
return Scaffold(
|
||||
endDrawer: const Drawer(
|
||||
child: Text('Drawer'),
|
||||
|
@ -1746,7 +1744,7 @@ void main() {
|
|||
// Regression test for https://github.com/flutter/flutter/issues/20295
|
||||
final Key bodyKey = UniqueKey();
|
||||
|
||||
Widget buildFrame(bool innerResizeToAvoidBottomInset, bool outerResizeToAvoidBottomInset) {
|
||||
Widget buildFrame(bool? innerResizeToAvoidBottomInset, bool? outerResizeToAvoidBottomInset) {
|
||||
return Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: MediaQuery(
|
||||
|
@ -1810,10 +1808,10 @@ void main() {
|
|||
),
|
||||
),
|
||||
);
|
||||
FlutterError error;
|
||||
late FlutterError error;
|
||||
try {
|
||||
key.currentState.showBottomSheet<void>((BuildContext context) {
|
||||
final ThemeData themeData = Theme.of(context);
|
||||
key.currentState!.showBottomSheet<void>((BuildContext context) {
|
||||
final ThemeData themeData = Theme.of(context)!;
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(top: BorderSide(color: themeData.disabledColor))
|
||||
|
@ -1872,7 +1870,7 @@ void main() {
|
|||
),
|
||||
),
|
||||
);
|
||||
key.currentState.showBottomSheet<void>((_) => Container());
|
||||
key.currentState!.showBottomSheet<void>((_) => Container());
|
||||
await tester.tap(find.byKey(buttonKey));
|
||||
await tester.pump();
|
||||
expect(errors, isNotEmpty);
|
||||
|
@ -1902,7 +1900,7 @@ void main() {
|
|||
MaterialApp(
|
||||
home: Builder(
|
||||
builder: (BuildContext context) {
|
||||
Scaffold.of(context).showBottomSheet<void>((BuildContext context) {
|
||||
Scaffold.of(context)!.showBottomSheet<void>((BuildContext context) {
|
||||
return Container();
|
||||
});
|
||||
return Container();
|
||||
|
@ -1970,7 +1968,7 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('Call to Scaffold.geometryOf() without context', (WidgetTester tester) async {
|
||||
ValueListenable<ScaffoldGeometry> geometry;
|
||||
ValueListenable<ScaffoldGeometry>? geometry;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Builder(
|
||||
|
@ -2036,7 +2034,7 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('ScaffoldMessenger.of can return null', (WidgetTester tester) async {
|
||||
ScaffoldMessengerState scaffoldMessenger;
|
||||
ScaffoldMessengerState? scaffoldMessenger;
|
||||
const Key tapTarget = Key('tap-target');
|
||||
await tester.pumpWidget(Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
|
@ -2070,7 +2068,7 @@ void main() {
|
|||
const Key tapTarget = Key('tap-target');
|
||||
|
||||
final List<dynamic> exceptions = <dynamic>[];
|
||||
final FlutterExceptionHandler oldHandler = FlutterError.onError;
|
||||
final FlutterExceptionHandler? oldHandler = FlutterError.onError;
|
||||
FlutterError.onError = (FlutterErrorDetails details) {
|
||||
exceptions.add(details.exception);
|
||||
};
|
||||
|
@ -2161,8 +2159,8 @@ class _GeometryListenerState extends State<_GeometryListener> {
|
|||
}
|
||||
|
||||
int numNotifications = 0;
|
||||
ValueListenable<ScaffoldGeometry> geometryListenable;
|
||||
_GeometryCachePainter cache;
|
||||
ValueListenable<ScaffoldGeometry>? geometryListenable;
|
||||
late _GeometryCachePainter cache;
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
|
@ -2172,11 +2170,11 @@ class _GeometryListenerState extends State<_GeometryListener> {
|
|||
return;
|
||||
|
||||
if (geometryListenable != null)
|
||||
geometryListenable.removeListener(onGeometryChanged);
|
||||
geometryListenable!.removeListener(onGeometryChanged);
|
||||
|
||||
geometryListenable = newListenable;
|
||||
geometryListenable.addListener(onGeometryChanged);
|
||||
cache = _GeometryCachePainter(geometryListenable);
|
||||
geometryListenable!.addListener(onGeometryChanged);
|
||||
cache = _GeometryCachePainter(geometryListenable!);
|
||||
}
|
||||
|
||||
void onGeometryChanged() {
|
||||
|
@ -2192,7 +2190,7 @@ class _GeometryCachePainter extends CustomPainter {
|
|||
|
||||
final ValueListenable<ScaffoldGeometry> geometryListenable;
|
||||
|
||||
ScaffoldGeometry value;
|
||||
late ScaffoldGeometry value;
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
value = geometryListenable.value;
|
||||
|
@ -2206,7 +2204,7 @@ class _GeometryCachePainter extends CustomPainter {
|
|||
|
||||
class _CustomPageRoute<T> extends PageRoute<T> {
|
||||
_CustomPageRoute({
|
||||
@required this.builder,
|
||||
required this.builder,
|
||||
RouteSettings settings = const RouteSettings(),
|
||||
this.maintainState = true,
|
||||
bool fullscreenDialog = false,
|
||||
|
@ -2219,10 +2217,10 @@ class _CustomPageRoute<T> extends PageRoute<T> {
|
|||
Duration get transitionDuration => const Duration(milliseconds: 300);
|
||||
|
||||
@override
|
||||
Color get barrierColor => null;
|
||||
Color? get barrierColor => null;
|
||||
|
||||
@override
|
||||
String get barrierLabel => null;
|
||||
String? get barrierLabel => null;
|
||||
|
||||
@override
|
||||
final bool maintainState;
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
@ -12,7 +10,7 @@ import '../rendering/mock_canvas.dart';
|
|||
Widget _buildSingleChildScrollViewWithScrollbar({
|
||||
TextDirection textDirection = TextDirection.ltr,
|
||||
EdgeInsets padding = EdgeInsets.zero,
|
||||
Widget child,
|
||||
Widget? child,
|
||||
}) {
|
||||
return Directionality(
|
||||
textDirection: textDirection,
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -13,20 +11,18 @@ import 'package:flutter_test/flutter_test.dart';
|
|||
import '../rendering/mock_canvas.dart';
|
||||
|
||||
class TestCanvas implements Canvas {
|
||||
TestCanvas([this.invocations]);
|
||||
|
||||
final List<Invocation> invocations;
|
||||
final List<Invocation> invocations = <Invocation>[];
|
||||
|
||||
@override
|
||||
void noSuchMethod(Invocation invocation) {
|
||||
invocations?.add(invocation);
|
||||
invocations.add(invocation);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildBoilerplate({
|
||||
TextDirection textDirection = TextDirection.ltr,
|
||||
EdgeInsets padding = EdgeInsets.zero,
|
||||
Widget child,
|
||||
required Widget child,
|
||||
}) {
|
||||
return Directionality(
|
||||
textDirection: textDirection,
|
||||
|
@ -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));
|
||||
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.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));
|
||||
|
@ -116,12 +112,11 @@ void main() {
|
|||
);
|
||||
scrollPainter.update(metrics, AxisDirection.down);
|
||||
|
||||
final List<Invocation> invocations = <Invocation>[];
|
||||
final TestCanvas canvas = TestCanvas(invocations);
|
||||
final TestCanvas canvas = TestCanvas();
|
||||
scrollPainter.paint(canvas, const Size(10.0, 100.0));
|
||||
|
||||
// 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 {
|
||||
|
@ -174,7 +169,7 @@ void main() {
|
|||
|
||||
testWidgets('Scrollbar passes controller to CupertinoScrollbar', (WidgetTester tester) async {
|
||||
final ScrollController controller = ScrollController();
|
||||
Widget viewWithScroll(TargetPlatform platform) {
|
||||
Widget viewWithScroll(TargetPlatform? platform) {
|
||||
return _buildBoilerplate(
|
||||
child: Theme(
|
||||
data: ThemeData(
|
||||
|
@ -517,7 +512,7 @@ void main() {
|
|||
|
||||
testWidgets('Scrollbar respects thickness and radius', (WidgetTester tester) async {
|
||||
final ScrollController controller = ScrollController();
|
||||
Widget viewWithScroll({Radius radius}) {
|
||||
Widget viewWithScroll({Radius? radius}) {
|
||||
return _buildBoilerplate(
|
||||
child: Theme(
|
||||
data: ThemeData(),
|
||||
|
|
Loading…
Reference in a new issue