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 '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,35 +11,33 @@ import 'rendering_tester.dart'; ...@@ -13,35 +11,33 @@ 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);
} }
final RenderObject child; final RenderObject child;
@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