Unverified Commit af0c7aed authored by Darren Austin's avatar Darren Austin Committed by GitHub

Migrate framework tests for rendering, semantics, widgets to null safety (#67453)

Migrate framework tests for rendering, semantics, widgets to null safety.
parent 2462f696
......@@ -2,11 +2,8 @@
// 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/rendering.dart';
import 'package:flutter/animation.dart';
import 'package:meta/meta.dart';
import '../flutter_test_alternative.dart';
......@@ -14,22 +11,21 @@ import 'rendering_tester.dart';
class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager {
TestRenderSliverBoxChildManager({
this.children,
required this.children,
});
RenderSliverList _renderObject;
late RenderSliverList _renderObject;
List<RenderBox> children;
RenderSliverList createRenderObject() {
assert(_renderObject == null);
_renderObject = RenderSliverList(childManager: this);
return _renderObject;
}
int _currentlyUpdatingChildIndex;
int? _currentlyUpdatingChildIndex;
@override
void createChild(int index, { @required RenderBox after }) {
void createChild(int index, { required RenderBox? after }) {
if (index < 0 || index >= children.length)
return;
try {
......@@ -48,13 +44,13 @@ class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager {
@override
double estimateMaxScrollOffset(
SliverConstraints constraints, {
int firstIndex,
int lastIndex,
double leadingScrollOffset,
double trailingScrollOffset,
int? firstIndex,
int? lastIndex,
double? leadingScrollOffset,
double? trailingScrollOffset,
}) {
assert(lastIndex >= firstIndex);
return children.length * (trailingScrollOffset - leadingScrollOffset) / (lastIndex - firstIndex + 1);
assert(lastIndex! >= firstIndex!);
return children.length * (trailingScrollOffset! - leadingScrollOffset!) / (lastIndex! - firstIndex! + 1);
}
@override
......@@ -104,8 +100,8 @@ class ViewportOffsetSpy extends ViewportOffset {
@override
Future<void> animateTo(
double to, {
@required Duration duration,
@required Curve curve,
required Duration duration,
required Curve curve,
}) async {
// Do nothing, not required in test.
}
......@@ -301,7 +297,7 @@ void main() {
root.offset = ViewportOffset.fixed(0.0);
pumpFrame();
expect(inner.geometry.scrollOffsetCorrection, isNull);
expect(inner.geometry?.scrollOffsetCorrection, isNull);
});
test('SliverList - no correction when tiny double precision error', () {
......
......@@ -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/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
......
......@@ -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/rendering.dart';
import '../flutter_test_alternative.dart';
......
......@@ -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/rendering.dart';
......@@ -872,8 +870,7 @@ void main() {
crossAxisOffset: 0.0,
mainAxisPosition: 0.0,
crossAxisPosition: 0.0,
hitTest: (SliverHitTestResult result, { double mainAxisPosition, double crossAxisPosition }) {
expect(result, isNotNull);
hitTest: (SliverHitTestResult result, { required double mainAxisPosition, required double crossAxisPosition }) {
mainAxisPositions.add(mainAxisPosition);
crossAxisPositions.add(crossAxisPosition);
return true;
......@@ -891,8 +888,7 @@ void main() {
crossAxisOffset: 6.0,
mainAxisPosition: 10.0,
crossAxisPosition: 20.0,
hitTest: (SliverHitTestResult result, { double mainAxisPosition, double crossAxisPosition }) {
expect(result, isNotNull);
hitTest: (SliverHitTestResult result, { required double mainAxisPosition, required double crossAxisPosition }) {
mainAxisPositions.add(mainAxisPosition);
crossAxisPositions.add(crossAxisPosition);
return false;
......@@ -910,8 +906,7 @@ void main() {
crossAxisOffset: -6.0,
mainAxisPosition: 10.0,
crossAxisPosition: 20.0,
hitTest: (SliverHitTestResult result, { double mainAxisPosition, double crossAxisPosition }) {
expect(result, isNotNull);
hitTest: (SliverHitTestResult result, { required double mainAxisPosition, required double crossAxisPosition }) {
mainAxisPositions.add(mainAxisPosition);
crossAxisPositions.add(crossAxisPosition);
return false;
......@@ -926,8 +921,8 @@ void main() {
test('addWithAxisOffset with non zero paintOffset', () {
final SliverHitTestResult result = SliverHitTestResult();
double recordedMainAxisPosition;
double recordedCrossAxisPosition;
late double recordedMainAxisPosition;
late double recordedCrossAxisPosition;
final HitTestEntry entry = HitTestEntry(_DummyHitTestTarget());
const Offset paintOffset = Offset(7, 11);
......@@ -937,8 +932,7 @@ void main() {
crossAxisOffset: 6.0,
mainAxisPosition: 10.0,
crossAxisPosition: 20.0,
hitTest: (SliverHitTestResult result, { double mainAxisPosition, double crossAxisPosition }) {
expect(result, isNotNull);
hitTest: (SliverHitTestResult result, { required double mainAxisPosition, required double crossAxisPosition }) {
recordedMainAxisPosition = mainAxisPosition;
recordedCrossAxisPosition = crossAxisPosition;
result.add(entry);
......@@ -949,7 +943,7 @@ void main() {
expect(recordedMainAxisPosition, 10.0 - 5.0);
expect(recordedCrossAxisPosition, 20.0 - 6.0);
expect(
entry.transform..translate(paintOffset.dx, paintOffset.dy),
entry.transform!..translate(paintOffset.dx, paintOffset.dy),
Matrix4.identity(),
);
});
......
......@@ -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/rendering.dart';
import '../flutter_test_alternative.dart';
......
......@@ -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/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
......@@ -104,8 +102,8 @@ void main() {
expect(TableBorder.lerp(tableA, tableC, 0.5), tableB);
expect(TableBorder.lerp(tableA, tableB, 2.0), tableC);
expect(TableBorder.lerp(tableB, tableC, -1.0), tableA);
expect(TableBorder.lerp(tableA, tableC, 0.9195).isUniform, isFalse);
expect(TableBorder.lerp(tableA, tableC, 0.9195).dimensions,
expect(TableBorder.lerp(tableA, tableC, 0.9195)!.isUniform, isFalse);
expect(TableBorder.lerp(tableA, tableC, 0.9195)!.dimensions,
EdgeInsets.lerp(tableA.dimensions, tableC.dimensions, 0.9195));
});
......
......@@ -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/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
......
......@@ -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:math' as math;
import 'package:flutter/rendering.dart';
......
......@@ -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/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
......
......@@ -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
// This file is separate from viewport_test.dart because we can't use both
// testWidgets and rendering_tester in the same file - testWidgets will
// initialize a binding, which rendering_tester will attempt to re-initialize
......@@ -18,7 +16,7 @@ void main() {
const double width = 800;
const double height = 600;
Rect rectExpandedOnAxis(double value) => Rect.fromLTRB(0.0, 0.0 - value, width, height + value);
List<RenderSliver> children;
late List<RenderSliver> children;
setUp(() {
children = <RenderSliver>[
......
......@@ -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
// This file is separate from viewport_caching_test.dart because we can't use
// both testWidgets and rendering_tester in the same file - testWidgets will
// initialize a binding, which rendering_tester will attempt to re-initialize
......@@ -19,15 +17,15 @@ import 'package:flutter/widgets.dart';
class _TestSliverPersistentHeaderDelegate extends SliverPersistentHeaderDelegate {
_TestSliverPersistentHeaderDelegate({
this.key,
this.minExtent,
this.maxExtent,
required this.minExtent,
required this.maxExtent,
this.child,
this.vsync = const TestVSync(),
this.showOnScreenConfiguration = const PersistentHeaderShowOnScreenConfiguration(),
});
final Key key;
final Widget child;
final Key? key;
final Widget? child;
@override
final double maxExtent;
......@@ -36,7 +34,7 @@ class _TestSliverPersistentHeaderDelegate extends SliverPersistentHeaderDelegate
final double minExtent;
@override
final TickerProvider vsync;
final TickerProvider? vsync;
@override
final PersistentHeaderShowOnScreenConfiguration showOnScreenConfiguration;
......@@ -537,11 +535,19 @@ void main() {
});
testWidgets('Nested Viewports showOnScreen', (WidgetTester tester) async {
final List<List<Widget>> children = List<List<Widget>>(10);
final List<ScrollController> controllersX = List<ScrollController>.generate(10, (int i) => ScrollController(initialScrollOffset: 400.0));
final ScrollController controllerY = ScrollController(initialScrollOffset: 400.0);
final List<List<Widget>> children = List<List<Widget>>.generate(10, (int y) {
return List<Widget>.generate(10, (int x) {
return Container(
height: 100.0,
width: 100.0,
child: Text('$x,$y'),
);
});
});
/// Builds a gird:
/// Builds a grid:
///
/// <- x ->
/// 0 1 2 3 4 5 6 7 8 9
......@@ -574,13 +580,7 @@ void main() {
child: ListView(
scrollDirection: Axis.horizontal,
controller: controllersX[y],
children: children[y] = List<Widget>.generate(10, (int x) {
return Container(
height: 100.0,
width: 100.0,
child: Text('$x,$y'),
);
}),
children: children[y],
),
);
}),
......@@ -695,9 +695,15 @@ void main() {
});
group('Nested viewports (same orientation) showOnScreen', () {
List<Widget> children;
final List<Widget> children = List<Widget>.generate(10, (int i) {
return Container(
height: 100.0,
width: 300.0,
child: Text('$i'),
);
});
Future<void> buildNestedScroller({ WidgetTester tester, ScrollController inner, ScrollController outer }) {
Future<void> buildNestedScroller({ required WidgetTester tester, required ScrollController inner, required ScrollController outer }) {
return tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
......@@ -716,13 +722,7 @@ void main() {
width: 300.0,
child: ListView(
controller: inner,
children: children = List<Widget>.generate(10, (int i) {
return Container(
height: 100.0,
width: 300.0,
child: Text('$i'),
);
}),
children: children,
),
),
Container(
......@@ -1127,12 +1127,12 @@ void main() {
});
void testFloatingHeaderShowOnScreen({ bool animated = true, Axis axis = Axis.vertical }) {
final TickerProvider vsync = animated ? const TestVSync() : null;
final TickerProvider? vsync = animated ? const TestVSync() : null;
const Key headerKey = Key('header');
List<Widget> children;
ScrollController controller;
late List<Widget> children;
final ScrollController controller = ScrollController(initialScrollOffset: 300.0);
Widget buildList({ SliverPersistentHeader floatingHeader, bool reversed = false }) {
Widget buildList({ required SliverPersistentHeader floatingHeader, bool reversed = false }) {
return Directionality(
textDirection: TextDirection.ltr,
child: Center(
......@@ -1142,7 +1142,7 @@ void main() {
child: CustomScrollView(
scrollDirection: axis,
center: reversed ? const Key('19') : null,
controller: controller = ScrollController(initialScrollOffset: 300.0),
controller: controller,
slivers: children = List<Widget>.generate(20, (int i) {
return i == 10
? floatingHeader
......@@ -1164,7 +1164,7 @@ void main() {
double mainAxisExtent(WidgetTester tester, Finder finder) {
final RenderObject renderObject = tester.renderObject(finder);
if (renderObject is RenderSliver) {
return renderObject.geometry.paintExtent;
return renderObject.geometry!.paintExtent;
}
final RenderBox renderBox = renderObject as RenderBox;
......@@ -1174,8 +1174,6 @@ void main() {
case Axis.vertical:
return renderBox.size.height;
}
assert(false);
return null;
}
group('animated: $animated, scrollDirection: $axis', () {
......@@ -1437,7 +1435,7 @@ void main() {
group('RenderViewport getOffsetToReveal renderBox to sliver coordinates conversion', () {
const EdgeInsets padding = EdgeInsets.fromLTRB(22, 22, 34, 34);
const Key centerKey = Key('5');
Widget buildList({ Axis axis, bool reverse = false, bool reverseGrowth = false }) {
Widget buildList({ required Axis axis, bool reverse = false, bool reverseGrowth = false }) {
return Directionality(
textDirection: TextDirection.ltr,
child: Center(
......@@ -1613,12 +1611,12 @@ void main() {
}
Future<void> expectFlutterError({
Widget widget,
WidgetTester tester,
String message,
required Widget widget,
required WidgetTester tester,
required String message,
}) async {
final List<FlutterErrorDetails> errors = <FlutterErrorDetails>[];
final FlutterExceptionHandler oldHandler = FlutterError.onError;
final FlutterExceptionHandler? oldHandler = FlutterError.onError;
FlutterError.onError = (FlutterErrorDetails error) => errors.add(error);
try {
await tester.pumpWidget(widget);
......@@ -1705,13 +1703,12 @@ void main() {
final RenderViewport renderViewport = RenderViewport(
crossAxisDirection: AxisDirection.right, offset: ViewportOffset.zero()
);
FlutterError error;
late FlutterError error;
try {
renderViewport.computeMinIntrinsicHeight(0);
} on FlutterError catch (e) {
error = e;
}
expect(error, isNotNull);
expect(
error.toStringDeep(),
'FlutterError\n'
......@@ -1728,7 +1725,6 @@ void main() {
final RenderShrinkWrappingViewport renderShrinkWrappingViewport = RenderShrinkWrappingViewport(
crossAxisDirection: AxisDirection.right, offset: ViewportOffset.zero()
);
error = null;
try {
renderShrinkWrappingViewport.computeMinIntrinsicHeight(0);
} on FlutterError catch (e) {
......
......@@ -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/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
......
......@@ -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/semantics.dart';
import '../flutter_test_alternative.dart';
......
......@@ -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/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
......@@ -236,16 +234,16 @@ void main() {
// TODO(goderbauer): remove awkward workaround when accessing force-merged
// SemanticsData becomes easier, https://github.com/flutter/flutter/issues/25669
SemanticsData mergedChildData;
SemanticsData? mergedChildData;
elevation10.visitChildren((SemanticsNode child) {
expect(mergedChildData, isNull);
mergedChildData = child.getSemanticsData();
return true;
});
expect(mergedChildData.thickness, 15.0);
expect(mergedChildData.elevation, 10.0);
expect(mergedChildData.label, 'abs. elevation 25.0\nabs. elevation 15.0');
expect(mergedChildData!.thickness, 15.0);
expect(mergedChildData!.elevation, 10.0);
expect(mergedChildData!.label, 'abs. elevation 25.0\nabs. elevation 15.0');
semantics.dispose();
});
......@@ -291,16 +289,16 @@ void main() {
// TODO(goderbauer): remove awkward workaround when accessing force-merged
// SemanticsData becomes easier, https://github.com/flutter/flutter/issues/25669
SemanticsData mergedChildData;
SemanticsData? mergedChildData;
elevation10.visitChildren((SemanticsNode child) {
expect(mergedChildData, isNull);
mergedChildData = child.getSemanticsData();
return true;
});
expect(mergedChildData.thickness, 15.0);
expect(mergedChildData.elevation, 10.0);
expect(mergedChildData.label, 'abs. elevation 15.0\nabs. elevation 25.0');
expect(mergedChildData!.thickness, 15.0);
expect(mergedChildData!.elevation, 10.0);
expect(mergedChildData!.label, 'abs. elevation 15.0\nabs. elevation 25.0');
semantics.dispose();
});
......
......@@ -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' show TextDirection;
import 'package:flutter/semantics.dart';
......@@ -17,11 +15,12 @@ void main() {
test('Semantic announcement', () async {
final List<Map<dynamic, dynamic>> log = <Map<dynamic, dynamic>>[];
SystemChannels.accessibility.setMockMessageHandler((Object mockMessage) async {
Future<dynamic> handleMessage(dynamic mockMessage) async {
final Map<dynamic, dynamic> message = mockMessage as Map<dynamic, dynamic>;
log.add(message);
});
}
SystemChannels.accessibility.setMockMessageHandler(handleMessage);
await SemanticsService.announce('announcement 1', TextDirection.ltr);
await SemanticsService.announce('announcement 2', TextDirection.rtl);
......
......@@ -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/rendering.dart';
import 'package:flutter/semantics.dart';
import 'package:vector_math/vector_math_64.dart';
......@@ -11,7 +9,6 @@ import 'package:flutter_test/flutter_test.dart';
import '../rendering/rendering_tester.dart';
void main() {
setUp(() {
debugResetSemanticsIdCounter();
......@@ -32,7 +29,7 @@ void main() {
expect(node.isTagged(tag1), isTrue);
expect(node.isTagged(tag2), isFalse);
node.tags.add(tag2);
node.tags!.add(tag2);
expect(node.isTagged(tag1), isTrue);
expect(node.isTagged(tag2), isTrue);
});
......@@ -90,7 +87,7 @@ void main() {
);
{
FlutterError error;
late FlutterError error;
try {
node.updateWith(
config: config,
......@@ -99,7 +96,6 @@ void main() {
} on FlutterError catch (e) {
error = e;
}
expect(error, isNotNull);
expect(error.toString(), equalsIgnoringHashCodes(
'Failed to replace child semantics nodes because the list of `SemanticsNode`s was mutated.\n'
'Instead of mutating the existing list, create a new list containing the desired `SemanticsNode`s.\n'
......@@ -113,7 +109,7 @@ void main() {
}
{
FlutterError error;
late FlutterError error;
final List<SemanticsNode> modifiedChildren = <SemanticsNode>[
SemanticsNode()
..isMergedIntoParent = true
......@@ -140,7 +136,6 @@ void main() {
} on FlutterError catch (e) {
error = e;
}
expect(error, isNotNull);
expect(error.toStringDeep(), equalsIgnoringHashCodes(
'FlutterError\n'
' Failed to replace child semantics nodes because the list of\n'
......@@ -195,7 +190,7 @@ void main() {
pumpFrame(phase: EnginePhase.flushSemantics);
int expectedActions = SemanticsAction.tap.index | SemanticsAction.longPress.index | SemanticsAction.scrollLeft.index | SemanticsAction.scrollRight.index;
expect(root.debugSemantics.getSemanticsData().actions, expectedActions);
expect(root.debugSemantics!.getSemanticsData().actions, expectedActions);
middle
..hasScrollLeftAction = false
......@@ -205,7 +200,7 @@ void main() {
pumpFrame(phase: EnginePhase.flushSemantics);
expectedActions = SemanticsAction.tap.index | SemanticsAction.longPress.index | SemanticsAction.scrollDown.index | SemanticsAction.scrollRight.index;
expect(root.debugSemantics.getSemanticsData().actions, expectedActions);
expect(root.debugSemantics!.getSemanticsData().actions, expectedActions);
});
});
......@@ -683,8 +678,8 @@ class TestRender extends RenderProxyBox {
this.hasScrollRightAction = false,
this.hasScrollUpAction = false,
this.hasScrollDownAction = false,
this.isSemanticBoundary,
RenderBox child,
this.isSemanticBoundary = false,
RenderBox? child,
}) : super(child);
bool hasTapAction;
......@@ -695,7 +690,6 @@ class TestRender extends RenderProxyBox {
bool hasScrollDownAction;
bool isSemanticBoundary;
@override
void describeSemanticsConfiguration(SemanticsConfiguration config) {
super.describeSemanticsConfiguration(config);
......@@ -717,5 +711,5 @@ class TestRender extends RenderProxyBox {
}
class CustomSortKey extends OrdinalSortKey {
const CustomSortKey(double order, {String name}) : super(order, name: name);
const CustomSortKey(double order, {String? name}) : super(order, name: name);
}
......@@ -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:typed_data';
import 'dart:ui' as ui;
......@@ -48,12 +46,12 @@ void main() {
expect(SemanticsUpdateBuilderSpy.observations.length, 2);
expect(SemanticsUpdateBuilderSpy.observations.containsKey(0), isTrue);
expect(SemanticsUpdateBuilderSpy.observations[0].childrenInTraversalOrder.length, 1);
expect(SemanticsUpdateBuilderSpy.observations[0].childrenInTraversalOrder[0], 1);
expect(SemanticsUpdateBuilderSpy.observations[0]!.childrenInTraversalOrder.length, 1);
expect(SemanticsUpdateBuilderSpy.observations[0]!.childrenInTraversalOrder[0], 1);
expect(SemanticsUpdateBuilderSpy.observations.containsKey(1), isTrue);
expect(SemanticsUpdateBuilderSpy.observations[1].childrenInTraversalOrder.length, 0);
expect(SemanticsUpdateBuilderSpy.observations[1].label, 'outer\ninner\ntext');
expect(SemanticsUpdateBuilderSpy.observations[1]!.childrenInTraversalOrder.length, 0);
expect(SemanticsUpdateBuilderSpy.observations[1]!.label, 'outer\ninner\ntext');
SemanticsUpdateBuilderSpy.observations.clear();
......@@ -79,8 +77,8 @@ void main() {
expect(SemanticsUpdateBuilderSpy.observations.length, 1);
expect(SemanticsUpdateBuilderSpy.observations.containsKey(1), isTrue);
expect(SemanticsUpdateBuilderSpy.observations[1].childrenInTraversalOrder.length, 0);
expect(SemanticsUpdateBuilderSpy.observations[1].label, 'outer\ninner-updated\ntext');
expect(SemanticsUpdateBuilderSpy.observations[1]!.childrenInTraversalOrder.length, 0);
expect(SemanticsUpdateBuilderSpy.observations[1]!.label, 'outer\ninner-updated\ntext');
SemanticsUpdateBuilderSpy.observations.clear();
handle.dispose();
......@@ -99,32 +97,32 @@ class SemanticsUpdateBuilderSpy extends ui.SemanticsUpdateBuilder {
@override
void updateNode({
@required int id,
@required int flags,
@required int actions,
@required int maxValueLength,
@required int currentValueLength,
@required int textSelectionBase,
@required int textSelectionExtent,
@required int platformViewId,
@required int scrollChildren,
@required int scrollIndex,
@required double scrollPosition,
@required double scrollExtentMax,
@required double scrollExtentMin,
@required double elevation,
@required double thickness,
@required Rect rect,
@required String label,
@required String hint,
@required String value,
@required String increasedValue,
@required String decreasedValue,
TextDirection textDirection,
@required Float64List transform,
@required Int32List childrenInTraversalOrder,
@required Int32List childrenInHitTestOrder,
@required Int32List additionalActions,
required int id,
required int flags,
required int actions,
required int maxValueLength,
required int currentValueLength,
required int textSelectionBase,
required int textSelectionExtent,
required int platformViewId,
required int scrollChildren,
required int scrollIndex,
required double scrollPosition,
required double scrollExtentMax,
required double scrollExtentMin,
required double elevation,
required double thickness,
required Rect rect,
required String label,
required String hint,
required String value,
required String increasedValue,
required String decreasedValue,
TextDirection? textDirection,
required Float64List transform,
required Int32List childrenInTraversalOrder,
required Int32List childrenInHitTestOrder,
required Int32List additionalActions,
}) {
// Makes sure we don't send the same id twice.
assert(!observations.containsKey(id));
......@@ -161,32 +159,32 @@ class SemanticsUpdateBuilderSpy extends ui.SemanticsUpdateBuilder {
class SemanticsNodeUpdateObservation {
const SemanticsNodeUpdateObservation({
@required this.id,
@required this.flags,
@required this.actions,
@required this.maxValueLength,
@required this.currentValueLength,
@required this.textSelectionBase,
@required this.textSelectionExtent,
@required this.platformViewId,
@required this.scrollChildren,
@required this.scrollIndex,
@required this.scrollPosition,
@required this.scrollExtentMax,
@required this.scrollExtentMin,
@required this.elevation,
@required this.thickness,
@required this.rect,
@required this.label,
@required this.hint,
@required this.value,
@required this.increasedValue,
@required this.decreasedValue,
required this.id,
required this.flags,
required this.actions,
required this.maxValueLength,
required this.currentValueLength,
required this.textSelectionBase,
required this.textSelectionExtent,
required this.platformViewId,
required this.scrollChildren,
required this.scrollIndex,
required this.scrollPosition,
required this.scrollExtentMax,
required this.scrollExtentMin,
required this.elevation,
required this.thickness,
required this.rect,
required this.label,
required this.hint,
required this.value,
required this.increasedValue,
required this.decreasedValue,
this.textDirection,
@required this.transform,
@required this.childrenInTraversalOrder,
@required this.childrenInHitTestOrder,
@required this.additionalActions,
required this.transform,
required this.childrenInTraversalOrder,
required this.childrenInHitTestOrder,
required this.additionalActions,
});
final int id;
......@@ -210,7 +208,7 @@ class SemanticsNodeUpdateObservation {
final String value;
final String increasedValue;
final String decreasedValue;
final TextDirection textDirection;
final TextDirection? textDirection;
final Float64List transform;
final Int32List childrenInTraversalOrder;
final Int32List childrenInHitTestOrder;
......
......@@ -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/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
......
......@@ -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/widgets.dart';
......
......@@ -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';
......@@ -28,7 +26,7 @@ class ThirdTestIntent extends SecondTestIntent {
class TestAction extends CallbackAction<TestIntent> {
TestAction({
@required OnInvokeCallback onInvoke,
required OnInvokeCallback onInvoke,
}) : assert(onInvoke != null),
super(onInvoke: onInvoke);
......@@ -64,23 +62,23 @@ class TestAction extends CallbackAction<TestIntent> {
class TestDispatcher extends ActionDispatcher {
const TestDispatcher({this.postInvoke});
final PostInvokeCallback postInvoke;
final PostInvokeCallback? postInvoke;
@override
Object invokeAction(Action<Intent> action, Intent intent, [BuildContext context]) {
final Object result = super.invokeAction(action, intent, context);
Object? invokeAction(Action<Intent> action, Intent intent, [BuildContext? context]) {
final Object? result = super.invokeAction(action, intent, context);
postInvoke?.call(action: action, intent: intent, dispatcher: this);
return result;
}
}
class TestDispatcher1 extends TestDispatcher {
const TestDispatcher1({PostInvokeCallback postInvoke}) : super(postInvoke: postInvoke);
const TestDispatcher1({PostInvokeCallback? postInvoke}) : super(postInvoke: postInvoke);
}
void main() {
testWidgets('CallbackAction passes correct intent when invoked.', (WidgetTester tester) async {
Intent passedIntent;
late Intent passedIntent;
final TestAction action = TestAction(onInvoke: (Intent intent) {
passedIntent = intent;
return true;
......@@ -94,7 +92,7 @@ void main() {
await tester.pumpWidget(Container());
bool invoked = false;
const ActionDispatcher dispatcher = ActionDispatcher();
final Object result = dispatcher.invokeAction(
final Object? result = dispatcher.invokeAction(
TestAction(
onInvoke: (Intent intent) {
invoked = true;
......@@ -108,11 +106,11 @@ void main() {
});
});
group(Actions, () {
Intent invokedIntent;
Action<Intent> invokedAction;
ActionDispatcher invokedDispatcher;
Intent? invokedIntent;
Action<Intent>? invokedAction;
ActionDispatcher? invokedDispatcher;
void collect({Action<Intent> action, Intent intent, ActionDispatcher dispatcher}) {
void collect({Action<Intent>? action, Intent? intent, ActionDispatcher? dispatcher}) {
invokedIntent = intent;
invokedAction = action;
invokedDispatcher = dispatcher;
......@@ -145,8 +143,8 @@ void main() {
);
await tester.pump();
final Object result = Actions.invoke(
containerKey.currentContext,
final Object? result = Actions.invoke(
containerKey.currentContext!,
const TestIntent(),
);
expect(result, isTrue);
......@@ -174,8 +172,8 @@ void main() {
);
await tester.pump();
final Object result = Actions.invoke<TestIntent>(
containerKey.currentContext,
final Object? result = Actions.invoke<TestIntent>(
containerKey.currentContext!,
intent,
);
expect(result, isTrue);
......@@ -208,8 +206,8 @@ void main() {
);
await tester.pump();
final Object result = Actions.invoke<TestIntent>(
containerKey.currentContext,
final Object? result = Actions.invoke<TestIntent>(
containerKey.currentContext!,
intent,
);
expect(result, isTrue);
......@@ -243,8 +241,8 @@ void main() {
);
await tester.pump();
final Object result = Actions.invoke<TestIntent>(
containerKey.currentContext,
final Object? result = Actions.invoke<TestIntent>(
containerKey.currentContext!,
intent,
);
expect(result, isTrue);
......@@ -267,7 +265,7 @@ void main() {
await tester.pump();
final ActionDispatcher dispatcher = Actions.of(
containerKey.currentContext,
containerKey.currentContext!,
nullOk: true,
);
expect(dispatcher, equals(testDispatcher));
......@@ -296,9 +294,9 @@ void main() {
);
await tester.pump();
expect(Actions.find<TestIntent>(containerKey.currentContext), equals(testAction));
expect(() => Actions.find<DoNothingIntent>(containerKey.currentContext), throwsAssertionError);
expect(Actions.find<DoNothingIntent>(containerKey.currentContext, nullOk: true), isNull);
expect(Actions.find<TestIntent>(containerKey.currentContext!), equals(testAction));
expect(() => Actions.find<DoNothingIntent>(containerKey.currentContext!), throwsAssertionError);
expect(Actions.find<DoNothingIntent>(containerKey.currentContext!, nullOk: true), isNull);
await tester.pumpWidget(
Actions(
......@@ -316,9 +314,9 @@ void main() {
);
await tester.pump();
expect(Actions.find<TestIntent>(containerKey.currentContext), equals(testAction));
expect(() => Actions.find<DoNothingIntent>(containerKey.currentContext), throwsAssertionError);
expect(Actions.find<DoNothingIntent>(containerKey.currentContext, nullOk: true), isNull);
expect(Actions.find<TestIntent>(containerKey.currentContext!), equals(testAction));
expect(() => Actions.find<DoNothingIntent>(containerKey.currentContext!), throwsAssertionError);
expect(Actions.find<DoNothingIntent>(containerKey.currentContext!, nullOk: true), isNull);
});
testWidgets('FocusableActionDetector keeps track of focus and hover even when disabled.', (WidgetTester tester) async {
FocusManager.instance.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
......@@ -407,7 +405,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);
// Test default
await tester.pumpWidget(
......@@ -421,7 +419,7 @@ void main() {
),
);
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.forbidden);
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.forbidden);
});
testWidgets('Actions.invoke returns the value of Action.invoke', (WidgetTester tester) async {
final GlobalKey containerKey = GlobalKey();
......@@ -446,8 +444,8 @@ void main() {
);
await tester.pump();
final Object result = Actions.invoke<TestIntent>(
containerKey.currentContext,
final Object? result = Actions.invoke<TestIntent>(
containerKey.currentContext!,
intent,
);
expect(identical(result, sentinel), isTrue);
......@@ -509,8 +507,8 @@ void main() {
),
);
Object result = Actions.invoke(
containerKey.currentContext,
Object? result = Actions.invoke(
containerKey.currentContext!,
const TestIntent(),
);
expect(enabled1, isFalse);
......@@ -519,14 +517,14 @@ void main() {
action1.enabled = true;
result = Actions.invoke(
containerKey.currentContext,
containerKey.currentContext!,
const TestIntent(),
);
expect(enabled1, isTrue);
expect(result, isTrue);
expect(invoked1, isTrue);
bool enabledChanged;
bool? enabledChanged;
await tester.pumpWidget(
Actions(
actions: <Type, Action<Intent>>{
......@@ -548,7 +546,7 @@ void main() {
await tester.pump();
result = Actions.invoke<TestIntent>(
containerKey.currentContext,
containerKey.currentContext!,
const SecondTestIntent(),
);
expect(enabledChanged, isNull);
......@@ -559,7 +557,7 @@ void main() {
action2.enabled = true;
expect(enabledChanged, isTrue);
result = Actions.invoke<TestIntent>(
containerKey.currentContext,
containerKey.currentContext!,
const SecondTestIntent(),
);
expect(enabled2, isTrue);
......@@ -622,18 +620,18 @@ void main() {
group(FocusableActionDetector, () {
const Intent intent = TestIntent();
bool invoked;
bool hovering;
bool focusing;
FocusNode focusNode;
Action<Intent> testAction;
late bool invoked;
late bool hovering;
late bool focusing;
late FocusNode focusNode;
late Action<Intent> testAction;
Future<void> pumpTest(
WidgetTester tester, {
bool enabled = true,
bool directional = false,
bool supplyCallbacks = true,
@required Key key,
required Key key,
}) async {
await tester.pumpWidget(
MediaQuery(
......
......@@ -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/widgets.dart';
......@@ -26,20 +24,17 @@ void main() {
await tester.pumpWidget(
const Align(
key: GlobalObjectKey<State<StatefulWidget>>(null),
alignment: Alignment.topLeft,
),
);
await tester.pumpWidget(const Directionality(
textDirection: TextDirection.rtl,
child: Align(
key: GlobalObjectKey<State<StatefulWidget>>(null),
alignment: AlignmentDirectional.topStart,
),
));
await tester.pumpWidget(
const Align(
key: GlobalObjectKey<State<StatefulWidget>>(null),
alignment: Alignment.topLeft,
),
);
......@@ -108,7 +103,7 @@ void main() {
),
);
final Size size = alignKey.currentContext.size;
final Size size = alignKey.currentContext!.size!;
expect(size.width, equals(800.0));
expect(size.height, equals(10.0));
});
......
......@@ -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/widgets.dart';
......
......@@ -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/widgets.dart';
......@@ -47,7 +45,7 @@ void main() {
),
);
final RenderDecoratedBox box = key.currentContext.findRenderObject() as RenderDecoratedBox;
final RenderDecoratedBox box = key.currentContext!.findRenderObject() as RenderDecoratedBox;
actualDecoration = box.decoration as BoxDecoration;
expect(actualDecoration.color, equals(decorationA.color));
......@@ -59,7 +57,7 @@ void main() {
),
);
expect(key.currentContext.findRenderObject(), equals(box));
expect(key.currentContext!.findRenderObject(), equals(box));
actualDecoration = box.decoration as BoxDecoration;
expect(actualDecoration.color, equals(decorationA.color));
......
......@@ -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/scheduler.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/rendering.dart';
......@@ -373,7 +371,7 @@ class _TickerWatchingWidget extends StatefulWidget {
}
class _TickerWatchingWidgetState extends State<_TickerWatchingWidget> with SingleTickerProviderStateMixin {
Ticker ticker;
late Ticker ticker;
@override
void initState() {
......
......@@ -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/src/foundation/diagnostics.dart';
import 'package:flutter/widgets.dart';
......@@ -37,11 +35,11 @@ void main() {
&& widget.itemBuilder == builder;
}), findsOneWidget);
listKey.currentState.insertItem(0);
listKey.currentState!.insertItem(0);
await tester.pump();
expect(find.text('item 2'), findsOneWidget);
listKey.currentState.removeItem(
listKey.currentState!.removeItem(
2,
(BuildContext context, Animation<double> animation) {
return const SizedBox(
......@@ -90,8 +88,8 @@ void main() {
expect(find.text('item 1'), findsOneWidget);
expect(animations.containsKey(0), true);
expect(animations.containsKey(1), true);
expect(animations[0].value, 1.0);
expect(animations[1].value, 1.0);
expect(animations[0]!.value, 1.0);
expect(animations[1]!.value, 1.0);
});
testWidgets('insert', (WidgetTester tester) async {
......@@ -125,7 +123,7 @@ void main() {
double itemTop(int index) => tester.getTopLeft(find.byKey(ValueKey<int>(index), skipOffstage: false)).dy;
double itemBottom(int index) => tester.getBottomLeft(find.byKey(ValueKey<int>(index), skipOffstage: false)).dy;
listKey.currentState.insertItem(
listKey.currentState!.insertItem(
0,
duration: const Duration(milliseconds: 100),
);
......@@ -143,11 +141,11 @@ void main() {
expect(itemTop(0), 0.0);
expect(itemBottom(0), 100.0);
listKey.currentState.insertItem(
listKey.currentState!.insertItem(
0,
duration: const Duration(milliseconds: 100),
);
listKey.currentState.insertItem(
listKey.currentState!.insertItem(
0,
duration: const Duration(milliseconds: 100),
);
......@@ -223,7 +221,7 @@ void main() {
expect(find.text('item 2'), findsOneWidget);
items.removeAt(0);
listKey.currentState.removeItem(
listKey.currentState!.removeItem(
0,
(BuildContext context, Animation<double> animation) => buildItem(context, 0, animation),
duration: const Duration(milliseconds: 100),
......@@ -289,11 +287,11 @@ void main() {
expect(tester.getTopLeft(find.text('item 0')).dy, 200);
expect(tester.getTopLeft(find.text('item 1')).dy, 300);
listKey.currentState.insertItem(3);
listKey.currentState!.insertItem(3);
await tester.pumpAndSettle();
expect(tester.getTopLeft(find.text('item 3')).dy, 500);
listKey.currentState.removeItem(0,
listKey.currentState!.removeItem(0,
(BuildContext context, Animation<double> animation) {
return SizeTransition(
sizeFactor: animation,
......@@ -327,13 +325,12 @@ void main() {
(WidgetTester tester) async {
final GlobalKey key = GlobalKey();
await tester.pumpWidget(Container(key: key));
FlutterError error;
late FlutterError error;
try {
AnimatedList.of(key.currentContext);
AnimatedList.of(key.currentContext!);
} on FlutterError catch (e) {
error = e;
}
expect(error, isNotNull);
expect(error.diagnostics.length, 4);
expect(error.diagnostics[2].level, DiagnosticLevel.hint);
expect(
......
......@@ -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/widgets.dart';
......
......@@ -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/widgets.dart';
......@@ -44,12 +42,12 @@ void main() {
),
);
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0)));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0)));
await tester.pumpWidget(
......@@ -71,17 +69,17 @@ void main() {
const Offset first = Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0);
const Offset last = Offset(37.0 + 59.0 / 2.0, 31.0 + 71.0 / 2.0);
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(first));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(Offset.lerp(first, last, 0.5)));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(last));
expect(box, hasAGoodToStringDeep);
......@@ -128,12 +126,12 @@ void main() {
),
);
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0)));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0)));
await tester.pumpWidget(
......@@ -157,17 +155,17 @@ void main() {
const Offset first = Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0);
const Offset last = Offset(37.0 + 59.0 / 2.0, 31.0 + 71.0 / 2.0);
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(first));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(Offset.lerp(first, last, 0.5)));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(last));
expect(box, hasAGoodToStringDeep);
......@@ -214,12 +212,12 @@ void main() {
),
);
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(800.0 - 50.0 - 70.0 / 2.0, 30.0 + 110.0 / 2.0)));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(800.0 - 50.0 - 70.0 / 2.0, 30.0 + 110.0 / 2.0)));
await tester.pumpWidget(
......@@ -243,17 +241,17 @@ void main() {
const Offset first = Offset(800.0 - 50.0 - 70.0 / 2.0, 30.0 + 110.0 / 2.0);
const Offset last = Offset(800.0 - 37.0 - 59.0 / 2.0, 31.0 + 71.0 / 2.0);
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(first));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(Offset.lerp(first, last, 0.5)));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(last));
expect(box, hasAGoodToStringDeep);
......@@ -298,12 +296,12 @@ void main() {
),
);
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
await tester.pumpWidget(
......@@ -322,12 +320,12 @@ void main() {
),
);
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(100.0, 100.0)));
await tester.pumpWidget(
......@@ -346,17 +344,17 @@ void main() {
),
);
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(100.0, 100.0)));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(150.0, 150.0)));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(200.0, 200.0)));
});
......@@ -381,12 +379,12 @@ void main() {
),
);
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
await tester.pumpWidget(
......@@ -405,17 +403,17 @@ void main() {
),
);
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 50.0)));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 100.0)));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 150.0)));
});
......@@ -442,12 +440,12 @@ void main() {
),
);
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
await tester.pumpWidget(
......@@ -468,12 +466,12 @@ void main() {
),
);
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(100.0, 100.0)));
await tester.pumpWidget(
......@@ -494,17 +492,17 @@ void main() {
),
);
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(100.0, 100.0)));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(150.0, 150.0)));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(200.0, 200.0)));
});
......@@ -531,12 +529,12 @@ void main() {
),
);
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
await tester.pumpWidget(
......@@ -557,17 +555,17 @@ void main() {
),
);
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 50.0)));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 100.0)));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 150.0)));
});
......@@ -594,12 +592,12 @@ void main() {
),
);
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(750.0, 50.0)));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(750.0, 50.0)));
await tester.pumpWidget(
......@@ -620,12 +618,12 @@ void main() {
),
);
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(750.0, 50.0)));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(700.0, 100.0)));
await tester.pumpWidget(
......@@ -646,17 +644,17 @@ void main() {
),
);
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(700.0, 100.0)));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(650.0, 150.0)));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(600.0, 200.0)));
});
......@@ -683,12 +681,12 @@ void main() {
),
);
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(750.0, 50.0)));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(750.0, 50.0)));
await tester.pumpWidget(
......@@ -709,17 +707,17 @@ void main() {
),
);
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(450.0, 50.0)));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(450.0, 100.0)));
await tester.pump(const Duration(seconds: 1));
box = key.currentContext.findRenderObject() as RenderBox;
box = key.currentContext!.findRenderObject() as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(450.0, 150.0)));
});
......
......@@ -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/widgets.dart';
......@@ -144,7 +142,7 @@ void main() {
await tester.pump(Duration(milliseconds: millis));
}
void verify({ double size, RenderAnimatedSizeState state }) {
void verify({ double? size, RenderAnimatedSizeState? state }) {
assert(size != null || state != null);
final RenderAnimatedSize box = tester.renderObject(find.byType(AnimatedSize));
if (size != 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/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
......@@ -211,9 +209,12 @@ void main() {
});
testWidgets('AnimatedSwitcher uses custom layout.', (WidgetTester tester) async {
Widget newLayoutBuilder(Widget currentChild, List<Widget> previousChildren) {
Widget newLayoutBuilder(Widget? currentChild, List<Widget> previousChildren) {
return Column(
children: previousChildren + <Widget>[currentChild],
children: <Widget>[
...previousChildren,
if (currentChild != null) currentChild,
],
);
}
......@@ -230,16 +231,13 @@ void main() {
});
testWidgets('AnimatedSwitcher uses custom transitions.', (WidgetTester tester) async {
final List<Widget> foundChildren = <Widget>[];
Widget newLayoutBuilder(Widget currentChild, List<Widget> previousChildren) {
foundChildren.clear();
if (currentChild != null) {
foundChildren.add(currentChild);
}
foundChildren.addAll(previousChildren);
return Column(
children: foundChildren,
);
late List<Widget> foundChildren;
Widget newLayoutBuilder(Widget? currentChild, List<Widget> previousChildren) {
foundChildren = <Widget>[
if (currentChild != null) currentChild,
...previousChildren,
];
return Column(children: foundChildren);
}
Widget newTransitionBuilder(Widget child, Animation<double> animation) {
......@@ -381,16 +379,13 @@ void main() {
final UniqueKey containerTwo = UniqueKey();
final UniqueKey containerThree = UniqueKey();
final List<Widget> foundChildren = <Widget>[];
Widget newLayoutBuilder(Widget currentChild, List<Widget> previousChildren) {
foundChildren.clear();
if (currentChild != null) {
foundChildren.add(currentChild);
}
foundChildren.addAll(previousChildren);
return Column(
children: foundChildren,
);
late List<Widget> foundChildren;
Widget newLayoutBuilder(Widget? currentChild, List<Widget> previousChildren) {
foundChildren = <Widget>[
if (currentChild != null) currentChild,
...previousChildren,
];
return Column(children: foundChildren);
}
// Insert three unique children so that we have some previous children.
......@@ -472,7 +467,7 @@ void main() {
}
class StatefulTest extends StatefulWidget {
const StatefulTest({Key key}) : super(key: key);
const StatefulTest({Key? key}) : super(key: key);
@override
StatefulTestState createState() => StatefulTestState();
......
......@@ -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' show window;
import 'package:flutter/rendering.dart';
......@@ -32,12 +30,12 @@ void main() {
),
),
);
int result = RendererBinding.instance.renderView.debugLayer.find<int>(Offset(
int? result = RendererBinding.instance!.renderView.debugLayer!.find<int>(Offset(
10.0 * window.devicePixelRatio,
10.0 * window.devicePixelRatio,
));
expect(result, null);
result = RendererBinding.instance.renderView.debugLayer.find<int>(Offset(
result = RendererBinding.instance!.renderView.debugLayer!.find<int>(Offset(
50.0 * window.devicePixelRatio,
50.0 * window.devicePixelRatio,
));
......
......@@ -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/widgets.dart';
......
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