Unverified Commit 019e90f7 authored by Kate Lovett's avatar Kate Lovett Committed by GitHub

[NNBD] Migrates some rendering tests (#67449)

parent 35174124
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
...@@ -408,7 +406,7 @@ void main() { ...@@ -408,7 +406,7 @@ void main() {
test('ignore key event from web platform', () async { test('ignore key event from web platform', () async {
final TextSelectionDelegate delegate = FakeEditableTextState(); final TextSelectionDelegate delegate = FakeEditableTextState();
final ViewportOffset viewportOffset = ViewportOffset.zero(); final ViewportOffset viewportOffset = ViewportOffset.zero();
TextSelection currentSelection; late TextSelection currentSelection;
final RenderEditable editable = RenderEditable( final RenderEditable editable = RenderEditable(
backgroundCursorColor: Colors.grey, backgroundCursorColor: Colors.grey,
selectionColor: Colors.black, selectionColor: Colors.black,
...@@ -460,7 +458,7 @@ void main() { ...@@ -460,7 +458,7 @@ void main() {
test('selects correct place with offsets', () { test('selects correct place with offsets', () {
final TextSelectionDelegate delegate = FakeEditableTextState(); final TextSelectionDelegate delegate = FakeEditableTextState();
final ViewportOffset viewportOffset = ViewportOffset.zero(); final ViewportOffset viewportOffset = ViewportOffset.zero();
TextSelection currentSelection; late TextSelection currentSelection;
final RenderEditable editable = RenderEditable( final RenderEditable editable = RenderEditable(
backgroundCursorColor: Colors.grey, backgroundCursorColor: Colors.grey,
selectionColor: Colors.black, selectionColor: Colors.black,
...@@ -545,7 +543,7 @@ void main() { ...@@ -545,7 +543,7 @@ void main() {
test('selects correct place when offsets are flipped', () { test('selects correct place when offsets are flipped', () {
final TextSelectionDelegate delegate = FakeEditableTextState(); final TextSelectionDelegate delegate = FakeEditableTextState();
final ViewportOffset viewportOffset = ViewportOffset.zero(); final ViewportOffset viewportOffset = ViewportOffset.zero();
TextSelection currentSelection; late TextSelection currentSelection;
final RenderEditable editable = RenderEditable( final RenderEditable editable = RenderEditable(
backgroundCursorColor: Colors.grey, backgroundCursorColor: Colors.grey,
selectionColor: Colors.black, selectionColor: Colors.black,
...@@ -578,7 +576,7 @@ void main() { ...@@ -578,7 +576,7 @@ void main() {
test('selection does not flicker as user is dragging', () { test('selection does not flicker as user is dragging', () {
int selectionChangedCount = 0; int selectionChangedCount = 0;
TextSelection updatedSelection; TextSelection? updatedSelection;
final TextSelectionDelegate delegate = FakeEditableTextState(); final TextSelectionDelegate delegate = FakeEditableTextState();
const TextSpan text = TextSpan( const TextSpan text = TextSpan(
text: 'abc def ghi', text: 'abc def ghi',
...@@ -630,8 +628,8 @@ void main() { ...@@ -630,8 +628,8 @@ void main() {
editable2.selectPositionAt(from: const Offset(30, 2), to: const Offset(48, 2), cause: SelectionChangedCause.drag); editable2.selectPositionAt(from: const Offset(30, 2), to: const Offset(48, 2), cause: SelectionChangedCause.drag);
pumpFrame(); pumpFrame();
expect(updatedSelection.baseOffset, 3); expect(updatedSelection!.baseOffset, 3);
expect(updatedSelection.extentOffset, 5); expect(updatedSelection!.extentOffset, 5);
expect(selectionChangedCount, 1); expect(selectionChangedCount, 1);
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/61028 }, skip: isBrowser); // https://github.com/flutter/flutter/issues/61028
...@@ -742,7 +740,7 @@ void main() { ...@@ -742,7 +740,7 @@ void main() {
test('arrow keys and delete handle simple text correctly', () async { test('arrow keys and delete handle simple text correctly', () async {
final TextSelectionDelegate delegate = FakeEditableTextState(); final TextSelectionDelegate delegate = FakeEditableTextState();
final ViewportOffset viewportOffset = ViewportOffset.zero(); final ViewportOffset viewportOffset = ViewportOffset.zero();
TextSelection currentSelection; late TextSelection currentSelection;
final RenderEditable editable = RenderEditable( final RenderEditable editable = RenderEditable(
backgroundCursorColor: Colors.grey, backgroundCursorColor: Colors.grey,
selectionColor: Colors.black, selectionColor: Colors.black,
...@@ -791,7 +789,7 @@ void main() { ...@@ -791,7 +789,7 @@ void main() {
test('arrow keys and delete handle surrogate pairs correctly', () async { test('arrow keys and delete handle surrogate pairs correctly', () async {
final TextSelectionDelegate delegate = FakeEditableTextState(); final TextSelectionDelegate delegate = FakeEditableTextState();
final ViewportOffset viewportOffset = ViewportOffset.zero(); final ViewportOffset viewportOffset = ViewportOffset.zero();
TextSelection currentSelection; late TextSelection currentSelection;
final RenderEditable editable = RenderEditable( final RenderEditable editable = RenderEditable(
backgroundCursorColor: Colors.grey, backgroundCursorColor: Colors.grey,
selectionColor: Colors.black, selectionColor: Colors.black,
...@@ -841,7 +839,7 @@ void main() { ...@@ -841,7 +839,7 @@ void main() {
test('arrow keys and delete handle grapheme clusters correctly', () async { test('arrow keys and delete handle grapheme clusters correctly', () async {
final TextSelectionDelegate delegate = FakeEditableTextState(); final TextSelectionDelegate delegate = FakeEditableTextState();
final ViewportOffset viewportOffset = ViewportOffset.zero(); final ViewportOffset viewportOffset = ViewportOffset.zero();
TextSelection currentSelection; late TextSelection currentSelection;
final RenderEditable editable = RenderEditable( final RenderEditable editable = RenderEditable(
backgroundCursorColor: Colors.grey, backgroundCursorColor: Colors.grey,
selectionColor: Colors.black, selectionColor: Colors.black,
...@@ -891,7 +889,7 @@ void main() { ...@@ -891,7 +889,7 @@ void main() {
test('arrow keys and delete handle surrogate pairs correctly', () async { test('arrow keys and delete handle surrogate pairs correctly', () async {
final TextSelectionDelegate delegate = FakeEditableTextState(); final TextSelectionDelegate delegate = FakeEditableTextState();
final ViewportOffset viewportOffset = ViewportOffset.zero(); final ViewportOffset viewportOffset = ViewportOffset.zero();
TextSelection currentSelection; late TextSelection currentSelection;
final RenderEditable editable = RenderEditable( final RenderEditable editable = RenderEditable(
backgroundCursorColor: Colors.grey, backgroundCursorColor: Colors.grey,
selectionColor: Colors.black, selectionColor: Colors.black,
...@@ -1048,11 +1046,11 @@ void main() { ...@@ -1048,11 +1046,11 @@ void main() {
// Give it a width that forces the editable to wrap. // Give it a width that forces the editable to wrap.
editable.layout(const BoxConstraints.tightFor(width: 200)); editable.layout(const BoxConstraints.tightFor(width: 200));
final Rect composingRect = editable.getRectForComposingRange(const TextRange(start: 0, end: 20 + 2)); final Rect composingRect = editable.getRectForComposingRange(const TextRange(start: 0, end: 20 + 2))!;
// Since the range covers an entire line, the Rect should also be almost // Since the range covers an entire line, the Rect should also be almost
// as wide as the entire paragraph (give or take 1 character). // as wide as the entire paragraph (give or take 1 character).
expect(composingRect?.width, greaterThan(200 - 10)); expect(composingRect.width, greaterThan(200 - 10));
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/66089 }, skip: isBrowser); // https://github.com/flutter/flutter/issues/66089
}); });
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:async'; import 'dart:async';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -30,9 +28,4 @@ void main() { ...@@ -30,9 +28,4 @@ void main() {
}, skip: !kIsWeb); }, skip: !kIsWeb);
} }
class TestRenderBinding extends BindingBase with SchedulerBinding, ServicesBinding, GestureBinding, SemanticsBinding, RendererBinding { class TestRenderBinding extends BindingBase with SchedulerBinding, ServicesBinding, GestureBinding, SemanticsBinding, RendererBinding {}
@override
void initInstances() {
super.initInstances();
}
}
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -28,7 +26,7 @@ void main() { ...@@ -28,7 +26,7 @@ void main() {
const double slightlyLarger = 438.8571428571429; const double slightlyLarger = 438.8571428571429;
const double slightlySmaller = 438.85714285714283; const double slightlySmaller = 438.85714285714283;
final List<dynamic> exceptions = <dynamic>[]; final List<dynamic> exceptions = <dynamic>[];
final FlutterExceptionHandler oldHandler = FlutterError.onError; final FlutterExceptionHandler? oldHandler = FlutterError.onError;
FlutterError.onError = (FlutterErrorDetails details) { FlutterError.onError = (FlutterErrorDetails details) {
exceptions.add(details.exception); exceptions.add(details.exception);
}; };
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' as ui show Image; import 'dart:ui' as ui show Image;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -179,35 +177,35 @@ Future<void> main() async { ...@@ -179,35 +177,35 @@ Future<void> main() async {
test('Render image disposes its image', () async { test('Render image disposes its image', () async {
final ui.Image image = await createTestImage(width: 10, height: 10, cache: false); final ui.Image image = await createTestImage(width: 10, height: 10, cache: false);
expect(image.debugGetOpenHandleStackTraces().length, 1); expect(image.debugGetOpenHandleStackTraces()!.length, 1);
final RenderImage renderImage = RenderImage(image: image.clone()); final RenderImage renderImage = RenderImage(image: image.clone());
expect(image.debugGetOpenHandleStackTraces().length, 2); expect(image.debugGetOpenHandleStackTraces()!.length, 2);
renderImage.image = image.clone(); renderImage.image = image.clone();
expect(image.debugGetOpenHandleStackTraces().length, 2); expect(image.debugGetOpenHandleStackTraces()!.length, 2);
renderImage.image = null; renderImage.image = null;
expect(image.debugGetOpenHandleStackTraces().length, 1); expect(image.debugGetOpenHandleStackTraces()!.length, 1);
image.dispose(); image.dispose();
expect(image.debugGetOpenHandleStackTraces().length, 0); expect(image.debugGetOpenHandleStackTraces()!.length, 0);
}, skip: kIsWeb); // Web doesn't track open image handles. }, skip: kIsWeb); // Web doesn't track open image handles.
test('Render image does not dispose its image if setting the same image twice', () async { test('Render image does not dispose its image if setting the same image twice', () async {
final ui.Image image = await createTestImage(width: 10, height: 10, cache: false); final ui.Image image = await createTestImage(width: 10, height: 10, cache: false);
expect(image.debugGetOpenHandleStackTraces().length, 1); expect(image.debugGetOpenHandleStackTraces()!.length, 1);
final RenderImage renderImage = RenderImage(image: image.clone()); final RenderImage renderImage = RenderImage(image: image.clone());
expect(image.debugGetOpenHandleStackTraces().length, 2); expect(image.debugGetOpenHandleStackTraces()!.length, 2);
renderImage.image = renderImage.image; renderImage.image = renderImage.image;
expect(image.debugGetOpenHandleStackTraces().length, 2); expect(image.debugGetOpenHandleStackTraces()!.length, 2);
renderImage.image = null; renderImage.image = null;
expect(image.debugGetOpenHandleStackTraces().length, 1); expect(image.debugGetOpenHandleStackTraces()!.length, 1);
image.dispose(); image.dispose();
expect(image.debugGetOpenHandleStackTraces().length, 0); expect(image.debugGetOpenHandleStackTraces()!.length, 0);
}, skip: kIsWeb); // Web doesn't track open image handles. }, skip: kIsWeb); // Web doesn't track open image handles.
} }
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' as ui show window; import 'dart:ui' as ui show window;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -29,8 +27,8 @@ class TestLayout { ...@@ -29,8 +27,8 @@ class TestLayout {
), ),
); );
} }
RenderBox root; late RenderBox root;
RenderBox child; late RenderBox child;
bool painted = false; bool painted = false;
} }
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import '../flutter_test_alternative.dart'; import '../flutter_test_alternative.dart';
......
...@@ -2,11 +2,8 @@ ...@@ -2,11 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:ui'; import 'dart:ui';
import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
...@@ -42,7 +39,7 @@ void main() { ...@@ -42,7 +39,7 @@ void main() {
] ]
).build(); ).build();
final int result = root.find<int>(Offset.zero); final int result = root.find<int>(Offset.zero)!;
expect(result, 3); expect(result, 3);
}); });
...@@ -348,9 +345,9 @@ void main() { ...@@ -348,9 +345,9 @@ void main() {
); );
void expectOneAnnotation({ void expectOneAnnotation({
@required Offset globalPosition, required Offset globalPosition,
@required int value, required int value,
@required Offset localPosition, required Offset localPosition,
}) { }) {
expect( expect(
root.findAllAnnotations<int>(globalPosition).entries.toList(), root.findAllAnnotations<int>(globalPosition).entries.toList(),
...@@ -747,7 +744,7 @@ class _Layers { ...@@ -747,7 +744,7 @@ class _Layers {
final ContainerLayer root; final ContainerLayer root;
// Each element must be instance of Layer or _Layers. // Each element must be instance of Layer or _Layers.
final List<Object> children; final List<Object>? children;
bool _assigned = false; bool _assigned = false;
// Build the layer tree by calling each child's `build`, then append children // Build the layer tree by calling each child's `build`, then append children
...@@ -756,8 +753,8 @@ class _Layers { ...@@ -756,8 +753,8 @@ class _Layers {
assert(!_assigned); assert(!_assigned);
_assigned = true; _assigned = true;
if (children != null) { if (children != null) {
for (final Object child in children) { for (final Object child in children!) {
Layer layer; late Layer layer;
if (child is Layer) { if (child is Layer) {
layer = child; layer = child;
} else if (child is _Layers) { } else if (child is _Layers) {
...@@ -775,7 +772,7 @@ class _Layers { ...@@ -775,7 +772,7 @@ class _Layers {
// This layer's [findAnnotation] can be controlled by the given arguments. // This layer's [findAnnotation] can be controlled by the given arguments.
class _TestAnnotatedLayer extends Layer { class _TestAnnotatedLayer extends Layer {
_TestAnnotatedLayer(this.value, { _TestAnnotatedLayer(this.value, {
@required this.opaque, required this.opaque,
this.offset = Offset.zero, this.offset = Offset.zero,
this.size, this.size,
}); });
...@@ -801,10 +798,10 @@ class _TestAnnotatedLayer extends Layer { ...@@ -801,10 +798,10 @@ class _TestAnnotatedLayer extends Layer {
/// ///
/// If [offset] is set, then the offset is applied to the size region before /// If [offset] is set, then the offset is applied to the size region before
/// hit testing in [find]. /// hit testing in [find].
final Size size; final Size? size;
@override @override
EngineLayer addToScene(SceneBuilder builder, [Offset layerOffset = Offset.zero]) { EngineLayer? addToScene(SceneBuilder builder, [Offset layerOffset = Offset.zero]) {
return null; return null;
} }
...@@ -812,14 +809,14 @@ class _TestAnnotatedLayer extends Layer { ...@@ -812,14 +809,14 @@ class _TestAnnotatedLayer extends Layer {
// [offset] & [size]. If it is hit, it adds [value] to result and returns // [offset] & [size]. If it is hit, it adds [value] to result and returns
// [opaque]; otherwise it directly returns false. // [opaque]; otherwise it directly returns false.
@override @override
bool findAnnotations<S>( bool findAnnotations<S extends Object>(
AnnotationResult<S> result, AnnotationResult<S> result,
Offset localPosition, { Offset localPosition, {
bool onlyFirst, required bool onlyFirst,
}) { }) {
if (S != int) if (S != int)
return false; return false;
if (size != null && !(offset & size).contains(localPosition)) if (size != null && !(offset & size!).contains(localPosition))
return false; return false;
final Object untypedValue = value; final Object untypedValue = value;
final S typedValue = untypedValue as S; final S typedValue = untypedValue as S;
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:ui'; import 'dart:ui';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -27,7 +25,7 @@ void main() { ...@@ -27,7 +25,7 @@ void main() {
expect(inner.debugLayer, null); expect(inner.debugLayer, null);
expect(boundary.isRepaintBoundary, isTrue); expect(boundary.isRepaintBoundary, isTrue);
expect(boundary.debugLayer, isNotNull); expect(boundary.debugLayer, isNotNull);
expect(boundary.debugLayer.attached, isTrue); // this time it painted... expect(boundary.debugLayer!.attached, isTrue); // this time it painted...
root.opacity = 0.0; root.opacity = 0.0;
pumpFrame(phase: EnginePhase.paint); pumpFrame(phase: EnginePhase.paint);
...@@ -35,7 +33,7 @@ void main() { ...@@ -35,7 +33,7 @@ void main() {
expect(inner.debugLayer, null); expect(inner.debugLayer, null);
expect(boundary.isRepaintBoundary, isTrue); expect(boundary.isRepaintBoundary, isTrue);
expect(boundary.debugLayer, isNotNull); expect(boundary.debugLayer, isNotNull);
expect(boundary.debugLayer.attached, isFalse); // this time it did not. expect(boundary.debugLayer!.attached, isFalse); // this time it did not.
root.opacity = 0.5; root.opacity = 0.5;
pumpFrame(phase: EnginePhase.paint); pumpFrame(phase: EnginePhase.paint);
...@@ -43,7 +41,7 @@ void main() { ...@@ -43,7 +41,7 @@ void main() {
expect(inner.debugLayer, null); expect(inner.debugLayer, null);
expect(boundary.isRepaintBoundary, isTrue); expect(boundary.isRepaintBoundary, isTrue);
expect(boundary.debugLayer, isNotNull); expect(boundary.debugLayer, isNotNull);
expect(boundary.debugLayer.attached, isTrue); // this time it did again! expect(boundary.debugLayer!.attached, isTrue); // this time it did again!
}); });
test('updateSubtreeNeedsAddToScene propagates Layer.alwaysNeedsAddToScene up the tree', () { test('updateSubtreeNeedsAddToScene propagates Layer.alwaysNeedsAddToScene up the tree', () {
...@@ -410,7 +408,7 @@ void main() { ...@@ -410,7 +408,7 @@ void main() {
void _testConflicts( void _testConflicts(
PhysicalModelLayer layerA, PhysicalModelLayer layerA,
PhysicalModelLayer layerB, { PhysicalModelLayer layerB, {
@required int expectedErrorCount, required int expectedErrorCount,
bool enableCheck = true, bool enableCheck = true,
}) { }) {
assert(expectedErrorCount != null); assert(expectedErrorCount != null);
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -25,7 +23,7 @@ void main() { ...@@ -25,7 +23,7 @@ void main() {
home: Builder( home: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
const String character = '骨'; const String character = '骨';
final TextStyle style = Theme.of(context).textTheme.headline2; final TextStyle style = Theme.of(context)!.textTheme.headline2!;
return Scaffold( return Scaffold(
body: Container( body: Container(
padding: const EdgeInsets.all(48.0), padding: const EdgeInsets.all(48.0),
...@@ -69,7 +67,7 @@ void main() { ...@@ -69,7 +67,7 @@ void main() {
home: Builder( home: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
const String character = '骨'; const String character = '骨';
final TextStyle style = Theme.of(context).textTheme.headline2; final TextStyle style = Theme.of(context)!.textTheme.headline2!;
return Scaffold( return Scaffold(
body: Container( body: Container(
padding: const EdgeInsets.all(48.0), padding: const EdgeInsets.all(48.0),
...@@ -120,7 +118,7 @@ void main() { ...@@ -120,7 +118,7 @@ void main() {
home: Builder( home: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
const String character = '骨'; const String character = '骨';
final TextStyle style = Theme.of(context).textTheme.headline2; final TextStyle style = Theme.of(context)!.textTheme.headline2!;
return Scaffold( return Scaffold(
body: Container( body: Container(
padding: const EdgeInsets.all(48.0), padding: const EdgeInsets.all(48.0),
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' as ui; import 'dart:ui' as ui;
import 'dart:ui' show PointerChange; import 'dart:ui' show PointerChange;
...@@ -16,24 +14,17 @@ import '../flutter_test_alternative.dart'; ...@@ -16,24 +14,17 @@ import '../flutter_test_alternative.dart';
import './mouse_tracking_test_utils.dart'; import './mouse_tracking_test_utils.dart';
typedef MethodCallHandler = Future<dynamic> Function(MethodCall call); typedef MethodCallHandler = Future<dynamic> Function(MethodCall call);
TestMouseTrackerFlutterBinding _binding = TestMouseTrackerFlutterBinding();
void _ensureTestGestureBinding() {
_binding ??= TestMouseTrackerFlutterBinding();
assert(GestureBinding.instance != null);
}
typedef SimpleAnnotationFinder = Iterable<HitTestTarget> Function(Offset offset); typedef SimpleAnnotationFinder = Iterable<HitTestTarget> Function(Offset offset);
void main() { void main() {
MethodCallHandler _methodCallHandler; final TestMouseTrackerFlutterBinding _binding = TestMouseTrackerFlutterBinding();
MethodCallHandler? _methodCallHandler;
// Only one of `logCursors` and `cursorHandler` should be specified. // Only one of `logCursors` and `cursorHandler` should be specified.
void _setUpMouseTracker({ void _setUpMouseTracker({
SimpleAnnotationFinder annotationFinder, required SimpleAnnotationFinder annotationFinder,
List<_CursorUpdateDetails> logCursors, List<_CursorUpdateDetails>? logCursors,
MethodCallHandler cursorHandler, MethodCallHandler? cursorHandler,
}) { }) {
assert(logCursors == null || cursorHandler == null); assert(logCursors == null || cursorHandler == null);
_methodCallHandler = logCursors != null _methodCallHandler = logCursors != null
...@@ -59,17 +50,16 @@ void main() { ...@@ -59,17 +50,16 @@ void main() {
} }
void dispatchRemoveDevice([int device = 0]) { void dispatchRemoveDevice([int device = 0]) {
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.remove, const Offset(0.0, 0.0), device: device), _pointerData(PointerChange.remove, const Offset(0.0, 0.0), device: device),
])); ]));
} }
setUp(() { setUp(() {
_ensureTestGestureBinding();
_binding.postFrameCallbacks.clear(); _binding.postFrameCallbacks.clear();
SystemChannels.mouseCursor.setMockMethodCallHandler((MethodCall call) async { SystemChannels.mouseCursor.setMockMethodCallHandler((MethodCall call) async {
if (_methodCallHandler != null) if (_methodCallHandler != null)
return _methodCallHandler(call); return _methodCallHandler!(call);
}); });
}); });
...@@ -87,7 +77,7 @@ void main() { ...@@ -87,7 +77,7 @@ void main() {
}, },
); );
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.add, const Offset(0.0, 0.0)), _pointerData(PointerChange.add, const Offset(0.0, 0.0)),
])); ]));
addTearDown(dispatchRemoveDevice); addTearDown(dispatchRemoveDevice);
...@@ -97,14 +87,14 @@ void main() { ...@@ -97,14 +87,14 @@ void main() {
test('pointer is added and removed out of any annotations', () { test('pointer is added and removed out of any annotations', () {
final List<_CursorUpdateDetails> logCursors = <_CursorUpdateDetails>[]; final List<_CursorUpdateDetails> logCursors = <_CursorUpdateDetails>[];
TestAnnotationTarget annotation; TestAnnotationTarget? annotation;
_setUpMouseTracker( _setUpMouseTracker(
annotationFinder: (Offset position) => <TestAnnotationTarget>[if (annotation != null) annotation], annotationFinder: (Offset position) => <TestAnnotationTarget>[if (annotation != null) annotation],
logCursors: logCursors, logCursors: logCursors,
); );
// Pointer is added outside of the annotation. // Pointer is added outside of the annotation.
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.add, const Offset(0.0, 0.0)), _pointerData(PointerChange.add, const Offset(0.0, 0.0)),
])); ]));
...@@ -115,7 +105,7 @@ void main() { ...@@ -115,7 +105,7 @@ void main() {
// Pointer moves into the annotation // Pointer moves into the annotation
annotation = const TestAnnotationTarget(cursor: SystemMouseCursors.grabbing); annotation = const TestAnnotationTarget(cursor: SystemMouseCursors.grabbing);
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.hover, const Offset(5.0, 0.0)), _pointerData(PointerChange.hover, const Offset(5.0, 0.0)),
])); ]));
...@@ -126,7 +116,7 @@ void main() { ...@@ -126,7 +116,7 @@ void main() {
// Pointer moves within the annotation // Pointer moves within the annotation
annotation = const TestAnnotationTarget(cursor: SystemMouseCursors.grabbing); annotation = const TestAnnotationTarget(cursor: SystemMouseCursors.grabbing);
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.hover, const Offset(10.0, 0.0)), _pointerData(PointerChange.hover, const Offset(10.0, 0.0)),
])); ]));
...@@ -136,7 +126,7 @@ void main() { ...@@ -136,7 +126,7 @@ void main() {
// Pointer moves out of the annotation // Pointer moves out of the annotation
annotation = null; annotation = null;
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.hover, const Offset(0.0, 0.0)), _pointerData(PointerChange.hover, const Offset(0.0, 0.0)),
])); ]));
...@@ -146,7 +136,7 @@ void main() { ...@@ -146,7 +136,7 @@ void main() {
logCursors.clear(); logCursors.clear();
// Pointer is removed outside of the annotation. // Pointer is removed outside of the annotation.
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.remove, const Offset(0.0, 0.0)), _pointerData(PointerChange.remove, const Offset(0.0, 0.0)),
])); ]));
...@@ -156,7 +146,7 @@ void main() { ...@@ -156,7 +146,7 @@ void main() {
test('pointer is added and removed in an annotation', () { test('pointer is added and removed in an annotation', () {
final List<_CursorUpdateDetails> logCursors = <_CursorUpdateDetails>[]; final List<_CursorUpdateDetails> logCursors = <_CursorUpdateDetails>[];
TestAnnotationTarget annotation; TestAnnotationTarget? annotation;
_setUpMouseTracker( _setUpMouseTracker(
annotationFinder: (Offset position) => <TestAnnotationTarget>[if (annotation != null) annotation], annotationFinder: (Offset position) => <TestAnnotationTarget>[if (annotation != null) annotation],
logCursors: logCursors, logCursors: logCursors,
...@@ -164,7 +154,7 @@ void main() { ...@@ -164,7 +154,7 @@ void main() {
// Pointer is added in the annotation. // Pointer is added in the annotation.
annotation = const TestAnnotationTarget(cursor: SystemMouseCursors.grabbing); annotation = const TestAnnotationTarget(cursor: SystemMouseCursors.grabbing);
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.add, const Offset(0.0, 0.0)), _pointerData(PointerChange.add, const Offset(0.0, 0.0)),
])); ]));
...@@ -175,7 +165,7 @@ void main() { ...@@ -175,7 +165,7 @@ void main() {
// Pointer moves out of the annotation // Pointer moves out of the annotation
annotation = null; annotation = null;
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.hover, const Offset(5.0, 0.0)), _pointerData(PointerChange.hover, const Offset(5.0, 0.0)),
])); ]));
...@@ -186,7 +176,7 @@ void main() { ...@@ -186,7 +176,7 @@ void main() {
// Pointer moves around out of the annotation // Pointer moves around out of the annotation
annotation = null; annotation = null;
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.hover, const Offset(10.0, 0.0)), _pointerData(PointerChange.hover, const Offset(10.0, 0.0)),
])); ]));
...@@ -196,7 +186,7 @@ void main() { ...@@ -196,7 +186,7 @@ void main() {
// Pointer moves back into the annotation // Pointer moves back into the annotation
annotation = const TestAnnotationTarget(cursor: SystemMouseCursors.grabbing); annotation = const TestAnnotationTarget(cursor: SystemMouseCursors.grabbing);
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.hover, const Offset(0.0, 0.0)), _pointerData(PointerChange.hover, const Offset(0.0, 0.0)),
])); ]));
...@@ -206,7 +196,7 @@ void main() { ...@@ -206,7 +196,7 @@ void main() {
logCursors.clear(); logCursors.clear();
// Pointer is removed within the annotation. // Pointer is removed within the annotation.
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.remove, const Offset(0.0, 0.0)), _pointerData(PointerChange.remove, const Offset(0.0, 0.0)),
])); ]));
...@@ -216,14 +206,14 @@ void main() { ...@@ -216,14 +206,14 @@ void main() {
test('pointer change caused by new frames', () { test('pointer change caused by new frames', () {
final List<_CursorUpdateDetails> logCursors = <_CursorUpdateDetails>[]; final List<_CursorUpdateDetails> logCursors = <_CursorUpdateDetails>[];
TestAnnotationTarget annotation; TestAnnotationTarget? annotation;
_setUpMouseTracker( _setUpMouseTracker(
annotationFinder: (Offset position) => <TestAnnotationTarget>[if (annotation != null) annotation], annotationFinder: (Offset position) => <TestAnnotationTarget>[if (annotation != null) annotation],
logCursors: logCursors, logCursors: logCursors,
); );
// Pointer is added outside of the annotation. // Pointer is added outside of the annotation.
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.add, const Offset(0.0, 0.0)), _pointerData(PointerChange.add, const Offset(0.0, 0.0)),
])); ]));
...@@ -251,7 +241,7 @@ void main() { ...@@ -251,7 +241,7 @@ void main() {
logCursors.clear(); logCursors.clear();
// Pointer is removed outside of the annotation. // Pointer is removed outside of the annotation.
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.remove, const Offset(0.0, 0.0)), _pointerData(PointerChange.remove, const Offset(0.0, 0.0)),
])); ]));
...@@ -261,7 +251,7 @@ void main() { ...@@ -261,7 +251,7 @@ void main() {
test('The first annotation with non-deferring cursor is used', () { test('The first annotation with non-deferring cursor is used', () {
final List<_CursorUpdateDetails> logCursors = <_CursorUpdateDetails>[]; final List<_CursorUpdateDetails> logCursors = <_CursorUpdateDetails>[];
List<TestAnnotationTarget> annotations; late List<TestAnnotationTarget> annotations;
_setUpMouseTracker( _setUpMouseTracker(
annotationFinder: (Offset position) sync* { yield* annotations; }, annotationFinder: (Offset position) sync* { yield* annotations; },
logCursors: logCursors, logCursors: logCursors,
...@@ -272,7 +262,7 @@ void main() { ...@@ -272,7 +262,7 @@ void main() {
const TestAnnotationTarget(cursor: SystemMouseCursors.click), const TestAnnotationTarget(cursor: SystemMouseCursors.click),
const TestAnnotationTarget(cursor: SystemMouseCursors.grabbing), const TestAnnotationTarget(cursor: SystemMouseCursors.grabbing),
]; ];
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.add, const Offset(0.0, 0.0)), _pointerData(PointerChange.add, const Offset(0.0, 0.0)),
])); ]));
...@@ -282,14 +272,14 @@ void main() { ...@@ -282,14 +272,14 @@ void main() {
logCursors.clear(); logCursors.clear();
// Remove // Remove
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.remove, const Offset(5.0, 0.0)), _pointerData(PointerChange.remove, const Offset(5.0, 0.0)),
])); ]));
}); });
test('Annotations with deferring cursors are ignored', () { test('Annotations with deferring cursors are ignored', () {
final List<_CursorUpdateDetails> logCursors = <_CursorUpdateDetails>[]; final List<_CursorUpdateDetails> logCursors = <_CursorUpdateDetails>[];
List<TestAnnotationTarget> annotations; late List<TestAnnotationTarget> annotations;
_setUpMouseTracker( _setUpMouseTracker(
annotationFinder: (Offset position) sync* { yield* annotations; }, annotationFinder: (Offset position) sync* { yield* annotations; },
logCursors: logCursors, logCursors: logCursors,
...@@ -300,7 +290,7 @@ void main() { ...@@ -300,7 +290,7 @@ void main() {
const TestAnnotationTarget(cursor: MouseCursor.defer), const TestAnnotationTarget(cursor: MouseCursor.defer),
const TestAnnotationTarget(cursor: SystemMouseCursors.grabbing), const TestAnnotationTarget(cursor: SystemMouseCursors.grabbing),
]; ];
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.add, const Offset(0.0, 0.0)), _pointerData(PointerChange.add, const Offset(0.0, 0.0)),
])); ]));
...@@ -310,21 +300,21 @@ void main() { ...@@ -310,21 +300,21 @@ void main() {
logCursors.clear(); logCursors.clear();
// Remove // Remove
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.remove, const Offset(5.0, 0.0)), _pointerData(PointerChange.remove, const Offset(5.0, 0.0)),
])); ]));
}); });
test('Finding no annotation is equivalent to specifying default cursor', () { test('Finding no annotation is equivalent to specifying default cursor', () {
final List<_CursorUpdateDetails> logCursors = <_CursorUpdateDetails>[]; final List<_CursorUpdateDetails> logCursors = <_CursorUpdateDetails>[];
TestAnnotationTarget annotation; TestAnnotationTarget? annotation;
_setUpMouseTracker( _setUpMouseTracker(
annotationFinder: (Offset position) => <TestAnnotationTarget>[if (annotation != null) annotation], annotationFinder: (Offset position) => <TestAnnotationTarget>[if (annotation != null) annotation],
logCursors: logCursors, logCursors: logCursors,
); );
// Pointer is added outside of the annotation. // Pointer is added outside of the annotation.
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.add, const Offset(0.0, 0.0)), _pointerData(PointerChange.add, const Offset(0.0, 0.0)),
])); ]));
...@@ -335,7 +325,7 @@ void main() { ...@@ -335,7 +325,7 @@ void main() {
// Pointer moved to an annotation specified with the default cursor // Pointer moved to an annotation specified with the default cursor
annotation = const TestAnnotationTarget(cursor: SystemMouseCursors.basic); annotation = const TestAnnotationTarget(cursor: SystemMouseCursors.basic);
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.hover, const Offset(5.0, 0.0)), _pointerData(PointerChange.hover, const Offset(5.0, 0.0)),
])); ]));
...@@ -345,7 +335,7 @@ void main() { ...@@ -345,7 +335,7 @@ void main() {
// Pointer moved to no annotations // Pointer moved to no annotations
annotation = null; annotation = null;
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.hover, const Offset(0.0, 0.0)), _pointerData(PointerChange.hover, const Offset(0.0, 0.0)),
])); ]));
...@@ -354,14 +344,14 @@ void main() { ...@@ -354,14 +344,14 @@ void main() {
logCursors.clear(); logCursors.clear();
// Remove // Remove
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.remove, const Offset(0.0, 0.0)), _pointerData(PointerChange.remove, const Offset(0.0, 0.0)),
])); ]));
}); });
test('Removing a pointer resets it back to the default cursor', () { test('Removing a pointer resets it back to the default cursor', () {
final List<_CursorUpdateDetails> logCursors = <_CursorUpdateDetails>[]; final List<_CursorUpdateDetails> logCursors = <_CursorUpdateDetails>[];
TestAnnotationTarget annotation; TestAnnotationTarget? annotation;
_setUpMouseTracker( _setUpMouseTracker(
annotationFinder: (Offset position) => <TestAnnotationTarget>[if (annotation != null) annotation], annotationFinder: (Offset position) => <TestAnnotationTarget>[if (annotation != null) annotation],
logCursors: logCursors, logCursors: logCursors,
...@@ -369,7 +359,7 @@ void main() { ...@@ -369,7 +359,7 @@ void main() {
// Pointer is added to the annotation, then removed // Pointer is added to the annotation, then removed
annotation = const TestAnnotationTarget(cursor: SystemMouseCursors.click); annotation = const TestAnnotationTarget(cursor: SystemMouseCursors.click);
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.add, const Offset(0.0, 0.0)), _pointerData(PointerChange.add, const Offset(0.0, 0.0)),
_pointerData(PointerChange.hover, const Offset(5.0, 0.0)), _pointerData(PointerChange.hover, const Offset(5.0, 0.0)),
_pointerData(PointerChange.remove, const Offset(5.0, 0.0)), _pointerData(PointerChange.remove, const Offset(5.0, 0.0)),
...@@ -379,7 +369,7 @@ void main() { ...@@ -379,7 +369,7 @@ void main() {
// Pointer is added out of the annotation // Pointer is added out of the annotation
annotation = null; annotation = null;
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.add, const Offset(0.0, 0.0)), _pointerData(PointerChange.add, const Offset(0.0, 0.0)),
])); ]));
addTearDown(dispatchRemoveDevice); addTearDown(dispatchRemoveDevice);
...@@ -404,7 +394,7 @@ void main() { ...@@ -404,7 +394,7 @@ void main() {
); );
// Pointers are added outside of the annotation. // Pointers are added outside of the annotation.
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.add, const Offset(0.0, 0.0), device: 1), _pointerData(PointerChange.add, const Offset(0.0, 0.0), device: 1),
_pointerData(PointerChange.add, const Offset(0.0, 0.0), device: 2), _pointerData(PointerChange.add, const Offset(0.0, 0.0), device: 2),
])); ]));
...@@ -418,7 +408,7 @@ void main() { ...@@ -418,7 +408,7 @@ void main() {
logCursors.clear(); logCursors.clear();
// Pointer 1 moved to cursor "click" // Pointer 1 moved to cursor "click"
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.hover, const Offset(101.0, 0.0), device: 1), _pointerData(PointerChange.hover, const Offset(101.0, 0.0), device: 1),
])); ]));
...@@ -428,7 +418,7 @@ void main() { ...@@ -428,7 +418,7 @@ void main() {
logCursors.clear(); logCursors.clear();
// Pointer 2 moved to cursor "click" // Pointer 2 moved to cursor "click"
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.hover, const Offset(102.0, 0.0), device: 2), _pointerData(PointerChange.hover, const Offset(102.0, 0.0), device: 2),
])); ]));
...@@ -438,7 +428,7 @@ void main() { ...@@ -438,7 +428,7 @@ void main() {
logCursors.clear(); logCursors.clear();
// Pointer 2 moved to cursor "forbidden" // Pointer 2 moved to cursor "forbidden"
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.hover, const Offset(202.0, 0.0), device: 2), _pointerData(PointerChange.hover, const Offset(202.0, 0.0), device: 2),
])); ]));
...@@ -472,8 +462,10 @@ class _CursorUpdateDetails extends MethodCall { ...@@ -472,8 +462,10 @@ class _CursorUpdateDetails extends MethodCall {
_CursorUpdateDetails.wrap(MethodCall call) _CursorUpdateDetails.wrap(MethodCall call)
: super(call.method, Map<String, dynamic>.from(call.arguments as Map<dynamic, dynamic>)); : super(call.method, Map<String, dynamic>.from(call.arguments as Map<dynamic, dynamic>));
_CursorUpdateDetails.activateSystemCursor({int device, String kind}) _CursorUpdateDetails.activateSystemCursor({
: this('activateSystemCursor', <String, dynamic>{'device': device, 'kind': kind}); required int device,
required String kind,
}) : this('activateSystemCursor', <String, dynamic>{'device': device, 'kind': kind});
@override @override
Map<String, dynamic> get arguments => super.arguments as Map<String, dynamic>; Map<String, dynamic> get arguments => super.arguments as Map<String, dynamic>;
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' as ui; import 'dart:ui' as ui;
import 'dart:ui' show PointerChange; import 'dart:ui' show PointerChange;
...@@ -16,17 +14,12 @@ import 'package:vector_math/vector_math_64.dart' show Matrix4; ...@@ -16,17 +14,12 @@ import 'package:vector_math/vector_math_64.dart' show Matrix4;
import '../flutter_test_alternative.dart'; import '../flutter_test_alternative.dart';
import './mouse_tracking_test_utils.dart'; import './mouse_tracking_test_utils.dart';
TestMouseTrackerFlutterBinding _binding = TestMouseTrackerFlutterBinding(); MouseTracker get _mouseTracker => RendererBinding.instance!.mouseTracker;
MouseTracker get _mouseTracker => RendererBinding.instance.mouseTracker;
void _ensureTestGestureBinding() {
_binding ??= TestMouseTrackerFlutterBinding();
assert(GestureBinding.instance != null);
}
typedef SimpleAnnotationFinder = Iterable<TestAnnotationEntry> Function(Offset offset); typedef SimpleAnnotationFinder = Iterable<TestAnnotationEntry> Function(Offset offset);
void main() { void main() {
final TestMouseTrackerFlutterBinding _binding = TestMouseTrackerFlutterBinding();
void _setUpMouseAnnotationFinder(SimpleAnnotationFinder annotationFinder) { void _setUpMouseAnnotationFinder(SimpleAnnotationFinder annotationFinder) {
_binding.setHitTest((BoxHitTestResult result, Offset position) { _binding.setHitTest((BoxHitTestResult result, Offset position) {
for (final TestAnnotationEntry entry in annotationFinder(position)) { for (final TestAnnotationEntry entry in annotationFinder(position)) {
...@@ -48,7 +41,9 @@ void main() { ...@@ -48,7 +41,9 @@ void main() {
// `logEvents`. // `logEvents`.
// This annotation also contains a cursor with a value of `testCursor`. // This annotation also contains a cursor with a value of `testCursor`.
// The mouse tracker records the cursor requests it receives to `logCursors`. // The mouse tracker records the cursor requests it receives to `logCursors`.
TestAnnotationTarget _setUpWithOneAnnotation({List<PointerEvent> logEvents}) { TestAnnotationTarget _setUpWithOneAnnotation({
required List<PointerEvent> logEvents
}) {
final TestAnnotationTarget oneAnnotation = TestAnnotationTarget( final TestAnnotationTarget oneAnnotation = TestAnnotationTarget(
onEnter: (PointerEnterEvent event) { onEnter: (PointerEnterEvent event) {
if (logEvents != null) if (logEvents != null)
...@@ -72,13 +67,12 @@ void main() { ...@@ -72,13 +67,12 @@ void main() {
} }
void dispatchRemoveDevice([int device = 0]) { void dispatchRemoveDevice([int device = 0]) {
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.remove, const Offset(0.0, 0.0), device: device), _pointerData(PointerChange.remove, const Offset(0.0, 0.0), device: device),
])); ]));
} }
setUp(() { setUp(() {
_ensureTestGestureBinding();
_binding.postFrameCallbacks.clear(); _binding.postFrameCallbacks.clear();
}); });
...@@ -122,7 +116,7 @@ void main() { ...@@ -122,7 +116,7 @@ void main() {
expect(_mouseTracker.mouseIsConnected, isFalse); expect(_mouseTracker.mouseIsConnected, isFalse);
// Pointer enters the annotation. // Pointer enters the annotation.
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.add, const Offset(0.0, 0.0)), _pointerData(PointerChange.add, const Offset(0.0, 0.0)),
])); ]));
addTearDown(() => dispatchRemoveDevice()); addTearDown(() => dispatchRemoveDevice());
...@@ -135,7 +129,7 @@ void main() { ...@@ -135,7 +129,7 @@ void main() {
listenerLogs.clear(); listenerLogs.clear();
// Pointer hovers the annotation. // Pointer hovers the annotation.
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.hover, const Offset(1.0, 101.0)), _pointerData(PointerChange.hover, const Offset(1.0, 101.0)),
])); ]));
expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[ expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[
...@@ -146,7 +140,7 @@ void main() { ...@@ -146,7 +140,7 @@ void main() {
events.clear(); events.clear();
// Pointer is removed while on the annotation. // Pointer is removed while on the annotation.
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.remove, const Offset(1.0, 101.0)), _pointerData(PointerChange.remove, const Offset(1.0, 101.0)),
])); ]));
expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[ expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[
...@@ -157,7 +151,7 @@ void main() { ...@@ -157,7 +151,7 @@ void main() {
listenerLogs.clear(); listenerLogs.clear();
// Pointer is added on the annotation. // Pointer is added on the annotation.
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.add, const Offset(0.0, 301.0)), _pointerData(PointerChange.add, const Offset(0.0, 301.0)),
])); ]));
expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[ expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[
...@@ -175,7 +169,7 @@ void main() { ...@@ -175,7 +169,7 @@ void main() {
expect(_mouseTracker.mouseIsConnected, isFalse); expect(_mouseTracker.mouseIsConnected, isFalse);
// The first mouse is added on the annotation. // The first mouse is added on the annotation.
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.add, const Offset(0.0, 0.0)), _pointerData(PointerChange.add, const Offset(0.0, 0.0)),
_pointerData(PointerChange.hover, const Offset(0.0, 1.0)), _pointerData(PointerChange.hover, const Offset(0.0, 1.0)),
])); ]));
...@@ -187,7 +181,7 @@ void main() { ...@@ -187,7 +181,7 @@ void main() {
events.clear(); events.clear();
// The second mouse is added on the annotation. // The second mouse is added on the annotation.
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.add, const Offset(0.0, 401.0), device: 1), _pointerData(PointerChange.add, const Offset(0.0, 401.0), device: 1),
_pointerData(PointerChange.hover, const Offset(1.0, 401.0), device: 1), _pointerData(PointerChange.hover, const Offset(1.0, 401.0), device: 1),
])); ]));
...@@ -199,7 +193,7 @@ void main() { ...@@ -199,7 +193,7 @@ void main() {
events.clear(); events.clear();
// The first mouse moves on the annotation. // The first mouse moves on the annotation.
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.hover, const Offset(0.0, 101.0)), _pointerData(PointerChange.hover, const Offset(0.0, 101.0)),
])); ]));
expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[ expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[
...@@ -209,7 +203,7 @@ void main() { ...@@ -209,7 +203,7 @@ void main() {
events.clear(); events.clear();
// The second mouse moves on the annotation. // The second mouse moves on the annotation.
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.hover, const Offset(1.0, 501.0), device: 1), _pointerData(PointerChange.hover, const Offset(1.0, 501.0), device: 1),
])); ]));
expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[ expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[
...@@ -219,7 +213,7 @@ void main() { ...@@ -219,7 +213,7 @@ void main() {
events.clear(); events.clear();
// The first mouse is removed while on the annotation. // The first mouse is removed while on the annotation.
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.remove, const Offset(0.0, 101.0)), _pointerData(PointerChange.remove, const Offset(0.0, 101.0)),
])); ]));
expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[ expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[
...@@ -229,7 +223,7 @@ void main() { ...@@ -229,7 +223,7 @@ void main() {
events.clear(); events.clear();
// The second mouse still moves on the annotation. // The second mouse still moves on the annotation.
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.hover, const Offset(1.0, 601.0), device: 1), _pointerData(PointerChange.hover, const Offset(1.0, 601.0), device: 1),
])); ]));
expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[ expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[
...@@ -239,7 +233,7 @@ void main() { ...@@ -239,7 +233,7 @@ void main() {
events.clear(); events.clear();
// The second mouse is removed while on the annotation. // The second mouse is removed while on the annotation.
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.remove, const Offset(1.0, 601.0), device: 1), _pointerData(PointerChange.remove, const Offset(1.0, 601.0), device: 1),
])); ]));
expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[ expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[
...@@ -253,7 +247,7 @@ void main() { ...@@ -253,7 +247,7 @@ void main() {
final List<PointerEvent> events = <PointerEvent>[]; final List<PointerEvent> events = <PointerEvent>[];
_setUpWithOneAnnotation(logEvents: events); _setUpWithOneAnnotation(logEvents: events);
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.add, const Offset(0.0, 101.0)), _pointerData(PointerChange.add, const Offset(0.0, 101.0)),
_pointerData(PointerChange.down, const Offset(0.0, 101.0)), _pointerData(PointerChange.down, const Offset(0.0, 101.0)),
])); ]));
...@@ -265,14 +259,14 @@ void main() { ...@@ -265,14 +259,14 @@ void main() {
])); ]));
events.clear(); events.clear();
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.move, const Offset(0.0, 201.0)), _pointerData(PointerChange.move, const Offset(0.0, 201.0)),
])); ]));
expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[ expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[
])); ]));
events.clear(); events.clear();
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.up, const Offset(0.0, 301.0)), _pointerData(PointerChange.up, const Offset(0.0, 301.0)),
])); ]));
expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[ expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[
...@@ -281,7 +275,7 @@ void main() { ...@@ -281,7 +275,7 @@ void main() {
}); });
test('should correctly handle when the annotation appears or disappears on the pointer', () { test('should correctly handle when the annotation appears or disappears on the pointer', () {
bool isInHitRegion; late bool isInHitRegion;
final List<Object> events = <PointerEvent>[]; final List<Object> events = <PointerEvent>[];
final TestAnnotationTarget annotation = TestAnnotationTarget( final TestAnnotationTarget annotation = TestAnnotationTarget(
onEnter: (PointerEnterEvent event) => events.add(event), onEnter: (PointerEnterEvent event) => events.add(event),
...@@ -297,7 +291,7 @@ void main() { ...@@ -297,7 +291,7 @@ void main() {
isInHitRegion = false; isInHitRegion = false;
// Connect a mouse when there is no annotation. // Connect a mouse when there is no annotation.
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.add, const Offset(0.0, 100.0)), _pointerData(PointerChange.add, const Offset(0.0, 100.0)),
])); ]));
addTearDown(() => dispatchRemoveDevice()); addTearDown(() => dispatchRemoveDevice());
...@@ -330,7 +324,7 @@ void main() { ...@@ -330,7 +324,7 @@ void main() {
}); });
test('should correctly handle when the annotation moves in or out of the pointer', () { test('should correctly handle when the annotation moves in or out of the pointer', () {
bool isInHitRegion; late bool isInHitRegion;
final List<Object> events = <PointerEvent>[]; final List<Object> events = <PointerEvent>[];
final TestAnnotationTarget annotation = TestAnnotationTarget( final TestAnnotationTarget annotation = TestAnnotationTarget(
onEnter: (PointerEnterEvent event) => events.add(event), onEnter: (PointerEnterEvent event) => events.add(event),
...@@ -346,7 +340,7 @@ void main() { ...@@ -346,7 +340,7 @@ void main() {
isInHitRegion = false; isInHitRegion = false;
// Connect a mouse. // Connect a mouse.
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.add, const Offset(0.0, 100.0)), _pointerData(PointerChange.add, const Offset(0.0, 100.0)),
])); ]));
addTearDown(() => dispatchRemoveDevice()); addTearDown(() => dispatchRemoveDevice());
...@@ -380,7 +374,7 @@ void main() { ...@@ -380,7 +374,7 @@ void main() {
}); });
test('should correctly handle when the pointer is added or removed on the annotation', () { test('should correctly handle when the pointer is added or removed on the annotation', () {
bool isInHitRegion; late bool isInHitRegion;
final List<Object> events = <PointerEvent>[]; final List<Object> events = <PointerEvent>[];
final TestAnnotationTarget annotation = TestAnnotationTarget( final TestAnnotationTarget annotation = TestAnnotationTarget(
onEnter: (PointerEnterEvent event) => events.add(event), onEnter: (PointerEnterEvent event) => events.add(event),
...@@ -397,7 +391,7 @@ void main() { ...@@ -397,7 +391,7 @@ void main() {
// Connect a mouse in the region. Should trigger Enter. // Connect a mouse in the region. Should trigger Enter.
isInHitRegion = true; isInHitRegion = true;
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.add, const Offset(0.0, 100.0)), _pointerData(PointerChange.add, const Offset(0.0, 100.0)),
])); ]));
...@@ -408,7 +402,7 @@ void main() { ...@@ -408,7 +402,7 @@ void main() {
events.clear(); events.clear();
// Disconnect the mouse from the region. Should trigger Exit. // Disconnect the mouse from the region. Should trigger Exit.
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.remove, const Offset(0.0, 100.0)), _pointerData(PointerChange.remove, const Offset(0.0, 100.0)),
])); ]));
expect(_binding.postFrameCallbacks, hasLength(0)); expect(_binding.postFrameCallbacks, hasLength(0));
...@@ -418,7 +412,7 @@ void main() { ...@@ -418,7 +412,7 @@ void main() {
}); });
test('should correctly handle when the pointer moves in or out of the annotation', () { test('should correctly handle when the pointer moves in or out of the annotation', () {
bool isInHitRegion; late bool isInHitRegion;
final List<Object> events = <PointerEvent>[]; final List<Object> events = <PointerEvent>[];
final TestAnnotationTarget annotation = TestAnnotationTarget( final TestAnnotationTarget annotation = TestAnnotationTarget(
onEnter: (PointerEnterEvent event) => events.add(event), onEnter: (PointerEnterEvent event) => events.add(event),
...@@ -432,7 +426,7 @@ void main() { ...@@ -432,7 +426,7 @@ void main() {
}); });
isInHitRegion = false; isInHitRegion = false;
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.add, const Offset(200.0, 100.0)), _pointerData(PointerChange.add, const Offset(200.0, 100.0)),
])); ]));
addTearDown(() => dispatchRemoveDevice()); addTearDown(() => dispatchRemoveDevice());
...@@ -442,7 +436,7 @@ void main() { ...@@ -442,7 +436,7 @@ void main() {
// Moves the mouse into the region. Should trigger Enter. // Moves the mouse into the region. Should trigger Enter.
isInHitRegion = true; isInHitRegion = true;
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.hover, const Offset(0.0, 100.0)), _pointerData(PointerChange.hover, const Offset(0.0, 100.0)),
])); ]));
expect(_binding.postFrameCallbacks, hasLength(0)); expect(_binding.postFrameCallbacks, hasLength(0));
...@@ -454,7 +448,7 @@ void main() { ...@@ -454,7 +448,7 @@ void main() {
// Moves the mouse out of the region. Should trigger Exit. // Moves the mouse out of the region. Should trigger Exit.
isInHitRegion = false; isInHitRegion = false;
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.hover, const Offset(200.0, 100.0)), _pointerData(PointerChange.hover, const Offset(200.0, 100.0)),
])); ]));
expect(_binding.postFrameCallbacks, hasLength(0)); expect(_binding.postFrameCallbacks, hasLength(0));
...@@ -468,7 +462,7 @@ void main() { ...@@ -468,7 +462,7 @@ void main() {
}); });
// Connect a touch device, which should not be recognized by MouseTracker // Connect a touch device, which should not be recognized by MouseTracker
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.add, const Offset(0.0, 100.0), kind: PointerDeviceKind.touch), _pointerData(PointerChange.add, const Offset(0.0, 100.0), kind: PointerDeviceKind.touch),
])); ]));
expect(_mouseTracker.mouseIsConnected, isFalse); expect(_mouseTracker.mouseIsConnected, isFalse);
...@@ -494,7 +488,7 @@ void main() { ...@@ -494,7 +488,7 @@ void main() {
isInHitRegionOne = false; isInHitRegionOne = false;
isInHitRegionTwo = true; isInHitRegionTwo = true;
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.add, const Offset(0.0, 101.0)), _pointerData(PointerChange.add, const Offset(0.0, 101.0)),
_pointerData(PointerChange.hover, const Offset(1.0, 101.0)), _pointerData(PointerChange.hover, const Offset(1.0, 101.0)),
])); ]));
...@@ -513,7 +507,7 @@ void main() { ...@@ -513,7 +507,7 @@ void main() {
// | —————— | // | —————— |
// ——————————— // ———————————
bool isInB; late bool isInB;
final List<String> logs = <String>[]; final List<String> logs = <String>[];
final TestAnnotationTarget annotationA = TestAnnotationTarget( final TestAnnotationTarget annotationA = TestAnnotationTarget(
onEnter: (PointerEnterEvent event) => logs.add('enterA'), onEnter: (PointerEnterEvent event) => logs.add('enterA'),
...@@ -535,7 +529,7 @@ void main() { ...@@ -535,7 +529,7 @@ void main() {
// Starts out of A. // Starts out of A.
isInB = false; isInB = false;
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.add, const Offset(0.0, 1.0)), _pointerData(PointerChange.add, const Offset(0.0, 1.0)),
])); ]));
addTearDown(() => dispatchRemoveDevice()); addTearDown(() => dispatchRemoveDevice());
...@@ -543,7 +537,7 @@ void main() { ...@@ -543,7 +537,7 @@ void main() {
// Moves into B within one frame. // Moves into B within one frame.
isInB = true; isInB = true;
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.hover, const Offset(0.0, 10.0)), _pointerData(PointerChange.hover, const Offset(0.0, 10.0)),
])); ]));
expect(logs, <String>['enterA', 'enterB', 'hoverB', 'hoverA']); expect(logs, <String>['enterA', 'enterB', 'hoverB', 'hoverA']);
...@@ -551,7 +545,7 @@ void main() { ...@@ -551,7 +545,7 @@ void main() {
// Moves out of A within one frame. // Moves out of A within one frame.
isInB = false; isInB = false;
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.hover, const Offset(0.0, 20.0)), _pointerData(PointerChange.hover, const Offset(0.0, 20.0)),
])); ]));
expect(logs, <String>['exitB', 'exitA']); expect(logs, <String>['exitB', 'exitA']);
...@@ -566,8 +560,8 @@ void main() { ...@@ -566,8 +560,8 @@ void main() {
// | | | | // | | | |
// ———————— ———————— // ———————— ————————
bool isInA; late bool isInA;
bool isInB; late bool isInB;
final List<String> logs = <String>[]; final List<String> logs = <String>[];
final TestAnnotationTarget annotationA = TestAnnotationTarget( final TestAnnotationTarget annotationA = TestAnnotationTarget(
onEnter: (PointerEnterEvent event) => logs.add('enterA'), onEnter: (PointerEnterEvent event) => logs.add('enterA'),
...@@ -590,7 +584,7 @@ void main() { ...@@ -590,7 +584,7 @@ void main() {
// Starts within A. // Starts within A.
isInA = true; isInA = true;
isInB = false; isInB = false;
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.add, const Offset(0.0, 1.0)), _pointerData(PointerChange.add, const Offset(0.0, 1.0)),
])); ]));
addTearDown(() => dispatchRemoveDevice()); addTearDown(() => dispatchRemoveDevice());
...@@ -600,7 +594,7 @@ void main() { ...@@ -600,7 +594,7 @@ void main() {
// Moves into B within one frame. // Moves into B within one frame.
isInA = false; isInA = false;
isInB = true; isInB = true;
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.hover, const Offset(0.0, 10.0)), _pointerData(PointerChange.hover, const Offset(0.0, 10.0)),
])); ]));
expect(logs, <String>['exitA', 'enterB', 'hoverB']); expect(logs, <String>['exitA', 'enterB', 'hoverB']);
...@@ -609,7 +603,7 @@ void main() { ...@@ -609,7 +603,7 @@ void main() {
// Moves into A within one frame. // Moves into A within one frame.
isInA = true; isInA = true;
isInB = false; isInB = false;
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(PointerChange.hover, const Offset(0.0, 1.0)), _pointerData(PointerChange.hover, const Offset(0.0, 1.0)),
])); ]));
expect(logs, <String>['exitB', 'enterA', 'hoverA']); expect(logs, <String>['exitB', 'enterA', 'hoverA']);
...@@ -725,7 +719,7 @@ class _EventListCriticalFieldsMatcher extends Matcher { ...@@ -725,7 +719,7 @@ class _EventListCriticalFieldsMatcher extends Matcher {
bool matches(dynamic untypedItem, Map<dynamic, dynamic> matchState) { bool matches(dynamic untypedItem, Map<dynamic, dynamic> matchState) {
if (untypedItem is! Iterable<PointerEvent>) if (untypedItem is! Iterable<PointerEvent>)
return false; return false;
final Iterable<PointerEvent> item = untypedItem as Iterable<PointerEvent>; final Iterable<PointerEvent> item = untypedItem;
final Iterator<PointerEvent> iterator = item.iterator; final Iterator<PointerEvent> iterator = item.iterator;
if (item.length != _expected.length) if (item.length != _expected.length)
return false; return false;
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import '../flutter_test_alternative.dart'; import '../flutter_test_alternative.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
...@@ -13,7 +11,6 @@ import 'rendering_tester.dart'; ...@@ -13,7 +11,6 @@ import 'rendering_tester.dart';
class RealRoot extends AbstractNode { class RealRoot extends AbstractNode {
RealRoot(this.child) { RealRoot(this.child) {
if (child != null)
adoptChild(child); adoptChild(child);
} }
...@@ -21,27 +18,26 @@ class RealRoot extends AbstractNode { ...@@ -21,27 +18,26 @@ class RealRoot extends AbstractNode {
@override @override
void redepthChildren() { void redepthChildren() {
if (child != null)
redepthChild(child); redepthChild(child);
} }
@override @override
void attach(Object owner) { void attach(Object owner) {
super.attach(owner); super.attach(owner);
child?.attach(owner as PipelineOwner); child.attach(owner as PipelineOwner);
} }
@override @override
void detach() { void detach() {
super.detach(); super.detach();
child?.detach(); child.detach();
} }
@override @override
PipelineOwner get owner => super.owner as PipelineOwner; PipelineOwner get owner => super.owner as PipelineOwner;
void layout() { void layout() {
child?.layout(BoxConstraints.tight(const Size(500.0, 500.0))); child.layout(BoxConstraints.tight(const Size(500.0, 500.0)));
} }
} }
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
...@@ -41,8 +39,8 @@ void main() { ...@@ -41,8 +39,8 @@ void main() {
}); });
test('ensure errors processing render objects are well formatted', () { test('ensure errors processing render objects are well formatted', () {
FlutterErrorDetails errorDetails; late FlutterErrorDetails errorDetails;
final FlutterExceptionHandler oldHandler = FlutterError.onError; final FlutterExceptionHandler? oldHandler = FlutterError.onError;
FlutterError.onError = (FlutterErrorDetails details) { FlutterError.onError = (FlutterErrorDetails details) {
errorDetails = details; errorDetails = details;
}; };
...@@ -103,37 +101,37 @@ void main() { ...@@ -103,37 +101,37 @@ void main() {
}); });
test('PaintingContext.pushClipRect reuses the layer', () { test('PaintingContext.pushClipRect reuses the layer', () {
_testPaintingContextLayerReuse<ClipRectLayer>((PaintingContextCallback painter, PaintingContext context, Offset offset, Layer oldLayer) { _testPaintingContextLayerReuse<ClipRectLayer>((PaintingContextCallback painter, PaintingContext context, Offset offset, Layer? oldLayer) {
return context.pushClipRect(true, offset, Rect.zero, painter, oldLayer: oldLayer as ClipRectLayer); return context.pushClipRect(true, offset, Rect.zero, painter, oldLayer: oldLayer as ClipRectLayer);
}); });
}); });
test('PaintingContext.pushClipRRect reuses the layer', () { test('PaintingContext.pushClipRRect reuses the layer', () {
_testPaintingContextLayerReuse<ClipRRectLayer>((PaintingContextCallback painter, PaintingContext context, Offset offset, Layer oldLayer) { _testPaintingContextLayerReuse<ClipRRectLayer>((PaintingContextCallback painter, PaintingContext context, Offset offset, Layer? oldLayer) {
return context.pushClipRRect(true, offset, Rect.zero, RRect.fromRectAndRadius(Rect.zero, const Radius.circular(1.0)), painter, oldLayer: oldLayer as ClipRRectLayer); return context.pushClipRRect(true, offset, Rect.zero, RRect.fromRectAndRadius(Rect.zero, const Radius.circular(1.0)), painter, oldLayer: oldLayer as ClipRRectLayer);
}); });
}); });
test('PaintingContext.pushClipPath reuses the layer', () { test('PaintingContext.pushClipPath reuses the layer', () {
_testPaintingContextLayerReuse<ClipPathLayer>((PaintingContextCallback painter, PaintingContext context, Offset offset, Layer oldLayer) { _testPaintingContextLayerReuse<ClipPathLayer>((PaintingContextCallback painter, PaintingContext context, Offset offset, Layer? oldLayer) {
return context.pushClipPath(true, offset, Rect.zero, Path(), painter, oldLayer: oldLayer as ClipPathLayer); return context.pushClipPath(true, offset, Rect.zero, Path(), painter, oldLayer: oldLayer as ClipPathLayer);
}); });
}); });
test('PaintingContext.pushColorFilter reuses the layer', () { test('PaintingContext.pushColorFilter reuses the layer', () {
_testPaintingContextLayerReuse<ColorFilterLayer>((PaintingContextCallback painter, PaintingContext context, Offset offset, Layer oldLayer) { _testPaintingContextLayerReuse<ColorFilterLayer>((PaintingContextCallback painter, PaintingContext context, Offset offset, Layer? oldLayer) {
return context.pushColorFilter(offset, const ColorFilter.mode(Color.fromRGBO(0, 0, 0, 1.0), BlendMode.clear), painter, oldLayer: oldLayer as ColorFilterLayer); return context.pushColorFilter(offset, const ColorFilter.mode(Color.fromRGBO(0, 0, 0, 1.0), BlendMode.clear), painter, oldLayer: oldLayer as ColorFilterLayer);
}); });
}); });
test('PaintingContext.pushTransform reuses the layer', () { test('PaintingContext.pushTransform reuses the layer', () {
_testPaintingContextLayerReuse<TransformLayer>((PaintingContextCallback painter, PaintingContext context, Offset offset, Layer oldLayer) { _testPaintingContextLayerReuse<TransformLayer>((PaintingContextCallback painter, PaintingContext context, Offset offset, Layer? oldLayer) {
return context.pushTransform(true, offset, Matrix4.identity(), painter, oldLayer: oldLayer as TransformLayer); return context.pushTransform(true, offset, Matrix4.identity(), painter, oldLayer: oldLayer as TransformLayer);
}); });
}); });
test('PaintingContext.pushOpacity reuses the layer', () { test('PaintingContext.pushOpacity reuses the layer', () {
_testPaintingContextLayerReuse<OpacityLayer>((PaintingContextCallback painter, PaintingContext context, Offset offset, Layer oldLayer) { _testPaintingContextLayerReuse<OpacityLayer>((PaintingContextCallback painter, PaintingContext context, Offset offset, Layer? oldLayer) {
return context.pushOpacity(offset, 100, painter, oldLayer: oldLayer as OpacityLayer); return context.pushOpacity(offset, 100, painter, oldLayer: oldLayer as OpacityLayer);
}); });
}); });
...@@ -154,7 +152,7 @@ void _testPaintingContextLayerReuse<L extends Layer>(_LayerTestPaintCallback pai ...@@ -154,7 +152,7 @@ void _testPaintingContextLayerReuse<L extends Layer>(_LayerTestPaintCallback pai
expect(box.paintedLayers[0], same(box.paintedLayers[1])); expect(box.paintedLayers[0], same(box.paintedLayers[1]));
} }
typedef _LayerTestPaintCallback = Layer Function(PaintingContextCallback painter, PaintingContext context, Offset offset, Layer oldLayer); typedef _LayerTestPaintCallback = Layer? Function(PaintingContextCallback painter, PaintingContext context, Offset offset, Layer? oldLayer);
class _TestCustomLayerBox extends RenderBox { class _TestCustomLayerBox extends RenderBox {
_TestCustomLayerBox(this.painter); _TestCustomLayerBox(this.painter);
...@@ -172,7 +170,7 @@ class _TestCustomLayerBox extends RenderBox { ...@@ -172,7 +170,7 @@ class _TestCustomLayerBox extends RenderBox {
@override @override
void paint(PaintingContext context, Offset offset) { void paint(PaintingContext context, Offset offset) {
final Layer paintedLayer = painter(super.paint, context, offset, layer); final Layer paintedLayer = painter(super.paint, context, offset, layer)!;
paintedLayers.add(paintedLayer); paintedLayers.add(paintedLayer);
layer = paintedLayer as ContainerLayer; layer = paintedLayer as ContainerLayer;
} }
...@@ -185,7 +183,10 @@ class TestRenderObject extends RenderObject { ...@@ -185,7 +183,10 @@ class TestRenderObject extends RenderObject {
void debugAssertDoesMeetConstraints() { } void debugAssertDoesMeetConstraints() { }
@override @override
Rect get paintBounds => null; Rect get paintBounds {
assert(false); // The test shouldn't call this.
return Rect.zero;
}
@override @override
void performLayout() { } void performLayout() { }
...@@ -216,11 +217,17 @@ class TestThrowingRenderObject extends RenderObject { ...@@ -216,11 +217,17 @@ class TestThrowingRenderObject extends RenderObject {
void debugAssertDoesMeetConstraints() { } void debugAssertDoesMeetConstraints() { }
@override @override
Rect get paintBounds => null; Rect get paintBounds {
assert(false); // The test shouldn't call this.
return Rect.zero;
}
@override @override
void performResize() { } void performResize() { }
@override @override
Rect get semanticBounds => null; Rect get semanticBounds {
assert(false); // The test shouldn't call this.
return Rect.zero;
}
} }
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import '../flutter_test_alternative.dart'; import '../flutter_test_alternative.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import '../flutter_test_alternative.dart'; import '../flutter_test_alternative.dart';
...@@ -13,7 +11,7 @@ import 'rendering_tester.dart'; ...@@ -13,7 +11,7 @@ import 'rendering_tester.dart';
void main() { void main() {
test('overflow should not affect baseline', () { test('overflow should not affect baseline', () {
RenderBox root, child, text; RenderBox root, child, text;
double baseline1, baseline2, height1, height2; late double baseline1, baseline2, height1, height2;
root = RenderPositionedBox( root = RenderPositionedBox(
child: RenderCustomPaint( child: RenderCustomPaint(
...@@ -23,7 +21,7 @@ void main() { ...@@ -23,7 +21,7 @@ void main() {
), ),
painter: TestCallbackPainter( painter: TestCallbackPainter(
onPaint: () { onPaint: () {
baseline1 = child.getDistanceToBaseline(TextBaseline.alphabetic); baseline1 = child.getDistanceToBaseline(TextBaseline.alphabetic)!;
height1 = text.size.height; height1 = text.size.height;
}, },
), ),
...@@ -43,7 +41,7 @@ void main() { ...@@ -43,7 +41,7 @@ void main() {
), ),
painter: TestCallbackPainter( painter: TestCallbackPainter(
onPaint: () { onPaint: () {
baseline2 = child.getDistanceToBaseline(TextBaseline.alphabetic); baseline2 = child.getDistanceToBaseline(TextBaseline.alphabetic)!;
height2 = text.size.height; height2 = text.size.height;
}, },
), ),
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:ui'; import 'dart:ui';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -17,10 +15,10 @@ void main() { ...@@ -17,10 +15,10 @@ void main() {
// the rendering_test.dart dependency of this test uses the bindings in not // the rendering_test.dart dependency of this test uses the bindings in not
// compatible with existing tests in object_test.dart. // compatible with existing tests in object_test.dart.
test('reentrant paint error', () { test('reentrant paint error', () {
FlutterErrorDetails errorDetails; late FlutterErrorDetails errorDetails;
final RenderBox root = TestReentrantPaintingErrorRenderBox(); final RenderBox root = TestReentrantPaintingErrorRenderBox();
layout(root, onErrors: () { layout(root, onErrors: () {
errorDetails = renderer.takeFlutterErrorDetails(); errorDetails = renderer.takeFlutterErrorDetails()!;
}); });
pumpFrame(phase: EnginePhase.paint); pumpFrame(phase: EnginePhase.paint);
...@@ -64,7 +62,7 @@ void main() { ...@@ -64,7 +62,7 @@ void main() {
}); });
test('needsCompositingBitsUpdate paint error', () { test('needsCompositingBitsUpdate paint error', () {
FlutterError flutterError; late FlutterError flutterError;
final RenderBox root = RenderRepaintBoundary(child: RenderSizedBox(const Size(100, 100))); final RenderBox root = RenderRepaintBoundary(child: RenderSizedBox(const Size(100, 100)));
try { try {
layout(root); layout(root);
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import '../flutter_test_alternative.dart'; import '../flutter_test_alternative.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' as ui show TextBox; import 'dart:ui' as ui show TextBox;
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
...@@ -22,9 +20,10 @@ const String _kText = "I polished up that handle so carefullee\nThat now I am th ...@@ -22,9 +20,10 @@ const String _kText = "I polished up that handle so carefullee\nThat now I am th
// which may return an empty list in some situations where Libtxt would return a list // which may return an empty list in some situations where Libtxt would return a list
// containing an empty box. // containing an empty box.
class RenderParagraphWithEmptySelectionBoxList extends RenderParagraph { class RenderParagraphWithEmptySelectionBoxList extends RenderParagraph {
RenderParagraphWithEmptySelectionBoxList(InlineSpan text, { RenderParagraphWithEmptySelectionBoxList(
TextDirection textDirection, InlineSpan text, {
this.emptyListSelection, required TextDirection textDirection,
required this.emptyListSelection,
}) : super(text, textDirection: textDirection); }) : super(text, textDirection: textDirection);
TextSelection emptyListSelection; TextSelection emptyListSelection;
...@@ -65,7 +64,7 @@ void main() { ...@@ -65,7 +64,7 @@ void main() {
); );
layout(paragraph); layout(paragraph);
final double height5 = paragraph.getFullHeightForCaret(const TextPosition(offset: 5)); final double height5 = paragraph.getFullHeightForCaret(const TextPosition(offset: 5))!;
expect(height5, equals(10.0)); expect(height5, equals(10.0));
}); });
...@@ -136,7 +135,11 @@ void main() { ...@@ -136,7 +135,11 @@ void main() {
softWrap: true, softWrap: true,
); );
void relayoutWith({ int maxLines, bool softWrap, TextOverflow overflow }) { void relayoutWith({
int? maxLines,
required bool softWrap,
required TextOverflow overflow,
}) {
paragraph paragraph
..maxLines = maxLines ..maxLines = maxLines
..softWrap = softWrap ..softWrap = softWrap
...@@ -211,7 +214,7 @@ void main() { ...@@ -211,7 +214,7 @@ void main() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
); );
layout(paragraph, constraints: const BoxConstraints(maxWidth: 100.0)); layout(paragraph, constraints: const BoxConstraints(maxWidth: 100.0));
void layoutAt(int maxLines) { void layoutAt(int? maxLines) {
paragraph.maxLines = maxLines; paragraph.maxLines = maxLines;
pumpFrame(); pumpFrame();
} }
...@@ -562,7 +565,7 @@ void main() { ...@@ -562,7 +565,7 @@ void main() {
bool failed = false; bool failed = false;
try { try {
paragraph.assembleSemanticsNode(SemanticsNode(), SemanticsConfiguration(), <SemanticsNode>[]); paragraph.assembleSemanticsNode(SemanticsNode(), SemanticsConfiguration(), <SemanticsNode>[]);
} catch(e) { } on AssertionError catch (e) {
failed = true; failed = true;
expect(e.message, 'MultiTapGestureRecognizer is not supported.'); expect(e.message, 'MultiTapGestureRecognizer is not supported.');
} }
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' as ui; import 'dart:ui' as ui;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -17,8 +15,8 @@ import 'rendering_tester.dart'; ...@@ -17,8 +15,8 @@ import 'rendering_tester.dart';
void main() { void main() {
group('PlatformViewRenderBox', () { group('PlatformViewRenderBox', () {
FakePlatformViewController fakePlatformViewController; late FakePlatformViewController fakePlatformViewController;
PlatformViewRenderBox platformViewRenderBox; late PlatformViewRenderBox platformViewRenderBox;
setUp(() { setUp(() {
renderer; // Initialize bindings renderer; // Initialize bindings
fakePlatformViewController = FakePlatformViewController(0); fakePlatformViewController = FakePlatformViewController(0);
...@@ -78,7 +76,7 @@ void main() { ...@@ -78,7 +76,7 @@ void main() {
layout(platformViewRenderBox); layout(platformViewRenderBox);
pumpFrame(phase: EnginePhase.flushSemantics); pumpFrame(phase: EnginePhase.flushSemantics);
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(ui.PointerChange.add, const Offset(0, 0)), _pointerData(ui.PointerChange.add, const Offset(0, 0)),
_pointerData(ui.PointerChange.hover, const Offset(10, 10)), _pointerData(ui.PointerChange.hover, const Offset(10, 10)),
_pointerData(ui.PointerChange.remove, const Offset(10, 10)), _pointerData(ui.PointerChange.remove, const Offset(10, 10)),
...@@ -91,7 +89,7 @@ void main() { ...@@ -91,7 +89,7 @@ void main() {
layout(platformViewRenderBox); layout(platformViewRenderBox);
pumpFrame(phase: EnginePhase.flushSemantics); pumpFrame(phase: EnginePhase.flushSemantics);
ui.window.onPointerDataPacket(ui.PointerDataPacket(data: <ui.PointerData>[ ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
_pointerData(ui.PointerChange.add, const Offset(0, 0)), _pointerData(ui.PointerChange.add, const Offset(0, 0)),
_pointerData(ui.PointerChange.hover, const Offset(10, 10)), _pointerData(ui.PointerChange.hover, const Offset(10, 10)),
_pointerData(ui.PointerChange.remove, const Offset(10, 10)), _pointerData(ui.PointerChange.remove, const Offset(10, 10)),
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import '../flutter_test_alternative.dart'; import '../flutter_test_alternative.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:typed_data'; import 'dart:typed_data';
import 'dart:ui' as ui show Gradient, Image, ImageFilter; import 'dart:ui' as ui show Gradient, Image, ImageFilter;
...@@ -26,7 +24,7 @@ void main() { ...@@ -26,7 +24,7 @@ void main() {
layout(fittedBox, phase: EnginePhase.flushSemantics); layout(fittedBox, phase: EnginePhase.flushSemantics);
final Matrix4 transform = Matrix4.identity(); final Matrix4 transform = Matrix4.identity();
fittedBox.applyPaintTransform(fittedBox.child, transform); fittedBox.applyPaintTransform(fittedBox.child!, transform);
expect(transform, Matrix4.zero()); expect(transform, Matrix4.zero());
final BoxHitTestResult hitTestResult = BoxHitTestResult(); final BoxHitTestResult hitTestResult = BoxHitTestResult();
...@@ -223,7 +221,7 @@ void main() { ...@@ -223,7 +221,7 @@ void main() {
image = await boundary.toImage(); image = await boundary.toImage();
expect(image.width, equals(20)); expect(image.width, equals(20));
expect(image.height, equals(20)); expect(image.height, equals(20));
ByteData data = await image.toByteData(); ByteData data = (await image.toByteData())!;
int getPixel(int x, int y) => data.getUint32((x + y * image.width) * 4); int getPixel(int x, int y) => data.getUint32((x + y * image.width) * 4);
...@@ -237,7 +235,7 @@ void main() { ...@@ -237,7 +235,7 @@ void main() {
image = await layer.toImage(Offset.zero & const Size(20.0, 20.0)); image = await layer.toImage(Offset.zero & const Size(20.0, 20.0));
expect(image.width, equals(20)); expect(image.width, equals(20));
expect(image.height, equals(20)); expect(image.height, equals(20));
data = await image.toByteData(); data = (await image.toByteData())!;
expect(getPixel(0, 0), equals(0x00000080)); expect(getPixel(0, 0), equals(0x00000080));
expect(getPixel(image.width - 1, 0 ), equals(0xffffffff)); expect(getPixel(image.width - 1, 0 ), equals(0xffffffff));
...@@ -245,7 +243,7 @@ void main() { ...@@ -245,7 +243,7 @@ void main() {
image = await layer.toImage(const Offset(-10.0, -10.0) & const Size(30.0, 30.0)); image = await layer.toImage(const Offset(-10.0, -10.0) & const Size(30.0, 30.0));
expect(image.width, equals(30)); expect(image.width, equals(30));
expect(image.height, equals(30)); expect(image.height, equals(30));
data = await image.toByteData(); data = (await image.toByteData())!;
expect(getPixel(0, 0), equals(0x00000000)); expect(getPixel(0, 0), equals(0x00000000));
expect(getPixel(10, 10), equals(0x00000080)); expect(getPixel(10, 10), equals(0x00000080));
expect(getPixel(image.width - 1, 0), equals(0x00000000)); expect(getPixel(image.width - 1, 0), equals(0x00000000));
...@@ -255,7 +253,7 @@ void main() { ...@@ -255,7 +253,7 @@ void main() {
image = await layer.toImage(const Offset(-10.0, -10.0) & const Size(30.0, 30.0), pixelRatio: 2.0); image = await layer.toImage(const Offset(-10.0, -10.0) & const Size(30.0, 30.0), pixelRatio: 2.0);
expect(image.width, equals(60)); expect(image.width, equals(60));
expect(image.height, equals(60)); expect(image.height, equals(60));
data = await image.toByteData(); data = (await image.toByteData())!;
expect(getPixel(0, 0), equals(0x00000000)); expect(getPixel(0, 0), equals(0x00000000));
expect(getPixel(20, 20), equals(0x00000080)); expect(getPixel(20, 20), equals(0x00000080));
expect(getPixel(image.width - 1, 0), equals(0x00000000)); expect(getPixel(image.width - 1, 0), equals(0x00000000));
...@@ -600,7 +598,7 @@ void _testLayerReuse<L extends Layer>(RenderBox renderObject) { ...@@ -600,7 +598,7 @@ void _testLayerReuse<L extends Layer>(RenderBox renderObject) {
expect(L, isNot(Layer)); expect(L, isNot(Layer));
expect(renderObject.debugLayer, null); expect(renderObject.debugLayer, null);
layout(renderObject, phase: EnginePhase.paint, constraints: BoxConstraints.tight(const Size(10, 10))); layout(renderObject, phase: EnginePhase.paint, constraints: BoxConstraints.tight(const Size(10, 10)));
final Layer layer = renderObject.debugLayer; final Layer layer = renderObject.debugLayer!;
expect(layer, isA<L>()); expect(layer, isA<L>());
expect(layer, isNotNull); expect(layer, isNotNull);
...@@ -624,8 +622,8 @@ class _TestPathClipper extends CustomClipper<Path> { ...@@ -624,8 +622,8 @@ class _TestPathClipper extends CustomClipper<Path> {
class _TestSemanticsUpdateRenderFractionalTranslation extends RenderFractionalTranslation { class _TestSemanticsUpdateRenderFractionalTranslation extends RenderFractionalTranslation {
_TestSemanticsUpdateRenderFractionalTranslation({ _TestSemanticsUpdateRenderFractionalTranslation({
@required Offset translation, required Offset translation,
RenderBox child, RenderBox? child,
}) : super(translation: translation, child: child); }) : super(translation: translation, child: child);
int markNeedsSemanticsUpdateCallCount = 0; int markNeedsSemanticsUpdateCallCount = 0;
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import '../flutter_test_alternative.dart'; import '../flutter_test_alternative.dart';
...@@ -53,8 +51,16 @@ void main() { ...@@ -53,8 +51,16 @@ void main() {
}); });
test('RenderShaderMask getters and setters', () { test('RenderShaderMask getters and setters', () {
final ShaderCallback callback1 = (Rect bounds) => null; final ShaderCallback callback1 = (Rect bounds) {
final ShaderCallback callback2 = (Rect bounds) => null; assert(false); // The test should not call this.
const LinearGradient gradient = LinearGradient(colors: <Color>[Colors.red]);
return gradient.createShader(Rect.zero);
};
final ShaderCallback callback2 = (Rect bounds) {
assert(false); // The test should not call this.
const LinearGradient gradient = LinearGradient(colors: <Color>[Colors.blue]);
return gradient.createShader(Rect.zero);
};
final RenderShaderMask box = RenderShaderMask(shaderCallback: callback1); final RenderShaderMask box = RenderShaderMask(shaderCallback: callback1);
expect(box.shaderCallback, equals(callback1)); expect(box.shaderCallback, equals(callback1));
box.shaderCallback = callback2; box.shaderCallback = callback2;
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/animation.dart'; import 'package:flutter/animation.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
...@@ -69,7 +67,7 @@ void main() { ...@@ -69,7 +67,7 @@ void main() {
expect(renderSliverOpacity.debugLayer, null); expect(renderSliverOpacity.debugLayer, null);
layout(root, phase: EnginePhase.paint, constraints: BoxConstraints.tight(const Size(10, 10))); layout(root, phase: EnginePhase.paint, constraints: BoxConstraints.tight(const Size(10, 10)));
final ContainerLayer layer = renderSliverOpacity.debugLayer; final ContainerLayer layer = renderSliverOpacity.debugLayer!;
expect(layer, isNotNull); expect(layer, isNotNull);
// Mark for repaint otherwise pumpFrame is a noop. // Mark for repaint otherwise pumpFrame is a noop.
...@@ -152,7 +150,7 @@ void main() { ...@@ -152,7 +150,7 @@ void main() {
expect(renderSliverAnimatedOpacity.debugLayer, null); expect(renderSliverAnimatedOpacity.debugLayer, null);
layout(root, phase: EnginePhase.paint, constraints: BoxConstraints.tight(const Size(10, 10))); layout(root, phase: EnginePhase.paint, constraints: BoxConstraints.tight(const Size(10, 10)));
final ContainerLayer layer = renderSliverAnimatedOpacity.debugLayer; final ContainerLayer layer = renderSliverAnimatedOpacity.debugLayer!;
expect(layer, isNotNull); expect(layer, isNotNull);
// Mark for repaint otherwise pumpFrame is a noop. // Mark for repaint otherwise pumpFrame is a noop.
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import '../flutter_test_alternative.dart'; import '../flutter_test_alternative.dart';
...@@ -41,13 +39,13 @@ class TestTree { ...@@ -41,13 +39,13 @@ class TestTree {
), ),
); );
} }
RenderBox root; late RenderBox root;
RenderConstrainedBox child; late RenderConstrainedBox child;
bool painted = false; bool painted = false;
} }
class MutableCompositor extends RenderProxyBox { class MutableCompositor extends RenderProxyBox {
MutableCompositor({ RenderBox child }) : super(child); MutableCompositor({ required RenderBox child }) : super(child);
bool _alwaysComposite = false; bool _alwaysComposite = false;
@override @override
bool get alwaysNeedsCompositing => _alwaysComposite; bool get alwaysNeedsCompositing => _alwaysComposite;
...@@ -77,9 +75,9 @@ class TestCompositingBitsTree { ...@@ -77,9 +75,9 @@ class TestCompositingBitsTree {
), ),
); );
} }
RenderBox root; late RenderBox root;
MutableCompositor compositor; late MutableCompositor compositor;
RenderConstrainedBox child; late RenderConstrainedBox child;
bool painted = false; bool painted = false;
} }
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import '../flutter_test_alternative.dart'; import '../flutter_test_alternative.dart';
...@@ -48,7 +46,7 @@ void main() { ...@@ -48,7 +46,7 @@ void main() {
test('RelativeRect.lerp', () { test('RelativeRect.lerp', () {
const RelativeRect r1 = RelativeRect.fill; const RelativeRect r1 = RelativeRect.fill;
const RelativeRect r2 = RelativeRect.fromLTRB(10.0, 20.0, 30.0, 40.0); const RelativeRect r2 = RelativeRect.fromLTRB(10.0, 20.0, 30.0, 40.0);
final RelativeRect r3 = RelativeRect.lerp(r1, r2, 0.5); final RelativeRect r3 = RelativeRect.lerp(r1, r2, 0.5)!;
expect(r3, const RelativeRect.fromLTRB(5.0, 10.0, 15.0, 20.0)); expect(r3, const RelativeRect.fromLTRB(5.0, 10.0, 15.0, 20.0));
}); });
} }
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
...@@ -17,7 +15,7 @@ void main() { ...@@ -17,7 +15,7 @@ void main() {
} }
class RelayoutBoundariesCrash extends StatefulWidget { class RelayoutBoundariesCrash extends StatefulWidget {
const RelayoutBoundariesCrash({Key key}) : super(key: key); const RelayoutBoundariesCrash({Key? key}) : super(key: key);
@override @override
RelayoutBoundariesCrashState createState() => RelayoutBoundariesCrashState(); RelayoutBoundariesCrashState createState() => RelayoutBoundariesCrashState();
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import '../flutter_test_alternative.dart'; import '../flutter_test_alternative.dart';
...@@ -92,9 +90,9 @@ void main() { ...@@ -92,9 +90,9 @@ void main() {
child: faultyRenderObject, child: faultyRenderObject,
); );
FlutterErrorDetails error; late FlutterErrorDetails error;
layout(opacity, phase: EnginePhase.flushSemantics, onErrors: () { layout(opacity, phase: EnginePhase.flushSemantics, onErrors: () {
error = renderer.takeFlutterErrorDetails(); error = renderer.takeFlutterErrorDetails()!;
}); });
expect('${error.exception}', contains('Attempted to set a layer to a repaint boundary render object.')); expect('${error.exception}', contains('Attempted to set a layer to a repaint boundary render object.'));
}); });
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart' show TestVSync; import 'package:flutter_test/flutter_test.dart' show TestVSync;
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import '../flutter_test_alternative.dart'; import '../flutter_test_alternative.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import '../flutter_test_alternative.dart'; import '../flutter_test_alternative.dart';
......
...@@ -2,9 +2,6 @@ ...@@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import '../flutter_test_alternative.dart'; import '../flutter_test_alternative.dart';
...@@ -880,25 +877,36 @@ void main() { ...@@ -880,25 +877,36 @@ void main() {
}); });
} }
void expectSliverConstraints({ RenderSliver sliver, double cacheOrigin, double remainingPaintExtent, double remainingCacheExtent, double scrollOffset }) { void expectSliverConstraints({
required RenderSliver sliver,
required double cacheOrigin,
required double remainingPaintExtent,
required double remainingCacheExtent,
required double scrollOffset,
}) {
expect(sliver.constraints.cacheOrigin, cacheOrigin, reason: 'cacheOrigin'); expect(sliver.constraints.cacheOrigin, cacheOrigin, reason: 'cacheOrigin');
expect(sliver.constraints.remainingPaintExtent, remainingPaintExtent, reason: 'remainingPaintExtent'); expect(sliver.constraints.remainingPaintExtent, remainingPaintExtent, reason: 'remainingPaintExtent');
expect(sliver.constraints.remainingCacheExtent, remainingCacheExtent, reason: 'remainingCacheExtent'); expect(sliver.constraints.remainingCacheExtent, remainingCacheExtent, reason: 'remainingCacheExtent');
expect(sliver.constraints.scrollOffset, scrollOffset, reason: 'scrollOffset'); expect(sliver.constraints.scrollOffset, scrollOffset, reason: 'scrollOffset');
} }
void expectSliverGeometry({ RenderSliver sliver, double paintExtent, double cacheExtent, bool visible }) { void expectSliverGeometry({
expect(sliver.geometry.paintExtent, paintExtent, reason: 'paintExtent'); required RenderSliver sliver,
expect(sliver.geometry.cacheExtent, cacheExtent, reason: 'cacheExtent'); required double paintExtent,
expect(sliver.geometry.visible, visible, reason: 'visible'); required double cacheExtent,
required bool visible,
}) {
expect(sliver.geometry!.paintExtent, paintExtent, reason: 'paintExtent');
expect(sliver.geometry!.cacheExtent, cacheExtent, reason: 'cacheExtent');
expect(sliver.geometry!.visible, visible, reason: 'visible');
} }
class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager { class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager {
TestRenderSliverBoxChildManager({ TestRenderSliverBoxChildManager({
this.children, required this.children,
}); });
RenderSliverMultiBoxAdaptor _renderObject; RenderSliverMultiBoxAdaptor? _renderObject;
List<RenderBox> children; List<RenderBox> children;
RenderSliverList createRenderSliverList() { RenderSliverList createRenderSliverList() {
...@@ -928,15 +936,15 @@ class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager { ...@@ -928,15 +936,15 @@ class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager {
return _renderObject as RenderSliverGrid; return _renderObject as RenderSliverGrid;
} }
int _currentlyUpdatingChildIndex; int? _currentlyUpdatingChildIndex;
@override @override
void createChild(int index, { @required RenderBox after }) { void createChild(int index, { required RenderBox? after }) {
if (index < 0 || index >= children.length) if (index < 0 || index >= children.length)
return; return;
try { try {
_currentlyUpdatingChildIndex = index; _currentlyUpdatingChildIndex = index;
_renderObject.insert(children[index], after: after); _renderObject!.insert(children[index], after: after);
} finally { } finally {
_currentlyUpdatingChildIndex = null; _currentlyUpdatingChildIndex = null;
} }
...@@ -944,19 +952,19 @@ class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager { ...@@ -944,19 +952,19 @@ class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager {
@override @override
void removeChild(RenderBox child) { void removeChild(RenderBox child) {
_renderObject.remove(child); _renderObject!.remove(child);
} }
@override @override
double estimateMaxScrollOffset( double estimateMaxScrollOffset(
SliverConstraints constraints, { SliverConstraints constraints, {
int firstIndex, int? firstIndex,
int lastIndex, int? lastIndex,
double leadingScrollOffset, double? leadingScrollOffset,
double trailingScrollOffset, double? trailingScrollOffset,
}) { }) {
assert(lastIndex >= firstIndex); assert(lastIndex! >= firstIndex!);
return children.length * (trailingScrollOffset - leadingScrollOffset) / (lastIndex - firstIndex + 1); return children.length * (trailingScrollOffset! - leadingScrollOffset!) / (lastIndex! - firstIndex! + 1);
} }
@override @override
......
...@@ -2,9 +2,6 @@ ...@@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import '../flutter_test_alternative.dart'; import '../flutter_test_alternative.dart';
...@@ -48,10 +45,10 @@ void main() { ...@@ -48,10 +45,10 @@ void main() {
class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager { class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager {
TestRenderSliverBoxChildManager({ TestRenderSliverBoxChildManager({
this.children, required this.children,
}); });
RenderSliverMultiBoxAdaptor _renderObject; RenderSliverMultiBoxAdaptor? _renderObject;
List<RenderBox> children; List<RenderBox> children;
RenderSliverFillViewport createRenderSliverFillViewport() { RenderSliverFillViewport createRenderSliverFillViewport() {
...@@ -62,15 +59,15 @@ class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager { ...@@ -62,15 +59,15 @@ class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager {
return _renderObject as RenderSliverFillViewport; return _renderObject as RenderSliverFillViewport;
} }
int _currentlyUpdatingChildIndex; int? _currentlyUpdatingChildIndex;
@override @override
void createChild(int index, { @required RenderBox after }) { void createChild(int index, { required RenderBox? after }) {
if (index < 0 || index >= children.length) if (index < 0 || index >= children.length)
return; return;
try { try {
_currentlyUpdatingChildIndex = index; _currentlyUpdatingChildIndex = index;
_renderObject.insert(children[index], after: after); _renderObject!.insert(children[index], after: after);
} finally { } finally {
_currentlyUpdatingChildIndex = null; _currentlyUpdatingChildIndex = null;
} }
...@@ -78,19 +75,19 @@ class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager { ...@@ -78,19 +75,19 @@ class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager {
@override @override
void removeChild(RenderBox child) { void removeChild(RenderBox child) {
_renderObject.remove(child); _renderObject!.remove(child);
} }
@override @override
double estimateMaxScrollOffset( double estimateMaxScrollOffset(
SliverConstraints constraints, { SliverConstraints constraints, {
int firstIndex, int? firstIndex,
int lastIndex, int? lastIndex,
double leadingScrollOffset, double? leadingScrollOffset,
double trailingScrollOffset, double? trailingScrollOffset,
}) { }) {
assert(lastIndex >= firstIndex); assert(lastIndex! >= firstIndex!);
return children.length * (trailingScrollOffset - leadingScrollOffset) / (lastIndex - firstIndex + 1); return children.length * (trailingScrollOffset! - leadingScrollOffset!) / (lastIndex! - firstIndex! + 1);
} }
@override @override
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import '../flutter_test_alternative.dart'; import '../flutter_test_alternative.dart';
...@@ -24,7 +22,7 @@ void main() { ...@@ -24,7 +22,7 @@ void main() {
); );
layout(root); layout(root);
expect(header.geometry.maxScrollObstructionExtent, 0); expect(header.geometry!.maxScrollObstructionExtent, 0);
}); });
test('RenderSliverFloatingPinnedPersistentHeader maxScrollObstructionExtent is minExtent', () { test('RenderSliverFloatingPinnedPersistentHeader maxScrollObstructionExtent is minExtent', () {
...@@ -42,13 +40,13 @@ void main() { ...@@ -42,13 +40,13 @@ void main() {
); );
layout(root); layout(root);
expect(header.geometry.maxScrollObstructionExtent, 100.0); expect(header.geometry!.maxScrollObstructionExtent, 100.0);
}); });
} }
class TestRenderSliverFloatingPersistentHeader extends RenderSliverFloatingPersistentHeader { class TestRenderSliverFloatingPersistentHeader extends RenderSliverFloatingPersistentHeader {
TestRenderSliverFloatingPersistentHeader({ TestRenderSliverFloatingPersistentHeader({
RenderBox child, required RenderBox child,
}) : super(child: child, vsync: null, showOnScreenConfiguration: null); }) : super(child: child, vsync: null, showOnScreenConfiguration: null);
@override @override
...@@ -60,7 +58,7 @@ class TestRenderSliverFloatingPersistentHeader extends RenderSliverFloatingPersi ...@@ -60,7 +58,7 @@ class TestRenderSliverFloatingPersistentHeader extends RenderSliverFloatingPersi
class TestRenderSliverFloatingPinnedPersistentHeader extends RenderSliverFloatingPinnedPersistentHeader { class TestRenderSliverFloatingPinnedPersistentHeader extends RenderSliverFloatingPinnedPersistentHeader {
TestRenderSliverFloatingPinnedPersistentHeader({ TestRenderSliverFloatingPinnedPersistentHeader({
RenderBox child, required RenderBox child,
}) : super(child: child, vsync: null, showOnScreenConfiguration: null); }) : super(child: child, vsync: null, showOnScreenConfiguration: null);
@override @override
......
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