Unverified Commit cbf1e135 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Migrate non-test files in flutter/test (#67098)

parent ddb81770
......@@ -58,6 +58,10 @@ class SynchronousErrorTestImageProvider extends ImageProvider<int> {
}
class AsyncTestImageProvider extends ImageProvider<int> {
AsyncTestImageProvider(this.image);
final ui.Image image;
@override
Future<int> obtainKey(ImageConfiguration configuration) {
return Future<int>.value(2);
......@@ -66,7 +70,7 @@ class AsyncTestImageProvider extends ImageProvider<int> {
@override
ImageStreamCompleter load(int key, DecoderCallback decode) {
return OneFrameImageStreamCompleter(
Future<ImageInfo>.value(TestImageInfo(key))
Future<ImageInfo>.value(TestImageInfo(key, image: image))
);
}
}
......@@ -147,9 +151,10 @@ void main() {
expect(onChangedCalled, equals(false));
});
test('BoxDecorationImageListenerAsync', () {
test('BoxDecorationImageListenerAsync', () async {
final ui.Image image = await createTestImage(width: 10, height: 10);
FakeAsync().run((FakeAsync async) {
final ImageProvider imageProvider = AsyncTestImageProvider();
final ImageProvider imageProvider = AsyncTestImageProvider(image);
final DecorationImage backgroundImage = DecorationImage(image: imageProvider);
final BoxDecoration boxDecoration = BoxDecoration(image: backgroundImage);
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:typed_data';
import 'dart:ui' as ui show Codec, FrameInfo, instantiateImageCodec;
......@@ -28,9 +26,9 @@ class FakeCodec implements ui.Codec {
static Future<FakeCodec> fromData(Uint8List data) async {
final ui.Codec codec = await ui.instantiateImageCodec(data);
final int frameCount = codec.frameCount;
final List<ui.FrameInfo> frameInfos = List<ui.FrameInfo>(frameCount);
final List<ui.FrameInfo> frameInfos = <ui.FrameInfo>[];
for (int i = 0; i < frameCount; i += 1)
frameInfos[i] = await codec.getNextFrame();
frameInfos.add(await codec.getNextFrame());
return FakeCodec._(frameCount, codec.repetitionCount, frameInfos);
}
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' as ui show Codec;
import 'package:flutter/foundation.dart';
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:async';
import 'dart:ui' as ui;
......@@ -19,7 +17,7 @@ class TestImageProvider extends ImageProvider<TestImageProvider> {
final ui.Image testImage;
final Completer<ImageInfo> _completer = Completer<ImageInfo>.sync();
ImageConfiguration configuration;
ImageConfiguration? configuration;
int loadCallCount = 0;
@override
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:async';
import 'dart:ui' as ui show Image;
......@@ -11,7 +9,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/painting.dart';
class TestImageInfo implements ImageInfo {
const TestImageInfo(this.value, { this.image, this.scale = 1.0, this.debugLabel });
const TestImageInfo(this.value, { required this.image, this.scale = 1.0, this.debugLabel });
@override
final ui.Image image;
......@@ -20,7 +18,7 @@ class TestImageInfo implements ImageInfo {
final double scale;
@override
final String debugLabel;
final String? debugLabel;
final int value;
......@@ -29,7 +27,7 @@ class TestImageInfo implements ImageInfo {
}
class TestImageProvider extends ImageProvider<int> {
const TestImageProvider(this.key, this.imageValue, { @required this.image })
const TestImageProvider(this.key, this.imageValue, { required this.image })
: assert(image != null);
final int key;
......@@ -53,7 +51,7 @@ class TestImageProvider extends ImageProvider<int> {
}
class FailingTestImageProvider extends TestImageProvider {
const FailingTestImageProvider(int key, int imageValue, { ui.Image image }) : super(key, imageValue, image: image);
const FailingTestImageProvider(int key, int imageValue, { required ui.Image image }) : super(key, imageValue, image: image);
@override
ImageStreamCompleter load(int key, DecoderCallback decode) {
......@@ -63,7 +61,7 @@ class FailingTestImageProvider extends TestImageProvider {
Future<ImageInfo> extractOneFrame(ImageStream stream) {
final Completer<ImageInfo> completer = Completer<ImageInfo>();
ImageStreamListener listener;
late ImageStreamListener listener;
listener = ImageStreamListener((ImageInfo image, bool synchronousCall) {
completer.complete(image);
stream.removeListener(listener);
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:typed_data';
import 'dart:ui' as ui;
......@@ -17,7 +15,7 @@ class PaintingBindingSpy extends BindingBase with SchedulerBinding, ServicesBind
int get instantiateImageCodecCalledCount => counter;
@override
Future<ui.Codec> instantiateImageCodec(Uint8List list, {int cacheWidth, int cacheHeight, bool allowUpscaling = false}) {
Future<ui.Codec> instantiateImageCodec(Uint8List list, {int? cacheWidth, int? cacheHeight, bool allowUpscaling = false}) {
counter++;
return ui.instantiateImageCodec(list);
}
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' as ui show Paragraph, Image;
import 'package:flutter/foundation.dart';
......@@ -102,14 +100,14 @@ abstract class PaintPattern {
/// Calls are skipped until a call to [Canvas.translate] is found. The call's
/// arguments are compared to those provided here. If any fail to match, or if
/// no call to [Canvas.translate] is found, then the matcher fails.
void translate({ double x, double y });
void translate({ double? x, double? y });
/// Indicates that a scale transform is expected next.
///
/// Calls are skipped until a call to [Canvas.scale] is found. The call's
/// arguments are compared to those provided here. If any fail to match, or if
/// no call to [Canvas.scale] is found, then the matcher fails.
void scale({ double x, double y });
void scale({ double? x, double? y });
/// Indicates that a rotate transform is expected next.
///
......@@ -117,7 +115,7 @@ abstract class PaintPattern {
/// argument is provided here, the call's argument is compared to it. If that
/// fails to match, or if no call to [Canvas.rotate] is found, then the
/// matcher fails.
void rotate({ double angle });
void rotate({ double? angle });
/// Indicates that a save is expected next.
///
......@@ -165,7 +163,7 @@ abstract class PaintPattern {
///
/// Any calls made between the last matched call (if any) and the
/// [Canvas.clipRect] call are ignored.
void clipRect({ Rect rect });
void clipRect({ Rect? rect });
/// Indicates that a path clip is expected next.
///
......@@ -177,7 +175,7 @@ abstract class PaintPattern {
///
/// Any calls made between the last matched call (if any) and the
/// [Canvas.clipPath] call are ignored.
void clipPath({ Matcher pathMatcher });
void clipPath({ Matcher? pathMatcher });
/// Indicates that a rectangle is expected next.
///
......@@ -195,7 +193,7 @@ abstract class PaintPattern {
/// painting has completed, not at the time of the call. If the same [Paint]
/// object is reused multiple times, then this may not match the actual
/// arguments as they were seen by the method.
void rect({ Rect rect, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style });
void rect({ Rect? rect, Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style });
/// Indicates that a rounded rectangle clip is expected next.
///
......@@ -207,7 +205,7 @@ abstract class PaintPattern {
///
/// Any calls made between the last matched call (if any) and the
/// [Canvas.clipRRect] call are ignored.
void clipRRect({ RRect rrect });
void clipRRect({ RRect? rrect });
/// Indicates that a rounded rectangle is expected next.
///
......@@ -225,7 +223,7 @@ abstract class PaintPattern {
/// painting has completed, not at the time of the call. If the same [Paint]
/// object is reused multiple times, then this may not match the actual
/// arguments as they were seen by the method.
void rrect({ RRect rrect, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style });
void rrect({ RRect? rrect, Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style });
/// Indicates that a rounded rectangle outline is expected next.
///
......@@ -243,7 +241,7 @@ abstract class PaintPattern {
/// painting has completed, not at the time of the call. If the same [Paint]
/// object is reused multiple times, then this may not match the actual
/// arguments as they were seen by the method.
void drrect({ RRect outer, RRect inner, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style });
void drrect({ RRect? outer, RRect? inner, Color? color, double strokeWidth, bool hasMaskFilter, PaintingStyle style });
/// Indicates that a circle is expected next.
///
......@@ -261,7 +259,7 @@ abstract class PaintPattern {
/// painting has completed, not at the time of the call. If the same [Paint]
/// object is reused multiple times, then this may not match the actual
/// arguments as they were seen by the method.
void circle({ double x, double y, double radius, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style });
void circle({ double? x, double? y, double? radius, Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style });
/// Indicates that a path is expected next.
///
......@@ -284,7 +282,7 @@ abstract class PaintPattern {
/// painting has completed, not at the time of the call. If the same [Paint]
/// object is reused multiple times, then this may not match the actual
/// arguments as they were seen by the method.
void path({ Iterable<Offset> includes, Iterable<Offset> excludes, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style });
void path({ Iterable<Offset>? includes, Iterable<Offset>? excludes, Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style });
/// Indicates that a line is expected next.
///
......@@ -302,7 +300,7 @@ abstract class PaintPattern {
/// painting has completed, not at the time of the call. If the same [Paint]
/// object is reused multiple times, then this may not match the actual
/// arguments as they were seen by the method.
void line({ Offset p1, Offset p2, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style });
void line({ Offset? p1, Offset? p2, Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style });
/// Indicates that an arc is expected next.
///
......@@ -320,7 +318,7 @@ abstract class PaintPattern {
/// painting has completed, not at the time of the call. If the same [Paint]
/// object is reused multiple times, then this may not match the actual
/// arguments as they were seen by the method.
void arc({ Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style });
void arc({ Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style });
/// Indicates that a paragraph is expected next.
///
......@@ -336,7 +334,7 @@ abstract class PaintPattern {
/// offset.
///
/// If no call to [Canvas.drawParagraph] was made, then this results in failure.
void paragraph({ ui.Paragraph paragraph, dynamic offset });
void paragraph({ ui.Paragraph? paragraph, dynamic offset });
/// Indicates that a shadow is expected next.
///
......@@ -357,7 +355,7 @@ abstract class PaintPattern {
///
/// Any calls made between the last matched call (if any) and the
/// [Canvas.drawShadow] call are ignored.
void shadow({ Iterable<Offset> includes, Iterable<Offset> excludes, Color color, double elevation, bool transparentOccluder });
void shadow({ Iterable<Offset>? includes, Iterable<Offset>? excludes, Color? color, double? elevation, bool? transparentOccluder });
/// Indicates that an image is expected next.
///
......@@ -375,7 +373,7 @@ abstract class PaintPattern {
/// painting has completed, not at the time of the call. If the same [Paint]
/// object is reused multiple times, then this may not match the actual
/// arguments as they were seen by the method.
void image({ ui.Image image, double x, double y, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style });
void image({ ui.Image? image, double? x, double? y, Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style });
/// Indicates that an image subsection is expected next.
///
......@@ -393,7 +391,7 @@ abstract class PaintPattern {
/// painting has completed, not at the time of the call. If the same [Paint]
/// object is reused multiple times, then this may not match the actual
/// arguments as they were seen by the method.
void drawImageRect({ ui.Image image, Rect source, Rect destination, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style });
void drawImageRect({ ui.Image? image, Rect? source, Rect? destination, Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style });
/// Provides a custom matcher.
///
......@@ -451,12 +449,12 @@ class _PathMatcher extends Matcher {
List<Offset> excludes;
@override
bool matches(Object object, Map<dynamic, dynamic> matchState) {
bool matches(Object? object, Map<dynamic, dynamic> matchState) {
if (object is! Path) {
matchState[this] = 'The given object ($object) was not a Path.';
return false;
}
final Path path = object as Path;
final Path path = object;
final List<String> errors = <String>[
for (final Offset offset in includes)
if (!path.contains(offset))
......@@ -500,7 +498,7 @@ class _MismatchedCall {
final RecordedInvocation call;
}
bool _evaluatePainter(Object object, Canvas canvas, PaintingContext context) {
bool _evaluatePainter(Object? object, Canvas canvas, PaintingContext context) {
if (object is _ContextPainterFunction) {
final _ContextPainterFunction function = object;
function(context, Offset.zero);
......@@ -510,7 +508,7 @@ bool _evaluatePainter(Object object, Canvas canvas, PaintingContext context) {
} else {
if (object is Finder) {
TestAsyncUtils.guardSync();
final Finder finder = object as Finder;
final Finder finder = object;
object = finder.evaluate().single.renderObject;
}
if (object is RenderObject) {
......@@ -525,7 +523,7 @@ bool _evaluatePainter(Object object, Canvas canvas, PaintingContext context) {
abstract class _TestRecordingCanvasMatcher extends Matcher {
@override
bool matches(Object object, Map<dynamic, dynamic> matchState) {
bool matches(Object? object, Map<dynamic, dynamic> matchState) {
final TestRecordingCanvas canvas = TestRecordingCanvas();
final TestRecordingPaintingContext context = TestRecordingPaintingContext(canvas);
final StringBuffer description = StringBuffer();
......@@ -630,7 +628,7 @@ class _TestRecordingCanvasPaintsNothingMatcher extends _TestRecordingCanvasMatch
class _TestRecordingCanvasPaintsAssertionMatcher extends Matcher {
@override
bool matches(Object object, Map<dynamic, dynamic> matchState) {
bool matches(Object? object, Map<dynamic, dynamic> matchState) {
final TestRecordingCanvas canvas = TestRecordingCanvas();
final TestRecordingPaintingContext context = TestRecordingPaintingContext(canvas);
final StringBuffer description = StringBuffer();
......@@ -686,17 +684,17 @@ class _TestRecordingCanvasPatternMatcher extends _TestRecordingCanvasMatcher imp
}
@override
void translate({ double x, double y }) {
void translate({ double? x, double? y }) {
_predicates.add(_FunctionPaintPredicate(#translate, <dynamic>[x, y]));
}
@override
void scale({ double x, double y }) {
void scale({ double? x, double? y }) {
_predicates.add(_FunctionPaintPredicate(#scale, <dynamic>[x, y]));
}
@override
void rotate({ double angle }) {
void rotate({ double? angle }) {
_predicates.add(_FunctionPaintPredicate(#rotate, <dynamic>[angle]));
}
......@@ -716,72 +714,72 @@ class _TestRecordingCanvasPatternMatcher extends _TestRecordingCanvasMatcher imp
}
@override
void clipRect({ Rect rect }) {
void clipRect({ Rect? rect }) {
_predicates.add(_FunctionPaintPredicate(#clipRect, <dynamic>[rect]));
}
@override
void clipPath({ Matcher pathMatcher }) {
void clipPath({ Matcher? pathMatcher }) {
_predicates.add(_FunctionPaintPredicate(#clipPath, <dynamic>[pathMatcher]));
}
@override
void rect({ Rect rect, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style }) {
void rect({ Rect? rect, Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style }) {
_predicates.add(_RectPaintPredicate(rect: rect, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style));
}
@override
void clipRRect({ RRect rrect }) {
void clipRRect({ RRect? rrect }) {
_predicates.add(_FunctionPaintPredicate(#clipRRect, <dynamic>[rrect]));
}
@override
void rrect({ RRect rrect, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style }) {
void rrect({ RRect? rrect, Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style }) {
_predicates.add(_RRectPaintPredicate(rrect: rrect, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style));
}
@override
void drrect({ RRect outer, RRect inner, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style }) {
void drrect({ RRect? outer, RRect? inner, Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style }) {
_predicates.add(_DRRectPaintPredicate(outer: outer, inner: inner, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style));
}
@override
void circle({ double x, double y, double radius, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style }) {
void circle({ double? x, double? y, double? radius, Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style }) {
_predicates.add(_CirclePaintPredicate(x: x, y: y, radius: radius, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style));
}
@override
void path({ Iterable<Offset> includes, Iterable<Offset> excludes, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style }) {
void path({ Iterable<Offset>? includes, Iterable<Offset>? excludes, Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style }) {
_predicates.add(_PathPaintPredicate(includes: includes, excludes: excludes, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style));
}
@override
void line({ Offset p1, Offset p2, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style }) {
void line({ Offset? p1, Offset? p2, Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style }) {
_predicates.add(_LinePaintPredicate(p1: p1, p2: p2, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style));
}
@override
void arc({ Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style }) {
void arc({ Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style }) {
_predicates.add(_ArcPaintPredicate(color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style));
}
@override
void paragraph({ ui.Paragraph paragraph, dynamic offset }) {
void paragraph({ ui.Paragraph? paragraph, dynamic offset }) {
_predicates.add(_FunctionPaintPredicate(#drawParagraph, <dynamic>[paragraph, offset]));
}
@override
void shadow({ Iterable<Offset> includes, Iterable<Offset> excludes, Color color, double elevation, bool transparentOccluder }) {
void shadow({ Iterable<Offset>? includes, Iterable<Offset>? excludes, Color? color, double? elevation, bool? transparentOccluder }) {
_predicates.add(_ShadowPredicate(includes: includes, excludes: excludes, color: color, elevation: elevation, transparentOccluder: transparentOccluder));
}
@override
void image({ ui.Image image, double x, double y, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style }) {
void image({ ui.Image? image, double? x, double? y, Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style }) {
_predicates.add(_DrawImagePaintPredicate(image: image, x: x, y: y, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style));
}
@override
void drawImageRect({ ui.Image image, Rect source, Rect destination, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style }) {
void drawImageRect({ ui.Image? image, Rect? source, Rect? destination, Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style }) {
_predicates.add(_DrawImageRectPaintPredicate(image: image, source: source, destination: destination, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style));
}
......@@ -892,10 +890,10 @@ abstract class _DrawCommandPaintPredicate extends _PaintPredicate {
final String name;
final int argumentCount;
final int paintArgumentIndex;
final Color color;
final double strokeWidth;
final bool hasMaskFilter;
final PaintingStyle style;
final Color? color;
final double? strokeWidth;
final bool? hasMaskFilter;
final PaintingStyle? style;
String get methodName => _symbolName(symbol);
......@@ -918,7 +916,7 @@ abstract class _DrawCommandPaintPredicate extends _PaintPredicate {
if (strokeWidth != null && paintArgument.strokeWidth != strokeWidth)
throw 'It called $methodName with a paint whose strokeWidth, ${paintArgument.strokeWidth}, was not exactly the expected strokeWidth ($strokeWidth).';
if (hasMaskFilter != null && (paintArgument.maskFilter != null) != hasMaskFilter) {
if (hasMaskFilter)
if (hasMaskFilter!)
throw 'It called $methodName with a paint that did not have a mask filter, despite expecting one.';
else
throw 'It called $methodName with a paint that did have a mask filter, despite not expecting one.';
......@@ -945,7 +943,7 @@ abstract class _DrawCommandPaintPredicate extends _PaintPredicate {
if (strokeWidth != null)
description.add('strokeWidth: $strokeWidth');
if (hasMaskFilter != null)
description.add(hasMaskFilter ? 'a mask filter' : 'no mask filter');
description.add(hasMaskFilter! ? 'a mask filter' : 'no mask filter');
if (style != null)
description.add('$style');
}
......@@ -955,15 +953,15 @@ class _OneParameterPaintPredicate<T> extends _DrawCommandPaintPredicate {
_OneParameterPaintPredicate(
Symbol symbol,
String name, {
@required this.expected,
@required Color color,
@required double strokeWidth,
@required bool hasMaskFilter,
@required PaintingStyle style,
required this.expected,
required Color? color,
required double? strokeWidth,
required bool? hasMaskFilter,
required PaintingStyle? style,
}) : super(
symbol, name, 2, 1, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style);
final T expected;
final T? expected;
@override
void verifyArguments(List<dynamic> arguments) {
......@@ -990,18 +988,18 @@ class _TwoParameterPaintPredicate<T1, T2> extends _DrawCommandPaintPredicate {
_TwoParameterPaintPredicate(
Symbol symbol,
String name, {
@required this.expected1,
@required this.expected2,
@required Color color,
@required double strokeWidth,
@required bool hasMaskFilter,
@required PaintingStyle style,
required this.expected1,
required this.expected2,
required Color? color,
required double? strokeWidth,
required bool? hasMaskFilter,
required PaintingStyle? style,
}) : super(
symbol, name, 3, 2, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style);
final T1 expected1;
final T1? expected1;
final T2 expected2;
final T2? expected2;
@override
void verifyArguments(List<dynamic> arguments) {
......@@ -1035,7 +1033,7 @@ class _TwoParameterPaintPredicate<T1, T2> extends _DrawCommandPaintPredicate {
}
class _RectPaintPredicate extends _OneParameterPaintPredicate<Rect> {
_RectPaintPredicate({ Rect rect, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style }) : super(
_RectPaintPredicate({ Rect? rect, Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style }) : super(
#drawRect,
'a rectangle',
expected: rect,
......@@ -1047,7 +1045,7 @@ class _RectPaintPredicate extends _OneParameterPaintPredicate<Rect> {
}
class _RRectPaintPredicate extends _DrawCommandPaintPredicate {
_RRectPaintPredicate({ this.rrect, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style }) : super(
_RRectPaintPredicate({ this.rrect, Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style }) : super(
#drawRRect,
'a rounded rectangle',
2,
......@@ -1058,7 +1056,7 @@ class _RRectPaintPredicate extends _DrawCommandPaintPredicate {
style: style,
);
final RRect rrect;
final RRect? rrect;
@override
void verifyArguments(List<dynamic> arguments) {
......@@ -1066,18 +1064,18 @@ class _RRectPaintPredicate extends _DrawCommandPaintPredicate {
const double eps = .0001;
final RRect actual = arguments[0] as RRect;
if (rrect != null &&
((actual.left - rrect.left).abs() > eps ||
(actual.right - rrect.right).abs() > eps ||
(actual.top - rrect.top).abs() > eps ||
(actual.bottom - rrect.bottom).abs() > eps ||
(actual.blRadiusX - rrect.blRadiusX).abs() > eps ||
(actual.blRadiusY - rrect.blRadiusY).abs() > eps ||
(actual.brRadiusX - rrect.brRadiusX).abs() > eps ||
(actual.brRadiusY - rrect.brRadiusY).abs() > eps ||
(actual.tlRadiusX - rrect.tlRadiusX).abs() > eps ||
(actual.tlRadiusY - rrect.tlRadiusY).abs() > eps ||
(actual.trRadiusX - rrect.trRadiusX).abs() > eps ||
(actual.trRadiusY - rrect.trRadiusY).abs() > eps)) {
((actual.left - rrect!.left).abs() > eps ||
(actual.right - rrect!.right).abs() > eps ||
(actual.top - rrect!.top).abs() > eps ||
(actual.bottom - rrect!.bottom).abs() > eps ||
(actual.blRadiusX - rrect!.blRadiusX).abs() > eps ||
(actual.blRadiusY - rrect!.blRadiusY).abs() > eps ||
(actual.brRadiusX - rrect!.brRadiusX).abs() > eps ||
(actual.brRadiusY - rrect!.brRadiusY).abs() > eps ||
(actual.tlRadiusX - rrect!.tlRadiusX).abs() > eps ||
(actual.tlRadiusY - rrect!.tlRadiusY).abs() > eps ||
(actual.trRadiusX - rrect!.trRadiusX).abs() > eps ||
(actual.trRadiusY - rrect!.trRadiusY).abs() > eps)) {
throw 'It called $methodName with RRect, $actual, which was not exactly the expected RRect ($rrect).';
}
}
......@@ -1092,7 +1090,7 @@ class _RRectPaintPredicate extends _DrawCommandPaintPredicate {
}
class _DRRectPaintPredicate extends _TwoParameterPaintPredicate<RRect, RRect> {
_DRRectPaintPredicate({ RRect inner, RRect outer, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style }) : super(
_DRRectPaintPredicate({ RRect? inner, RRect? outer, Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style }) : super(
#drawDRRect,
'a rounded rectangle outline',
expected1: outer,
......@@ -1105,69 +1103,69 @@ class _DRRectPaintPredicate extends _TwoParameterPaintPredicate<RRect, RRect> {
}
class _CirclePaintPredicate extends _DrawCommandPaintPredicate {
_CirclePaintPredicate({ this.x, this.y, this.radius, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style }) : super(
_CirclePaintPredicate({ this.x, this.y, this.radius, Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style }) : super(
#drawCircle, 'a circle', 3, 2, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style,
);
final double x;
final double y;
final double radius;
final double? x;
final double? y;
final double? radius;
@override
void verifyArguments(List<dynamic> arguments) {
super.verifyArguments(arguments);
final Offset pointArgument = arguments[0] as Offset;
if (x != null && y != null) {
final Offset point = Offset(x, y);
final Offset point = Offset(x!, y!);
if (point != pointArgument)
throw 'It called $methodName with a center coordinate, $pointArgument, which was not exactly the expected coordinate ($point).';
} else {
if (x != null && pointArgument.dx != x)
throw 'It called $methodName with a center coordinate, $pointArgument, whose x-coordinate not exactly the expected coordinate (${x.toStringAsFixed(1)}).';
throw 'It called $methodName with a center coordinate, $pointArgument, whose x-coordinate not exactly the expected coordinate (${x!.toStringAsFixed(1)}).';
if (y != null && pointArgument.dy != y)
throw 'It called $methodName with a center coordinate, $pointArgument, whose y-coordinate not exactly the expected coordinate (${y.toStringAsFixed(1)}).';
throw 'It called $methodName with a center coordinate, $pointArgument, whose y-coordinate not exactly the expected coordinate (${y!.toStringAsFixed(1)}).';
}
final double radiusArgument = arguments[1] as double;
if (radius != null && radiusArgument != radius)
throw 'It called $methodName with radius, ${radiusArgument.toStringAsFixed(1)}, which was not exactly the expected radius (${radius.toStringAsFixed(1)}).';
throw 'It called $methodName with radius, ${radiusArgument.toStringAsFixed(1)}, which was not exactly the expected radius (${radius!.toStringAsFixed(1)}).';
}
@override
void debugFillDescription(List<String> description) {
super.debugFillDescription(description);
if (x != null && y != null) {
description.add('point ${Offset(x, y)}');
description.add('point ${Offset(x!, y!)}');
} else {
if (x != null)
description.add('x-coordinate ${x.toStringAsFixed(1)}');
description.add('x-coordinate ${x!.toStringAsFixed(1)}');
if (y != null)
description.add('y-coordinate ${y.toStringAsFixed(1)}');
description.add('y-coordinate ${y!.toStringAsFixed(1)}');
}
if (radius != null)
description.add('radius ${radius.toStringAsFixed(1)}');
description.add('radius ${radius!.toStringAsFixed(1)}');
}
}
class _PathPaintPredicate extends _DrawCommandPaintPredicate {
_PathPaintPredicate({ this.includes, this.excludes, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style }) : super(
_PathPaintPredicate({ this.includes, this.excludes, Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style }) : super(
#drawPath, 'a path', 2, 1, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style,
);
final Iterable<Offset> includes;
final Iterable<Offset> excludes;
final Iterable<Offset>? includes;
final Iterable<Offset>? excludes;
@override
void verifyArguments(List<dynamic> arguments) {
super.verifyArguments(arguments);
final Path pathArgument = arguments[0] as Path;
if (includes != null) {
for (final Offset offset in includes) {
for (final Offset offset in includes!) {
if (!pathArgument.contains(offset))
throw 'It called $methodName with a path that unexpectedly did not contain $offset.';
}
}
if (excludes != null) {
for (final Offset offset in excludes) {
for (final Offset offset in excludes!) {
if (pathArgument.contains(offset))
throw 'It called $methodName with a path that unexpectedly contained $offset.';
}
......@@ -1189,12 +1187,12 @@ class _PathPaintPredicate extends _DrawCommandPaintPredicate {
// TODO(ianh): add arguments to test the length, angle, that kind of thing
class _LinePaintPredicate extends _DrawCommandPaintPredicate {
_LinePaintPredicate({ this.p1, this.p2, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style }) : super(
_LinePaintPredicate({ this.p1, this.p2, Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style }) : super(
#drawLine, 'a line', 3, 2, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style,
);
final Offset p1;
final Offset p2;
final Offset? p1;
final Offset? p2;
@override
void verifyArguments(List<dynamic> arguments) {
......@@ -1222,7 +1220,7 @@ class _LinePaintPredicate extends _DrawCommandPaintPredicate {
}
class _ArcPaintPredicate extends _DrawCommandPaintPredicate {
_ArcPaintPredicate({ Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style }) : super(
_ArcPaintPredicate({ Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style }) : super(
#drawArc, 'an arc', 5, 4, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style,
);
}
......@@ -1230,11 +1228,11 @@ class _ArcPaintPredicate extends _DrawCommandPaintPredicate {
class _ShadowPredicate extends _PaintPredicate {
_ShadowPredicate({ this.includes, this.excludes, this.color, this.elevation, this.transparentOccluder });
final Iterable<Offset> includes;
final Iterable<Offset> excludes;
final Color color;
final double elevation;
final bool transparentOccluder;
final Iterable<Offset>? includes;
final Iterable<Offset>? excludes;
final Color? color;
final double? elevation;
final bool? transparentOccluder;
static const Symbol symbol = #drawShadow;
String get methodName => _symbolName(symbol);
......@@ -1245,13 +1243,13 @@ class _ShadowPredicate extends _PaintPredicate {
throw 'It called $methodName with ${arguments.length} arguments; expected 4.';
final Path pathArgument = arguments[0] as Path;
if (includes != null) {
for (final Offset offset in includes) {
for (final Offset offset in includes!) {
if (!pathArgument.contains(offset))
throw 'It called $methodName with a path that unexpectedly did not contain $offset.';
}
}
if (excludes != null) {
for (final Offset offset in excludes) {
for (final Offset offset in excludes!) {
if (pathArgument.contains(offset))
throw 'It called $methodName with a path that unexpectedly contained $offset.';
}
......@@ -1303,13 +1301,13 @@ class _ShadowPredicate extends _PaintPredicate {
}
class _DrawImagePaintPredicate extends _DrawCommandPaintPredicate {
_DrawImagePaintPredicate({ this.image, this.x, this.y, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style }) : super(
_DrawImagePaintPredicate({ this.image, this.x, this.y, Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style }) : super(
#drawImage, 'an image', 3, 2, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style,
);
final ui.Image image;
final double x;
final double y;
final ui.Image? image;
final double? x;
final double? y;
@override
void verifyArguments(List<dynamic> arguments) {
......@@ -1319,14 +1317,14 @@ class _DrawImagePaintPredicate extends _DrawCommandPaintPredicate {
throw 'It called $methodName with an image, $imageArgument, which was not exactly the expected image ($image).';
final Offset pointArgument = arguments[0] as Offset;
if (x != null && y != null) {
final Offset point = Offset(x, y);
final Offset point = Offset(x!, y!);
if (point != pointArgument)
throw 'It called $methodName with an offset coordinate, $pointArgument, which was not exactly the expected coordinate ($point).';
} else {
if (x != null && pointArgument.dx != x)
throw 'It called $methodName with an offset coordinate, $pointArgument, whose x-coordinate not exactly the expected coordinate (${x.toStringAsFixed(1)}).';
throw 'It called $methodName with an offset coordinate, $pointArgument, whose x-coordinate not exactly the expected coordinate (${x!.toStringAsFixed(1)}).';
if (y != null && pointArgument.dy != y)
throw 'It called $methodName with an offset coordinate, $pointArgument, whose y-coordinate not exactly the expected coordinate (${y.toStringAsFixed(1)}).';
throw 'It called $methodName with an offset coordinate, $pointArgument, whose y-coordinate not exactly the expected coordinate (${y!.toStringAsFixed(1)}).';
}
}
......@@ -1336,24 +1334,24 @@ class _DrawImagePaintPredicate extends _DrawCommandPaintPredicate {
if (image != null)
description.add('image $image');
if (x != null && y != null) {
description.add('point ${Offset(x, y)}');
description.add('point ${Offset(x!, y!)}');
} else {
if (x != null)
description.add('x-coordinate ${x.toStringAsFixed(1)}');
description.add('x-coordinate ${x!.toStringAsFixed(1)}');
if (y != null)
description.add('y-coordinate ${y.toStringAsFixed(1)}');
description.add('y-coordinate ${y!.toStringAsFixed(1)}');
}
}
}
class _DrawImageRectPaintPredicate extends _DrawCommandPaintPredicate {
_DrawImageRectPaintPredicate({ this.image, this.source, this.destination, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style }) : super(
_DrawImageRectPaintPredicate({ this.image, this.source, this.destination, Color? color, double? strokeWidth, bool? hasMaskFilter, PaintingStyle? style }) : super(
#drawImageRect, 'an image', 4, 3, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style,
);
final ui.Image image;
final Rect source;
final Rect destination;
final ui.Image? image;
final Rect? source;
final Rect? destination;
@override
void verifyArguments(List<dynamic> arguments) {
......@@ -1500,7 +1498,7 @@ class _SaveRestorePairPaintPredicate extends _PaintPredicate {
String toString() => 'a matching save/restore pair';
}
String _valueName(Object value) {
String _valueName(Object? value) {
if (value is double)
return value.toStringAsFixed(1);
return value.toString();
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' as ui;
import 'package:flutter/cupertino.dart';
......@@ -20,7 +18,7 @@ class _TestHitTester extends RenderBox {
final BoxHitTest hitTestOverride;
@override
bool hitTest(BoxHitTestResult result, {ui.Offset position}) {
bool hitTest(BoxHitTestResult result, {required ui.Offset position}) {
return hitTestOverride(result, position);
}
}
......@@ -39,7 +37,7 @@ class TestMouseTrackerFlutterBinding extends BindingBase
renderView.child = _TestHitTester(hitTest);
}
SchedulerPhase _overridePhase;
SchedulerPhase? _overridePhase;
@override
SchedulerPhase get schedulerPhase => _overridePhase ?? super.schedulerPhase;
......@@ -48,7 +46,7 @@ class TestMouseTrackerFlutterBinding extends BindingBase
// In real apps this is done by the renderer binding, but in tests we have to
// bypass the phase assertion of [MouseTracker.schedulePostFrameCheck].
void scheduleMouseTrackerPostFrameCheck() {
final SchedulerPhase lastPhase = _overridePhase;
final SchedulerPhase? lastPhase = _overridePhase;
_overridePhase = SchedulerPhase.persistentCallbacks;
addPostFrameCallback((_) {
mouseTracker.updateAllDevices(renderView.hitTestMouseTrackers);
......@@ -77,13 +75,13 @@ class TestAnnotationTarget with Diagnosticable implements MouseTrackerAnnotation
const TestAnnotationTarget({this.onEnter, this.onHover, this.onExit, this.cursor = MouseCursor.defer});
@override
final PointerEnterEventListener onEnter;
final PointerEnterEventListener? onEnter;
@override
final PointerHoverEventListener onHover;
final PointerHoverEventListener? onHover;
@override
final PointerExitEventListener onExit;
final PointerExitEventListener? onExit;
@override
final MouseCursor cursor;
......@@ -92,14 +90,14 @@ class TestAnnotationTarget with Diagnosticable implements MouseTrackerAnnotation
void handleEvent(PointerEvent event, HitTestEntry entry) {
if (event is PointerHoverEvent)
if (onHover != null)
onHover(event);
onHover!(event);
}
}
// A hit test entry that can be assigned with a [TestAnnotationTarget] and an
// optional transform matrix.
class TestAnnotationEntry extends HitTestEntry {
TestAnnotationEntry(TestAnnotationTarget target, [Matrix4 transform])
TestAnnotationEntry(TestAnnotationTarget target, [Matrix4? transform])
: transform = transform ?? Matrix4.identity(), super(target);
@override
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/src/rendering/layer.dart';
......@@ -13,7 +11,7 @@ import 'package:flutter/src/rendering/layer.dart';
/// Used by [TestRecordingCanvas] to trace canvas calls.
class RecordedInvocation {
/// Create a record for an invocation list.
const RecordedInvocation(this.invocation, { this.stack });
const RecordedInvocation(this.invocation, { required this.stack });
/// The method that was called and its arguments.
///
......@@ -74,7 +72,7 @@ class TestRecordingCanvas implements Canvas {
}
@override
void saveLayer(Rect bounds, Paint paint) {
void saveLayer(Rect? bounds, Paint paint) {
_saveCount += 1;
invocations.add(RecordedInvocation(_MethodCall(#saveLayer, <dynamic>[bounds, paint]), stack: StackTrace.current));
}
......@@ -106,27 +104,27 @@ class TestRecordingPaintingContext extends ClipContext implements PaintingContex
}
@override
ClipRectLayer pushClipRect(
ClipRectLayer? pushClipRect(
bool needsCompositing,
Offset offset,
Rect clipRect,
PaintingContextCallback painter, {
Clip clipBehavior = Clip.hardEdge,
ClipRectLayer oldLayer,
ClipRectLayer? oldLayer,
}) {
clipRectAndPaint(clipRect.shift(offset), clipBehavior, clipRect.shift(offset), () => painter(this, offset));
return null;
}
@override
ClipRRectLayer pushClipRRect(
ClipRRectLayer? pushClipRRect(
bool needsCompositing,
Offset offset,
Rect bounds,
RRect clipRRect,
PaintingContextCallback painter, {
Clip clipBehavior = Clip.antiAlias,
ClipRRectLayer oldLayer,
ClipRRectLayer? oldLayer,
}) {
assert(clipBehavior != null);
clipRRectAndPaint(clipRRect.shift(offset), clipBehavior, bounds.shift(offset), () => painter(this, offset));
......@@ -134,26 +132,26 @@ class TestRecordingPaintingContext extends ClipContext implements PaintingContex
}
@override
ClipPathLayer pushClipPath(
ClipPathLayer? pushClipPath(
bool needsCompositing,
Offset offset,
Rect bounds,
Path clipPath,
PaintingContextCallback painter, {
Clip clipBehavior = Clip.antiAlias,
ClipPathLayer oldLayer,
ClipPathLayer? oldLayer,
}) {
clipPathAndPaint(clipPath.shift(offset), clipBehavior, bounds.shift(offset), () => painter(this, offset));
return null;
}
@override
TransformLayer pushTransform(
TransformLayer? pushTransform(
bool needsCompositing,
Offset offset,
Matrix4 transform,
PaintingContextCallback painter, {
TransformLayer oldLayer,
TransformLayer? oldLayer,
}) {
canvas.save();
canvas.transform(transform.storage);
......@@ -163,17 +161,25 @@ class TestRecordingPaintingContext extends ClipContext implements PaintingContex
}
@override
OpacityLayer pushOpacity(Offset offset, int alpha, PaintingContextCallback painter,
{ OpacityLayer oldLayer }) {
canvas.saveLayer(null, null); // TODO(ianh): Expose the alpha somewhere.
OpacityLayer pushOpacity(
Offset offset,
int alpha,
PaintingContextCallback painter, {
OpacityLayer? oldLayer,
}) {
canvas.saveLayer(null, Paint()); // TODO(ianh): Expose the alpha somewhere.
painter(this, offset);
canvas.restore();
return null;
return OpacityLayer();
}
@override
void pushLayer(Layer childLayer, PaintingContextCallback painter, Offset offset,
{ Rect childPaintBounds }) {
void pushLayer(
Layer childLayer,
PaintingContextCallback painter,
Offset offset, {
Rect? childPaintBounds,
}) {
painter(this, offset);
}
......@@ -204,7 +210,7 @@ class _MethodCall implements Invocation {
List<Type> get typeArguments => _typeArguments;
}
String _valueName(Object value) {
String _valueName(Object? value) {
if (value is double)
return value.toStringAsFixed(1);
return value.toString();
......@@ -228,7 +234,7 @@ String _describeInvocation(Invocation call) {
buffer.write('(');
buffer.writeAll(call.positionalArguments.map<String>(_valueName), ', ');
String separator = call.positionalArguments.isEmpty ? '' : ', ';
call.namedArguments.forEach((Symbol name, Object value) {
call.namedArguments.forEach((Symbol name, Object? value) {
buffer.write(separator);
buffer.write(_symbolName(name));
buffer.write(': ');
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:async';
import 'package:flutter/foundation.dart';
......@@ -29,7 +27,7 @@ class TestRenderingFlutterBinding extends BindingBase with SchedulerBinding, Ser
TestRenderingFlutterBinding({ this.onErrors }) {
FlutterError.onError = (FlutterErrorDetails details) {
FlutterError.dumpErrorToConsole(details);
Zone.current.parent.handleUncaughtError(details.exception, details.stack);
Zone.current.parent!.handleUncaughtError(details.exception as Object, details.stack!);
};
}
......@@ -40,14 +38,14 @@ class TestRenderingFlutterBinding extends BindingBase with SchedulerBinding, Ser
/// This function is expected to inspect these errors and decide whether they
/// are expected or not. Use [takeFlutterErrorDetails] to take one error at a
/// time, or [takeAllFlutterErrorDetails] to iterate over all errors.
VoidCallback onErrors;
VoidCallback? onErrors;
/// Returns the error least recently caught by [FlutterError] and removes it
/// from the list of captured errors.
///
/// Returns null if no errors were captures, or if the list was exhausted by
/// calling this method repeatedly.
FlutterErrorDetails takeFlutterErrorDetails() {
FlutterErrorDetails? takeFlutterErrorDetails() {
if (_errors.isEmpty) {
return null;
}
......@@ -87,7 +85,7 @@ class TestRenderingFlutterBinding extends BindingBase with SchedulerBinding, Ser
@override
void drawFrame() {
assert(phase != EnginePhase.build, 'rendering_tester does not support testing the build phase; use flutter_test instead');
final FlutterExceptionHandler oldErrorHandler = FlutterError.onError;
final FlutterExceptionHandler? oldErrorHandler = FlutterError.onError;
FlutterError.onError = (FlutterErrorDetails details) {
_errors.add(details);
};
......@@ -113,7 +111,7 @@ class TestRenderingFlutterBinding extends BindingBase with SchedulerBinding, Ser
FlutterError.onError = oldErrorHandler;
if (_errors.isNotEmpty) {
if (onErrors != null) {
onErrors();
onErrors!();
if (_errors.isNotEmpty) {
_errors.forEach(FlutterError.dumpErrorToConsole);
fail('There are more errors than the test inspected using TestRenderingFlutterBinding.takeFlutterErrorDetails.');
......@@ -127,11 +125,9 @@ class TestRenderingFlutterBinding extends BindingBase with SchedulerBinding, Ser
}
}
TestRenderingFlutterBinding _renderer;
TestRenderingFlutterBinding get renderer {
_renderer ??= TestRenderingFlutterBinding();
return _renderer;
}
late final TestRenderingFlutterBinding _renderer = TestRenderingFlutterBinding();
TestRenderingFlutterBinding get renderer => _renderer;
/// Place the box in the render tree, at the given size and with the given
/// alignment on the screen.
......@@ -149,10 +145,10 @@ TestRenderingFlutterBinding get renderer {
/// If `onErrors` is not null, it is set as [TestRenderingFlutterBinding.onError].
void layout(
RenderBox box, {
BoxConstraints constraints,
BoxConstraints? constraints,
Alignment alignment = Alignment.center,
EnginePhase phase = EnginePhase.layout,
VoidCallback onErrors,
VoidCallback? onErrors,
}) {
assert(box != null); // If you want to just repump the last box, call pumpFrame().
assert(box.parent == null); // We stick the box in another, so you can't reuse it easily, sorry.
......@@ -175,7 +171,7 @@ void layout(
/// Pumps a single frame.
///
/// If `onErrors` is not null, it is set as [TestRenderingFlutterBinding.onError].
void pumpFrame({ EnginePhase phase = EnginePhase.layout, VoidCallback onErrors }) {
void pumpFrame({ EnginePhase phase = EnginePhase.layout, VoidCallback? onErrors }) {
assert(renderer != null);
assert(renderer.renderView != null);
assert(renderer.renderView.child != null); // call layout() first!
......@@ -189,7 +185,7 @@ void pumpFrame({ EnginePhase phase = EnginePhase.layout, VoidCallback onErrors }
}
class TestCallbackPainter extends CustomPainter {
const TestCallbackPainter({ this.onPaint });
const TestCallbackPainter({ required this.onPaint });
final VoidCallback onPaint;
......@@ -251,25 +247,25 @@ class FakeTickerProvider implements TickerProvider {
class FakeTicker implements Ticker {
@override
bool muted;
bool muted = false;
@override
void absorbTicker(Ticker originalTicker) { }
@override
String get debugLabel => null;
String? get debugLabel => null;
@override
bool get isActive => null;
bool get isActive => throw UnimplementedError();
@override
bool get isTicking => null;
bool get isTicking => throw UnimplementedError();
@override
bool get scheduled => null;
bool get scheduled => throw UnimplementedError();
@override
bool get shouldScheduleTick => null;
bool get shouldScheduleTick => throw UnimplementedError();
@override
void dispose() { }
......@@ -279,7 +275,7 @@ class FakeTicker implements Ticker {
@override
TickerFuture start() {
return null;
throw UnimplementedError();
}
@override
......@@ -301,7 +297,14 @@ class TestClipPaintingContext extends PaintingContext {
TestClipPaintingContext() : super(ContainerLayer(), Rect.zero);
@override
ClipRectLayer pushClipRect(bool needsCompositing, Offset offset, Rect clipRect, PaintingContextCallback painter, {Clip clipBehavior = Clip.hardEdge, ClipRectLayer oldLayer}) {
ClipRectLayer? pushClipRect(
bool needsCompositing,
Offset offset,
Rect clipRect,
PaintingContextCallback painter, {
Clip clipBehavior = Clip.hardEdge,
ClipRectLayer? oldLayer,
}) {
this.clipBehavior = clipBehavior;
return null;
}
......@@ -310,7 +313,7 @@ class TestClipPaintingContext extends PaintingContext {
}
void expectOverflowedErrors() {
final FlutterErrorDetails errorDetails = renderer.takeFlutterErrorDetails();
final FlutterErrorDetails errorDetails = renderer.takeFlutterErrorDetails()!;
final bool overflowed = errorDetails.toString().contains('overflowed');
if (!overflowed) {
FlutterError.reportError(errorDetails);
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:typed_data';
import 'package:flutter/services.dart';
......@@ -53,15 +51,15 @@ class MockRestorationManager extends TestRestorationManager {
int rootBucketAccessed = 0;
@override
Future<RestorationBucket> get rootBucket {
Future<RestorationBucket?> get rootBucket {
rootBucketAccessed++;
return _rootBucket;
}
Future<RestorationBucket> _rootBucket;
set rootBucket(Future<RestorationBucket> value) {
late Future<RestorationBucket?> _rootBucket;
set rootBucket(Future<RestorationBucket?> value) {
_rootBucket = value;
_isRestoring = true;
ServicesBinding.instance.addPostFrameCallback((Duration _) {
ServicesBinding.instance!.addPostFrameCallback((Duration _) {
_isRestoring = false;
});
notifyListeners();
......@@ -69,7 +67,7 @@ class MockRestorationManager extends TestRestorationManager {
@override
bool get isReplacing => _isRestoring;
bool _isRestoring;
bool _isRestoring = false;
@override
Future<void> sendToEngine(Uint8List encodedData) {
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart';
......@@ -13,7 +11,7 @@ RenderEditable findRenderEditable(WidgetTester tester) {
final RenderObject root = tester.renderObject(find.byType(EditableText));
expect(root, isNotNull);
RenderEditable renderEditable;
late RenderEditable renderEditable;
void recursiveFinder(RenderObject child) {
if (child is RenderEditable) {
renderEditable = child;
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/gestures.dart';
import 'package:flutter_test/flutter_test.dart';
......
......@@ -2,49 +2,47 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/material.dart';
typedef OnObservation = void Function(Route<dynamic> route, Route<dynamic> previousRoute);
typedef OnObservation = void Function(Route<dynamic>? route, Route<dynamic>? previousRoute);
/// A trivial observer for testing the navigator.
class TestObserver extends NavigatorObserver {
OnObservation onPushed;
OnObservation onPopped;
OnObservation onRemoved;
OnObservation onReplaced;
OnObservation onStartUserGesture;
OnObservation? onPushed;
OnObservation? onPopped;
OnObservation? onRemoved;
OnObservation? onReplaced;
OnObservation? onStartUserGesture;
@override
void didPush(Route<dynamic> route, Route<dynamic> previousRoute) {
void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {
if (onPushed != null) {
onPushed(route, previousRoute);
onPushed!(route, previousRoute);
}
}
@override
void didPop(Route<dynamic> route, Route<dynamic> previousRoute) {
void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) {
if (onPopped != null) {
onPopped(route, previousRoute);
onPopped!(route, previousRoute);
}
}
@override
void didRemove(Route<dynamic> route, Route<dynamic> previousRoute) {
void didRemove(Route<dynamic> route, Route<dynamic>? previousRoute) {
if (onRemoved != null)
onRemoved(route, previousRoute);
onRemoved!(route, previousRoute);
}
@override
void didReplace({ Route<dynamic> oldRoute, Route<dynamic> newRoute }) {
void didReplace({ Route<dynamic>? oldRoute, Route<dynamic>? newRoute }) {
if (onReplaced != null)
onReplaced(newRoute, oldRoute);
onReplaced!(newRoute, oldRoute);
}
@override
void didStartUserGesture(Route<dynamic> route, Route<dynamic> previousRoute) {
void didStartUserGesture(Route<dynamic> route, Route<dynamic>? previousRoute) {
if (onStartUserGesture != null)
onStartUserGesture(route, previousRoute);
onStartUserGesture!(route, previousRoute);
}
}
......@@ -2,24 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
export '../services/restoration.dart';
class BucketSpy extends StatefulWidget {
const BucketSpy({Key key, this.child}) : super(key: key);
const BucketSpy({Key? key, this.child}) : super(key: key);
final Widget child;
final Widget? child;
@override
State<BucketSpy> createState() => BucketSpyState();
}
class BucketSpyState extends State<BucketSpy> {
RestorationBucket bucket;
RestorationBucket? bucket;
@override
void didChangeDependencies() {
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/foundation.dart';
......@@ -54,7 +52,7 @@ class TestSemantics {
this.children = const <TestSemantics>[],
this.scrollIndex,
this.scrollChildren,
Iterable<SemanticsTag> tags,
Iterable<SemanticsTag>? tags,
}) : assert(flags is int || flags is List<SemanticsFlag>),
assert(actions is int || actions is List<SemanticsAction>),
assert(label != null),
......@@ -81,7 +79,7 @@ class TestSemantics {
this.children = const <TestSemantics>[],
this.scrollIndex,
this.scrollChildren,
Iterable<SemanticsTag> tags,
Iterable<SemanticsTag>? tags,
}) : id = 0,
assert(flags is int || flags is List<SemanticsFlag>),
assert(actions is int || actions is List<SemanticsAction>),
......@@ -116,14 +114,14 @@ class TestSemantics {
this.decreasedValue = '',
this.textDirection,
this.rect,
Matrix4 transform,
Matrix4? transform,
this.elevation,
this.thickness,
this.textSelection,
this.children = const <TestSemantics>[],
this.scrollIndex,
this.scrollChildren,
Iterable<SemanticsTag> tags,
Iterable<SemanticsTag>? tags,
}) : assert(flags is int || flags is List<SemanticsFlag>),
assert(actions is int || actions is List<SemanticsAction>),
assert(label != null),
......@@ -139,7 +137,7 @@ class TestSemantics {
///
/// The root node has an id of zero. Other nodes are given a unique id when
/// they are created.
final int id;
final int? id;
/// The [SemanticsFlag]s set on this node.
///
......@@ -183,7 +181,7 @@ class TestSemantics {
/// Even if this is not set, the [hasSemantics] matcher will verify that if a
/// label is present on the [SemanticsNode], a [SemanticsNode.textDirection]
/// is also set.
final TextDirection textDirection;
final TextDirection? textDirection;
/// The bounding box for this node in its coordinate system.
///
......@@ -194,7 +192,7 @@ class TestSemantics {
///
/// * [TestSemantics.fullScreen] 800x600, the test screen's size in logical
/// pixels, useful for other full-screen widgets.
final Rect rect;
final Rect? rect;
/// The test screen's size in physical pixels, typically used as the [rect]
/// for the node with id zero.
......@@ -214,7 +212,7 @@ class TestSemantics {
/// By default, the transform is null, which represents the identity
/// transformation (i.e., that this node has the same coordinate system as its
/// parent).
final Matrix4 transform;
final Matrix4? transform;
/// The elevation of this node relative to the parent node.
///
......@@ -222,24 +220,24 @@ class TestSemantics {
///
/// * [SemanticsConfiguration.elevation] for a detailed discussion regarding
/// elevation and semantics.
final double elevation;
final double? elevation;
/// The extend that this node occupies in z-direction starting at [elevation].
///
/// See also:
///
/// * [SemanticsConfiguration.thickness] for a more detailed definition.
final double thickness;
final double? thickness;
/// The index of the first visible semantic node within a scrollable.
final int scrollIndex;
final int? scrollIndex;
/// The total number of semantic nodes within a scrollable.
final int scrollChildren;
final int? scrollChildren;
final TextSelection textSelection;
final TextSelection? textSelection;
static Matrix4 _applyRootChildScale(Matrix4 transform) {
static Matrix4 _applyRootChildScale(Matrix4? transform) {
final Matrix4 result = Matrix4.diagonal3Values(3.0, 3.0, 1.0);
if (transform != null)
result.multiply(transform);
......@@ -253,7 +251,7 @@ class TestSemantics {
final Set<SemanticsTag> tags;
bool _matches(
SemanticsNode node,
SemanticsNode? node,
Map<dynamic, dynamic> matchState, {
bool ignoreRect = false,
bool ignoreTransform = false,
......@@ -370,7 +368,7 @@ class TestSemantics {
if (textDirection != null)
buf.writeln('$indent textDirection: $textDirection,');
if (textSelection?.isValid == true)
buf.writeln('$indent textSelection:\n[${textSelection.start}, ${textSelection.end}],');
buf.writeln('$indent textSelection:\n[${textSelection!.start}, ${textSelection!.end}],');
if (scrollIndex != null)
buf.writeln('$indent scrollIndex: $scrollIndex,');
if (rect != null)
......@@ -413,7 +411,7 @@ class SemanticsTester {
/// The widget tester that this object is testing the semantics of.
final WidgetTester tester;
SemanticsHandle _semanticsHandle;
SemanticsHandle? _semanticsHandle;
/// Release resources held by this semantics tester.
///
......@@ -437,18 +435,18 @@ class SemanticsTester {
///
/// If `ancestor` is not null, only the descendants of it are returned.
Iterable<SemanticsNode> nodesWith({
String label,
String value,
String hint,
TextDirection textDirection,
List<SemanticsAction> actions,
List<SemanticsFlag> flags,
double scrollPosition,
double scrollExtentMax,
double scrollExtentMin,
int currentValueLength,
int maxValueLength,
SemanticsNode ancestor,
String? label,
String? value,
String? hint,
TextDirection? textDirection,
List<SemanticsAction>? actions,
List<SemanticsFlag>? flags,
double? scrollPosition,
double? scrollExtentMax,
double? scrollExtentMin,
int? currentValueLength,
int? maxValueLength,
SemanticsNode? ancestor,
}) {
bool checkNode(SemanticsNode node) {
if (label != null && node.label != label)
......@@ -497,7 +495,7 @@ class SemanticsTester {
if (ancestor != null) {
visit(ancestor);
} else {
visit(tester.binding.pipelineOwner.semanticsOwner.rootSemanticsNode);
visit(tester.binding.pipelineOwner.semanticsOwner!.rootSemanticsNode!);
}
return result;
}
......@@ -551,7 +549,7 @@ class SemanticsTester {
/// over-test. Prefer breaking your widgets into smaller widgets and test them
/// individually.
String generateTestSemanticsExpressionForCurrentSemanticsTree(DebugSemanticsDumpOrder childOrder) {
final SemanticsNode node = tester.binding.pipelineOwner.semanticsOwner?.rootSemanticsNode;
final SemanticsNode? node = tester.binding.pipelineOwner.semanticsOwner?.rootSemanticsNode;
return _generateSemanticsTestForNode(node, 0, childOrder);
}
......@@ -583,7 +581,7 @@ class SemanticsTester {
/// Recursively generates [TestSemantics] code for [node] and its children,
/// indenting the expression by `indentAmount`.
static String _generateSemanticsTestForNode(SemanticsNode node, int indentAmount, DebugSemanticsDumpOrder childOrder) {
static String _generateSemanticsTestForNode(SemanticsNode? node, int indentAmount, DebugSemanticsDumpOrder childOrder) {
if (node == null)
return 'null';
final String indent = ' ' * indentAmount;
......@@ -594,7 +592,7 @@ class SemanticsTester {
if (!isRoot)
buf.writeln(' id: ${node.id},');
if (nodeData.tags != null)
buf.writeln(' tags: ${_tagsToSemanticsTagExpression(nodeData.tags)},');
buf.writeln(' tags: ${_tagsToSemanticsTagExpression(nodeData.tags!)},');
if (nodeData.flags != 0)
buf.writeln(' flags: ${_flagsToSemanticsFlagExpression(nodeData.flags)},');
if (nodeData.actions != 0)
......@@ -635,10 +633,10 @@ class SemanticsTester {
class _HasSemantics extends Matcher {
const _HasSemantics(
this._semantics, {
@required this.ignoreRect,
@required this.ignoreTransform,
@required this.ignoreId,
@required this.childOrder,
required this.ignoreRect,
required this.ignoreTransform,
required this.ignoreId,
required this.childOrder,
}) : assert(_semantics != null),
assert(ignoreRect != null),
assert(ignoreId != null),
......@@ -675,7 +673,7 @@ class _HasSemantics extends Matcher {
return description.add('semantics node matching:\n$_semantics');
}
String _indent(String text) {
String _indent(String? text) {
return text.toString().trimRight().split('\n').map<String>((String line) => ' $line').join('\n');
}
......@@ -684,7 +682,7 @@ class _HasSemantics extends Matcher {
Description result = mismatchDescription
.add('${matchState[TestSemantics]}\n')
.add('Current SemanticsNode tree:\n')
.add(_indent(RendererBinding.instance?.renderView?.debugSemantics?.toStringDeep(childOrder: childOrder)))
.add(_indent(RendererBinding.instance?.renderView.debugSemantics?.toStringDeep(childOrder: childOrder)))
.add('\n')
.add('The semantics tree would have matched the following configuration:\n')
.add(_indent(matchState['would-match'] as String));
......@@ -739,17 +737,17 @@ class _IncludesNodeWith extends Matcher {
currentValueLength != null
);
final String label;
final String value;
final String hint;
final TextDirection textDirection;
final List<SemanticsAction> actions;
final List<SemanticsFlag> flags;
final double scrollPosition;
final double scrollExtentMax;
final double scrollExtentMin;
final int currentValueLength;
final int maxValueLength;
final String? label;
final String? value;
final String? hint;
final TextDirection? textDirection;
final List<SemanticsAction>? actions;
final List<SemanticsFlag>? flags;
final double? scrollPosition;
final double? scrollExtentMax;
final double? scrollExtentMin;
final int? currentValueLength;
final int? maxValueLength;
@override
bool matches(covariant SemanticsTester item, Map<dynamic, dynamic> matchState) {
......@@ -783,9 +781,9 @@ class _IncludesNodeWith extends Matcher {
if (label != null) 'label "$label"',
if (value != null) 'value "$value"',
if (hint != null) 'hint "$hint"',
if (textDirection != null) ' (${describeEnum(textDirection)})',
if (actions != null) 'actions "${actions.join(', ')}"',
if (flags != null) 'flags "${flags.join(', ')}"',
if (textDirection != null) ' (${describeEnum(textDirection!)})',
if (actions != null) 'actions "${actions!.join(', ')}"',
if (flags != null) 'flags "${flags!.join(', ')}"',
if (scrollPosition != null) 'scrollPosition "$scrollPosition"',
if (scrollExtentMax != null) 'scrollExtentMax "$scrollExtentMax"',
if (scrollExtentMin != null) 'scrollExtentMin "$scrollExtentMin"',
......@@ -801,17 +799,17 @@ class _IncludesNodeWith extends Matcher {
///
/// If null is provided for an argument, it will match against any value.
Matcher includesNodeWith({
String label,
String value,
String hint,
TextDirection textDirection,
List<SemanticsAction> actions,
List<SemanticsFlag> flags,
double scrollPosition,
double scrollExtentMax,
double scrollExtentMin,
int maxValueLength,
int currentValueLength,
String? label,
String? value,
String? hint,
TextDirection? textDirection,
List<SemanticsAction>? actions,
List<SemanticsFlag>? flags,
double? scrollPosition,
double? scrollExtentMax,
double? scrollExtentMin,
int? maxValueLength,
int? currentValueLength,
}) {
return _IncludesNodeWith(
label: label,
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
const List<String> kStates = <String>[
'Alabama',
'Alaska',
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/material.dart';
typedef Logger = void Function(String caller);
......@@ -20,19 +18,19 @@ class TestBorder extends ShapeBorder {
ShapeBorder scale(double t) => TestBorder(onLog);
@override
Path getInnerPath(Rect rect, { TextDirection textDirection }) {
Path getInnerPath(Rect rect, { TextDirection? textDirection }) {
onLog('getInnerPath $rect $textDirection');
return Path();
}
@override
Path getOuterPath(Rect rect, { TextDirection textDirection }) {
Path getOuterPath(Rect rect, { TextDirection? textDirection }) {
onLog('getOuterPath $rect $textDirection');
return Path();
}
@override
void paint(Canvas canvas, Rect rect, { TextDirection textDirection }) {
void paint(Canvas canvas, Rect rect, { TextDirection? textDirection }) {
onLog('paint $rect $textDirection');
}
}
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
......@@ -21,7 +19,7 @@ const BoxDecoration kBoxDecorationC = BoxDecoration(
);
class TestBuildCounter extends StatelessWidget {
const TestBuildCounter({ Key key }) : super(key: key);
const TestBuildCounter({ Key? key }) : super(key: key);
static int buildCount = 0;
......@@ -34,7 +32,7 @@ class TestBuildCounter extends StatelessWidget {
class FlipWidget extends StatefulWidget {
const FlipWidget({ Key key, this.left, this.right }) : super(key: key);
const FlipWidget({ Key? key, required this.left, required this.right }) : super(key: key);
final Widget left;
final Widget right;
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
......@@ -14,7 +12,7 @@ RenderEditable findRenderEditable(WidgetTester tester) {
final RenderObject root = tester.renderObject(find.byType(EditableText));
expect(root, isNotNull);
RenderEditable renderEditable;
late RenderEditable renderEditable;
void recursiveFinder(RenderObject child) {
if (child is RenderEditable) {
renderEditable = child;
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:async';
import 'dart:convert';
......@@ -12,48 +10,46 @@ import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
typedef InspectorServiceExtensionCallback = FutureOr<Map<String, Object>> Function(Map<String, String> parameters);
class TestWidgetInspectorService extends Object with WidgetInspectorService {
final Map<String, InspectorServiceExtensionCallback> extensions = <String, InspectorServiceExtensionCallback>{};
final Map<String, ServiceExtensionCallback> extensions = <String, ServiceExtensionCallback>{};
final Map<String, List<Map<Object, Object>>> eventsDispatched = <String, List<Map<Object, Object>>>{};
final Map<String, List<Map<Object, Object?>>> eventsDispatched = <String, List<Map<Object, Object?>>>{};
@override
void registerServiceExtension({
@required String name,
@required FutureOr<Map<String, Object>> callback(Map<String, String> parameters),
required String name,
required ServiceExtensionCallback callback,
}) {
assert(!extensions.containsKey(name));
extensions[name] = callback;
}
@override
void postEvent(String eventKind, Map<Object, Object> eventData) {
void postEvent(String eventKind, Map<Object, Object?> eventData) {
getEventsDispatched(eventKind).add(eventData);
}
List<Map<Object, Object>> getEventsDispatched(String eventKind) {
List<Map<Object, Object?>> getEventsDispatched(String eventKind) {
return eventsDispatched.putIfAbsent(eventKind, () => <Map<Object, Object>>[]);
}
Iterable<Map<Object, Object>> getServiceExtensionStateChangedEvents(String extensionName) {
Iterable<Map<Object, Object?>> getServiceExtensionStateChangedEvents(String extensionName) {
return getEventsDispatched('Flutter.ServiceExtensionStateChanged')
.where((Map<Object, Object> event) => event['extension'] == extensionName);
.where((Map<Object, Object?> event) => event['extension'] == extensionName);
}
Future<Object> testExtension(String name, Map<String, String> arguments) async {
Future<Object?> testExtension(String name, Map<String, String> arguments) async {
expect(extensions, contains(name));
// Encode and decode to JSON to match behavior using a real service
// extension where only JSON is allowed.
return json.decode(json.encode(await extensions[name](arguments)))['result'];
return json.decode(json.encode(await extensions[name]!(arguments)))['result'];
}
Future<String> testBoolExtension(String name, Map<String, String> arguments) async {
expect(extensions, contains(name));
// Encode and decode to JSON to match behavior using a real service
// extension where only JSON is allowed.
return json.decode(json.encode(await extensions[name](arguments)))['enabled'] as String;
return json.decode(json.encode(await extensions[name]!(arguments)))['enabled'] as String;
}
int rebuildCount = 0;
......@@ -61,10 +57,10 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
@override
Future<void> forceRebuild() async {
rebuildCount++;
final WidgetsBinding binding = WidgetsBinding.instance;
final WidgetsBinding binding = WidgetsBinding.instance!;
if (binding.renderViewElement != null) {
binding.buildOwner.reassemble(binding.renderViewElement);
binding.buildOwner!.reassemble(binding.renderViewElement!);
}
}
}
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