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

Migrate more tests to null safety (#67360)

parent 74c3ea4d
...@@ -2,7 +2,6 @@ ...@@ -2,7 +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.
import 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'dart:typed_data'; import 'dart:typed_data';
......
...@@ -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/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/painting.dart'; import 'package:flutter/painting.dart';
...@@ -23,26 +21,26 @@ void main() { ...@@ -23,26 +21,26 @@ void main() {
); );
test('FlutterLogoDecoration lerp from null to null is null', () { test('FlutterLogoDecoration lerp from null to null is null', () {
final FlutterLogoDecoration logo = FlutterLogoDecoration.lerp(null, null, 0.5); final FlutterLogoDecoration? logo = FlutterLogoDecoration.lerp(null, null, 0.5);
expect(logo, isNull); expect(logo, isNull);
}); });
test('FlutterLogoDecoration lerp from non-null to null lerps margin', () { test('FlutterLogoDecoration lerp from non-null to null lerps margin', () {
final FlutterLogoDecoration logo = FlutterLogoDecoration.lerp(start, null, 0.4); final FlutterLogoDecoration logo = FlutterLogoDecoration.lerp(start, null, 0.4)!;
expect(logo.textColor, start.textColor); expect(logo.textColor, start.textColor);
expect(logo.style, start.style); expect(logo.style, start.style);
expect(logo.margin, start.margin * 0.4); expect(logo.margin, start.margin * 0.4);
}); });
test('FlutterLogoDecoration lerp from null to non-null lerps margin', () { test('FlutterLogoDecoration lerp from null to non-null lerps margin', () {
final FlutterLogoDecoration logo = FlutterLogoDecoration.lerp(null, end, 0.6); final FlutterLogoDecoration logo = FlutterLogoDecoration.lerp(null, end, 0.6)!;
expect(logo.textColor, end.textColor); expect(logo.textColor, end.textColor);
expect(logo.style, end.style); expect(logo.style, end.style);
expect(logo.margin, end.margin * 0.6); expect(logo.margin, end.margin * 0.6);
}); });
test('FlutterLogoDecoration lerps colors and margins', () { test('FlutterLogoDecoration lerps colors and margins', () {
final FlutterLogoDecoration logo = FlutterLogoDecoration.lerp(start, end, 0.5); final FlutterLogoDecoration logo = FlutterLogoDecoration.lerp(start, end, 0.5)!;
expect(logo.textColor, Color.lerp(start.textColor, end.textColor, 0.5)); expect(logo.textColor, Color.lerp(start.textColor, end.textColor, 0.5));
expect(logo.margin, EdgeInsets.lerp(start.margin, end.margin, 0.5)); expect(logo.margin, EdgeInsets.lerp(start.margin, end.margin, 0.5));
}); });
...@@ -55,10 +53,10 @@ void main() { ...@@ -55,10 +53,10 @@ void main() {
}); });
test('FlutterLogoDecoration lerp changes styles at 0.5', () { test('FlutterLogoDecoration lerp changes styles at 0.5', () {
FlutterLogoDecoration logo = FlutterLogoDecoration.lerp(start, end, 0.4); FlutterLogoDecoration logo = FlutterLogoDecoration.lerp(start, end, 0.4)!;
expect(logo.style, start.style); expect(logo.style, start.style);
logo = FlutterLogoDecoration.lerp(start, end, 0.5); logo = FlutterLogoDecoration.lerp(start, end, 0.5)!;
expect(logo.style, end.style); expect(logo.style, end.style);
}); });
......
...@@ -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/painting.dart'; import 'package:flutter/painting.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/painting.dart'; import 'package:flutter/painting.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:math' as math; import 'dart:math' as math;
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
...@@ -21,7 +19,7 @@ void main() { ...@@ -21,7 +19,7 @@ void main() {
Color(0x44444444), Color(0x44444444),
], ],
); );
final LinearGradient actual = LinearGradient.lerp(null, testGradient, 0.25); final LinearGradient? actual = LinearGradient.lerp(null, testGradient, 0.25);
expect(actual, const LinearGradient( expect(actual, const LinearGradient(
begin: Alignment.bottomRight, begin: Alignment.bottomRight,
...@@ -52,7 +50,7 @@ void main() { ...@@ -52,7 +50,7 @@ void main() {
], ],
); );
final LinearGradient actual = LinearGradient.lerp(testGradient1, testGradient2, 0.5); final LinearGradient? actual = LinearGradient.lerp(testGradient1, testGradient2, 0.5);
expect(actual, const LinearGradient( expect(actual, const LinearGradient(
begin: Alignment(0.0, -1.0), begin: Alignment(0.0, -1.0),
end: Alignment(-1.0, 0.0), end: Alignment(-1.0, 0.0),
...@@ -90,7 +88,7 @@ void main() { ...@@ -90,7 +88,7 @@ void main() {
], ],
); );
final LinearGradient actual = LinearGradient.lerp(testGradient1, testGradient2, 0.5); final LinearGradient? actual = LinearGradient.lerp(testGradient1, testGradient2, 0.5);
expect(actual, const LinearGradient( expect(actual, const LinearGradient(
begin: Alignment(0.0, -1.0), begin: Alignment(0.0, -1.0),
end: Alignment(-1.0, 0.0), end: Alignment(-1.0, 0.0),
...@@ -122,7 +120,7 @@ void main() { ...@@ -122,7 +120,7 @@ void main() {
], ],
); );
final LinearGradient actual = LinearGradient.lerp(testGradient1, testGradient2, 0.5); final LinearGradient? actual = LinearGradient.lerp(testGradient1, testGradient2, 0.5);
expect(actual, const LinearGradient( expect(actual, const LinearGradient(
colors: <Color>[ colors: <Color>[
Color(0x33333333), Color(0x33333333),
...@@ -161,7 +159,7 @@ void main() { ...@@ -161,7 +159,7 @@ void main() {
], ],
); );
final LinearGradient actual = LinearGradient.lerp(testGradient1, testGradient2, 0.5); final LinearGradient? actual = LinearGradient.lerp(testGradient1, testGradient2, 0.5);
expect(actual, const LinearGradient( expect(actual, const LinearGradient(
colors: <Color>[ colors: <Color>[
Color(0x3B3B3B3B), Color(0x3B3B3B3B),
...@@ -291,7 +289,7 @@ void main() { ...@@ -291,7 +289,7 @@ void main() {
], ],
); );
final RadialGradient actual = RadialGradient.lerp(testGradient1, testGradient2, 0.5); final RadialGradient? actual = RadialGradient.lerp(testGradient1, testGradient2, 0.5);
expect(actual, const RadialGradient( expect(actual, const RadialGradient(
center: Alignment(0.0, -1.0), center: Alignment(0.0, -1.0),
radius: 15.0, radius: 15.0,
...@@ -332,9 +330,7 @@ void main() { ...@@ -332,9 +330,7 @@ void main() {
], ],
); );
final RadialGradient actual = RadialGradient.lerp(testGradient1, testGradient2, 0.5); final RadialGradient? actual = RadialGradient.lerp(testGradient1, testGradient2, 0.5);
expect(actual.focal, isNull);
expect(actual, const RadialGradient( expect(actual, const RadialGradient(
center: Alignment(0.0, -1.0), center: Alignment(0.0, -1.0),
...@@ -350,6 +346,8 @@ void main() { ...@@ -350,6 +346,8 @@ void main() {
1.0, 1.0,
], ],
)); ));
expect(actual!.focal, isNull);
}); });
test('RadialGradient lerp test with unequal number of colors', () { test('RadialGradient lerp test with unequal number of colors', () {
...@@ -367,7 +365,7 @@ void main() { ...@@ -367,7 +365,7 @@ void main() {
], ],
); );
final RadialGradient actual = RadialGradient.lerp(testGradient1, testGradient2, 0.5); final RadialGradient? actual = RadialGradient.lerp(testGradient1, testGradient2, 0.5);
expect(actual, const RadialGradient( expect(actual, const RadialGradient(
colors: <Color>[ colors: <Color>[
Color(0x33333333), Color(0x33333333),
...@@ -406,7 +404,7 @@ void main() { ...@@ -406,7 +404,7 @@ void main() {
], ],
); );
final RadialGradient actual = RadialGradient.lerp(testGradient1, testGradient2, 0.5); final RadialGradient? actual = RadialGradient.lerp(testGradient1, testGradient2, 0.5);
expect(actual, const RadialGradient( expect(actual, const RadialGradient(
colors: <Color>[ colors: <Color>[
Color(0x3B3B3B3B), Color(0x3B3B3B3B),
...@@ -453,7 +451,7 @@ void main() { ...@@ -453,7 +451,7 @@ void main() {
], ],
); );
final RadialGradient actual = RadialGradient.lerp(testGradient1, testGradient2, 0.5); final RadialGradient? actual = RadialGradient.lerp(testGradient1, testGradient2, 0.5);
expect(actual, const RadialGradient( expect(actual, const RadialGradient(
center: Alignment(0.0, -1.0), center: Alignment(0.0, -1.0),
focal: Alignment(0.0, 0.0), focal: Alignment(0.0, 0.0),
...@@ -469,7 +467,7 @@ void main() { ...@@ -469,7 +467,7 @@ void main() {
], ],
)); ));
final RadialGradient actual2 = RadialGradient.lerp(testGradient1, testGradient3, 0.5); final RadialGradient? actual2 = RadialGradient.lerp(testGradient1, testGradient3, 0.5);
expect(actual2, const RadialGradient( expect(actual2, const RadialGradient(
center: Alignment(0.0, -1.0), center: Alignment(0.0, -1.0),
focal: Alignment(-0.5, 0.0), focal: Alignment(-0.5, 0.0),
...@@ -506,7 +504,7 @@ void main() { ...@@ -506,7 +504,7 @@ void main() {
], ],
); );
final SweepGradient actual = SweepGradient.lerp(testGradient1, testGradient2, 0.5); final SweepGradient? actual = SweepGradient.lerp(testGradient1, testGradient2, 0.5);
expect(actual, const SweepGradient( expect(actual, const SweepGradient(
center: Alignment(0.0, -1.0), center: Alignment(0.0, -1.0),
startAngle: math.pi / 4, startAngle: math.pi / 4,
...@@ -550,7 +548,7 @@ void main() { ...@@ -550,7 +548,7 @@ void main() {
], ],
); );
final SweepGradient actual = SweepGradient.lerp(testGradient1, testGradient2, 0.5); final SweepGradient? actual = SweepGradient.lerp(testGradient1, testGradient2, 0.5);
expect(actual, const SweepGradient( expect(actual, const SweepGradient(
center: Alignment(0.0, -1.0), center: Alignment(0.0, -1.0),
startAngle: math.pi / 4, startAngle: math.pi / 4,
...@@ -583,7 +581,7 @@ void main() { ...@@ -583,7 +581,7 @@ void main() {
], ],
); );
final SweepGradient actual = SweepGradient.lerp(testGradient1, testGradient2, 0.5); final SweepGradient? actual = SweepGradient.lerp(testGradient1, testGradient2, 0.5);
expect(actual, const SweepGradient( expect(actual, const SweepGradient(
colors: <Color>[ colors: <Color>[
Color(0x33333333), Color(0x33333333),
...@@ -622,7 +620,7 @@ void main() { ...@@ -622,7 +620,7 @@ void main() {
], ],
); );
final SweepGradient actual = SweepGradient.lerp(testGradient1, testGradient2, 0.5); final SweepGradient? actual = SweepGradient.lerp(testGradient1, testGradient2, 0.5);
expect(actual, const SweepGradient( expect(actual, const SweepGradient(
colors: <Color>[ colors: <Color>[
Color(0x3B3B3B3B), Color(0x3B3B3B3B),
......
...@@ -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';
...@@ -13,7 +11,6 @@ import 'package:flutter/services.dart'; ...@@ -13,7 +11,6 @@ import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
void main() { void main() {
test('PaintingBinding with memory pressure before initInstances', () { test('PaintingBinding with memory pressure before initInstances', () {
// Observed in devicelab: the device sends a memory pressure event to us // Observed in devicelab: the device sends a memory pressure event to us
...@@ -25,7 +22,7 @@ void main() { ...@@ -25,7 +22,7 @@ void main() {
expect(binding.imageCache, null); expect(binding.imageCache, null);
binding.initInstances(); binding.initInstances();
expect(binding.imageCache, isNotNull); expect(binding.imageCache, isNotNull);
expect(binding.imageCache.currentSize, 0); expect(binding.imageCache!.currentSize, 0);
}); });
} }
...@@ -56,19 +53,19 @@ class TestBindingBase implements BindingBase { ...@@ -56,19 +53,19 @@ class TestBindingBase implements BindingBase {
} }
@override @override
void registerBoolServiceExtension({String name, AsyncValueGetter<bool> getter, AsyncValueSetter<bool> setter}) {} void registerBoolServiceExtension({required String name, required AsyncValueGetter<bool> getter, required AsyncValueSetter<bool> setter}) {}
@override @override
void registerNumericServiceExtension({String name, AsyncValueGetter<double> getter, AsyncValueSetter<double> setter}) {} void registerNumericServiceExtension({required String name, required AsyncValueGetter<double> getter, required AsyncValueSetter<double> setter}) {}
@override @override
void registerServiceExtension({String name, ServiceExtensionCallback callback}) {} void registerServiceExtension({required String name, required ServiceExtensionCallback callback}) {}
@override @override
void registerSignalServiceExtension({String name, AsyncCallback callback}) {} void registerSignalServiceExtension({required String name, required AsyncCallback callback}) {}
@override @override
void registerStringServiceExtension({String name, AsyncValueGetter<String> getter, AsyncValueSetter<String> setter}) {} void registerStringServiceExtension({required String name, required AsyncValueGetter<String> getter, required AsyncValueSetter<String> setter}) {}
@override @override
void unlocked() {} void unlocked() {}
......
...@@ -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 'dart:typed_data'; import 'dart:typed_data';
...@@ -27,7 +25,7 @@ void main() { ...@@ -27,7 +25,7 @@ void main() {
completer.complete(); completer.complete();
} }
)); ));
imageCache.clearLiveImages(); imageCache!.clearLiveImages();
await completer.future; await completer.future;
}); });
} }
...@@ -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/painting.dart'; import 'package:flutter/painting.dart';
...@@ -16,13 +14,14 @@ void main() { ...@@ -16,13 +14,14 @@ void main() {
TestRenderingFlutterBinding(); TestRenderingFlutterBinding();
tearDown(() { tearDown(() {
imageCache.clear(); imageCache!
imageCache.maximumSize = 1000; ..clear()
imageCache.maximumSizeBytes = 10485760; ..maximumSize = 1000
..maximumSizeBytes = 10485760;
}); });
test('Image cache resizing based on count', () async { test('Image cache resizing based on count', () async {
imageCache.maximumSize = 2; imageCache!.maximumSize = 2;
final TestImageInfo a = await extractOneFrame(TestImageProvider(1, 1, image: await createTestImage()).resolve(ImageConfiguration.empty)) as TestImageInfo; final TestImageInfo a = await extractOneFrame(TestImageProvider(1, 1, image: await createTestImage()).resolve(ImageConfiguration.empty)) as TestImageInfo;
final TestImageInfo b = await extractOneFrame(TestImageProvider(2, 2, image: await createTestImage()).resolve(ImageConfiguration.empty)) as TestImageInfo; final TestImageInfo b = await extractOneFrame(TestImageProvider(2, 2, image: await createTestImage()).resolve(ImageConfiguration.empty)) as TestImageInfo;
...@@ -33,7 +32,7 @@ void main() { ...@@ -33,7 +32,7 @@ void main() {
expect(c.value, equals(3)); expect(c.value, equals(3));
expect(d.value, equals(4)); expect(d.value, equals(4));
imageCache.maximumSize = 0; imageCache!.maximumSize = 0;
final TestImageInfo e = await extractOneFrame(TestImageProvider(1, 5, image: await createTestImage()).resolve(ImageConfiguration.empty)) as TestImageInfo; final TestImageInfo e = await extractOneFrame(TestImageProvider(1, 5, image: await createTestImage()).resolve(ImageConfiguration.empty)) as TestImageInfo;
expect(e.value, equals(5)); expect(e.value, equals(5));
...@@ -41,7 +40,7 @@ void main() { ...@@ -41,7 +40,7 @@ void main() {
final TestImageInfo f = await extractOneFrame(TestImageProvider(1, 6, image: await createTestImage()).resolve(ImageConfiguration.empty)) as TestImageInfo; final TestImageInfo f = await extractOneFrame(TestImageProvider(1, 6, image: await createTestImage()).resolve(ImageConfiguration.empty)) as TestImageInfo;
expect(f.value, equals(6)); expect(f.value, equals(6));
imageCache.maximumSize = 3; imageCache!.maximumSize = 3;
final TestImageInfo g = await extractOneFrame(TestImageProvider(1, 7, image: await createTestImage()).resolve(ImageConfiguration.empty)) as TestImageInfo; final TestImageInfo g = await extractOneFrame(TestImageProvider(1, 7, image: await createTestImage()).resolve(ImageConfiguration.empty)) as TestImageInfo;
expect(g.value, equals(7)); expect(g.value, equals(7));
...@@ -52,7 +51,7 @@ void main() { ...@@ -52,7 +51,7 @@ void main() {
test('Image cache resizing based on size', () async { test('Image cache resizing based on size', () async {
final ui.Image testImage = await createTestImage(width: 8, height: 8); // 256 B. final ui.Image testImage = await createTestImage(width: 8, height: 8); // 256 B.
imageCache.maximumSizeBytes = 256 * 2; imageCache!.maximumSizeBytes = 256 * 2;
final TestImageInfo a = await extractOneFrame(TestImageProvider(1, 1, image: testImage).resolve(ImageConfiguration.empty)) as TestImageInfo; final TestImageInfo a = await extractOneFrame(TestImageProvider(1, 1, image: testImage).resolve(ImageConfiguration.empty)) as TestImageInfo;
final TestImageInfo b = await extractOneFrame(TestImageProvider(2, 2, image: testImage).resolve(ImageConfiguration.empty)) as TestImageInfo; final TestImageInfo b = await extractOneFrame(TestImageProvider(2, 2, image: testImage).resolve(ImageConfiguration.empty)) as TestImageInfo;
...@@ -63,7 +62,7 @@ void main() { ...@@ -63,7 +62,7 @@ void main() {
expect(c.value, equals(3)); expect(c.value, equals(3));
expect(d.value, equals(4)); expect(d.value, equals(4));
imageCache.maximumSizeBytes = 0; imageCache!.maximumSizeBytes = 0;
final TestImageInfo e = await extractOneFrame(TestImageProvider(1, 5, image: testImage).resolve(ImageConfiguration.empty)) as TestImageInfo; final TestImageInfo e = await extractOneFrame(TestImageProvider(1, 5, image: testImage).resolve(ImageConfiguration.empty)) as TestImageInfo;
expect(e.value, equals(5)); expect(e.value, equals(5));
...@@ -71,7 +70,7 @@ void main() { ...@@ -71,7 +70,7 @@ void main() {
final TestImageInfo f = await extractOneFrame(TestImageProvider(1, 6, image: testImage).resolve(ImageConfiguration.empty)) as TestImageInfo; final TestImageInfo f = await extractOneFrame(TestImageProvider(1, 6, image: testImage).resolve(ImageConfiguration.empty)) as TestImageInfo;
expect(f.value, equals(6)); expect(f.value, equals(6));
imageCache.maximumSizeBytes = 256 * 3; imageCache!.maximumSizeBytes = 256 * 3;
final TestImageInfo g = await extractOneFrame(TestImageProvider(1, 7, image: testImage).resolve(ImageConfiguration.empty)) as TestImageInfo; final TestImageInfo g = await extractOneFrame(TestImageProvider(1, 7, image: testImage).resolve(ImageConfiguration.empty)) as TestImageInfo;
expect(g.value, equals(7)); expect(g.value, equals(7));
......
...@@ -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; import 'dart:ui' as ui;
......
...@@ -2,14 +2,11 @@ ...@@ -2,14 +2,11 @@
// 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 'dart:typed_data'; import 'dart:typed_data';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/painting.dart'; import 'package:flutter/painting.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import '../image_data.dart'; import '../image_data.dart';
...@@ -19,23 +16,23 @@ import 'mocks_for_image_cache.dart'; ...@@ -19,23 +16,23 @@ import 'mocks_for_image_cache.dart';
void main() { void main() {
TestRenderingFlutterBinding(); TestRenderingFlutterBinding();
final DecoderCallback _basicDecoder = (Uint8List bytes, {int cacheWidth, int cacheHeight, bool allowUpscaling}) { final DecoderCallback _basicDecoder = (Uint8List bytes, {int? cacheWidth, int? cacheHeight, bool? allowUpscaling}) {
return PaintingBinding.instance.instantiateImageCodec(bytes, cacheWidth: cacheWidth, cacheHeight: cacheHeight, allowUpscaling: allowUpscaling ?? false); return PaintingBinding.instance!.instantiateImageCodec(bytes, cacheWidth: cacheWidth, cacheHeight: cacheHeight, allowUpscaling: allowUpscaling ?? false);
}; };
FlutterExceptionHandler oldError; FlutterExceptionHandler? oldError;
setUp(() { setUp(() {
oldError = FlutterError.onError; oldError = FlutterError.onError;
}); });
tearDown(() { tearDown(() {
FlutterError.onError = oldError; FlutterError.onError = oldError;
PaintingBinding.instance.imageCache.clear(); PaintingBinding.instance!.imageCache!.clear();
PaintingBinding.instance.imageCache.clearLiveImages(); PaintingBinding.instance!.imageCache!.clearLiveImages();
}); });
tearDown(() { tearDown(() {
imageCache.clear(); imageCache!.clear();
}); });
test('AssetImageProvider - evicts on failure to load', () async { test('AssetImageProvider - evicts on failure to load', () async {
...@@ -46,42 +43,20 @@ void main() { ...@@ -46,42 +43,20 @@ void main() {
const ImageProvider provider = ExactAssetImage('does-not-exist'); const ImageProvider provider = ExactAssetImage('does-not-exist');
final Object key = await provider.obtainKey(ImageConfiguration.empty); final Object key = await provider.obtainKey(ImageConfiguration.empty);
expect(imageCache.statusForKey(provider).untracked, true); expect(imageCache!.statusForKey(provider).untracked, true);
expect(imageCache.pendingImageCount, 0); expect(imageCache!.pendingImageCount, 0);
provider.resolve(ImageConfiguration.empty); provider.resolve(ImageConfiguration.empty);
expect(imageCache.statusForKey(key).pending, true); expect(imageCache!.statusForKey(key).pending, true);
expect(imageCache.pendingImageCount, 1); expect(imageCache!.pendingImageCount, 1);
await error.future; await error.future;
expect(imageCache.statusForKey(provider).untracked, true); expect(imageCache!.statusForKey(provider).untracked, true);
expect(imageCache.pendingImageCount, 0); expect(imageCache!.pendingImageCount, 0);
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/56314 }, skip: isBrowser); // https://github.com/flutter/flutter/issues/56314
test('AssetImageProvider - evicts on null load', () async {
final Completer<StateError> error = Completer<StateError>();
FlutterError.onError = (FlutterErrorDetails details) {
error.complete(details.exception as StateError);
};
final ImageProvider provider = ExactAssetImage('does-not-exist', bundle: _TestAssetBundle());
final Object key = await provider.obtainKey(ImageConfiguration.empty);
expect(imageCache.statusForKey(provider).untracked, true);
expect(imageCache.pendingImageCount, 0);
provider.resolve(ImageConfiguration.empty);
expect(imageCache.statusForKey(key).pending, true);
expect(imageCache.pendingImageCount, 1);
await error.future;
expect(imageCache.statusForKey(provider).untracked, true);
expect(imageCache.pendingImageCount, 0);
});
test('ImageProvider can evict images', () async { test('ImageProvider can evict images', () async {
final Uint8List bytes = Uint8List.fromList(kTransparentImage); final Uint8List bytes = Uint8List.fromList(kTransparentImage);
final MemoryImage imageProvider = MemoryImage(bytes); final MemoryImage imageProvider = MemoryImage(bytes);
...@@ -90,9 +65,9 @@ void main() { ...@@ -90,9 +65,9 @@ void main() {
stream.addListener(ImageStreamListener((ImageInfo info, bool syncCall) => completer.complete())); stream.addListener(ImageStreamListener((ImageInfo info, bool syncCall) => completer.complete()));
await completer.future; await completer.future;
expect(imageCache.currentSize, 1); expect(imageCache!.currentSize, 1);
expect(await MemoryImage(bytes).evict(), true); expect(await MemoryImage(bytes).evict(), true);
expect(imageCache.currentSize, 0); expect(imageCache!.currentSize, 0);
}); });
test('ImageProvider.evict respects the provided ImageCache', () async { test('ImageProvider.evict respects the provided ImageCache', () async {
...@@ -101,7 +76,7 @@ void main() { ...@@ -101,7 +76,7 @@ void main() {
final MemoryImage imageProvider = MemoryImage(bytes); final MemoryImage imageProvider = MemoryImage(bytes);
final ImageStreamCompleter cacheStream = otherCache.putIfAbsent( final ImageStreamCompleter cacheStream = otherCache.putIfAbsent(
imageProvider, () => imageProvider.load(imageProvider, _basicDecoder), imageProvider, () => imageProvider.load(imageProvider, _basicDecoder),
); )!;
final ImageStream stream = imageProvider.resolve(ImageConfiguration.empty); final ImageStream stream = imageProvider.resolve(ImageConfiguration.empty);
final Completer<void> completer = Completer<void>(); final Completer<void> completer = Completer<void>();
final Completer<void> cacheCompleter = Completer<void>(); final Completer<void> cacheCompleter = Completer<void>();
...@@ -114,10 +89,10 @@ void main() { ...@@ -114,10 +89,10 @@ void main() {
await Future.wait(<Future<void>>[completer.future, cacheCompleter.future]); await Future.wait(<Future<void>>[completer.future, cacheCompleter.future]);
expect(otherCache.currentSize, 1); expect(otherCache.currentSize, 1);
expect(imageCache.currentSize, 1); expect(imageCache!.currentSize, 1);
expect(await imageProvider.evict(cache: otherCache), true); expect(await imageProvider.evict(cache: otherCache), true);
expect(otherCache.currentSize, 0); expect(otherCache.currentSize, 0);
expect(imageCache.currentSize, 1); expect(imageCache!.currentSize, 1);
}); });
test('ImageProvider errors can always be caught', () async { test('ImageProvider errors can always be caught', () async {
...@@ -129,16 +104,9 @@ void main() { ...@@ -129,16 +104,9 @@ void main() {
final ImageStream stream = imageProvider.resolve(ImageConfiguration.empty); final ImageStream stream = imageProvider.resolve(ImageConfiguration.empty);
stream.addListener(ImageStreamListener((ImageInfo info, bool syncCall) { stream.addListener(ImageStreamListener((ImageInfo info, bool syncCall) {
caughtError.complete(false); caughtError.complete(false);
}, onError: (dynamic error, StackTrace stackTrace) { }, onError: (dynamic error, StackTrace? stackTrace) {
caughtError.complete(true); caughtError.complete(true);
})); }));
expect(await caughtError.future, true); expect(await caughtError.future, true);
}); });
} }
class _TestAssetBundle extends CachingAssetBundle {
@override
Future<ByteData> load(String key) async {
return 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 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'dart:math' as math; import 'dart:math' as math;
...@@ -21,11 +19,11 @@ import '../rendering/rendering_tester.dart'; ...@@ -21,11 +19,11 @@ import '../rendering/rendering_tester.dart';
void main() { void main() {
TestRenderingFlutterBinding(); TestRenderingFlutterBinding();
final DecoderCallback _basicDecoder = (Uint8List bytes, {int cacheWidth, int cacheHeight, bool allowUpscaling}) { final DecoderCallback _basicDecoder = (Uint8List bytes, {int? cacheWidth, int? cacheHeight, bool? allowUpscaling}) {
return PaintingBinding.instance.instantiateImageCodec(bytes, cacheWidth: cacheWidth, cacheHeight: cacheHeight, allowUpscaling: allowUpscaling); return PaintingBinding.instance!.instantiateImageCodec(bytes, cacheWidth: cacheWidth, cacheHeight: cacheHeight, allowUpscaling: allowUpscaling ?? false);
}; };
_FakeHttpClient httpClient; late _FakeHttpClient httpClient;
setUp(() { setUp(() {
httpClient = _FakeHttpClient(); httpClient = _FakeHttpClient();
...@@ -34,8 +32,8 @@ void main() { ...@@ -34,8 +32,8 @@ void main() {
tearDown(() { tearDown(() {
debugNetworkImageHttpClientProvider = null; debugNetworkImageHttpClientProvider = null;
PaintingBinding.instance.imageCache.clear(); PaintingBinding.instance!.imageCache!.clear();
PaintingBinding.instance.imageCache.clearLiveImages(); PaintingBinding.instance!.imageCache!.clearLiveImages();
}); });
test('Expect thrown exception with statusCode - evicts from cache', () async { test('Expect thrown exception with statusCode - evicts from cache', () async {
...@@ -47,23 +45,23 @@ void main() { ...@@ -47,23 +45,23 @@ void main() {
final Completer<dynamic> caughtError = Completer<dynamic>(); final Completer<dynamic> caughtError = Completer<dynamic>();
final ImageProvider imageProvider = NetworkImage(nonconst(requestUrl)); final ImageProvider imageProvider = NetworkImage(nonconst(requestUrl));
expect(imageCache.pendingImageCount, 0); expect(imageCache!.pendingImageCount, 0);
expect(imageCache.statusForKey(imageProvider).untracked, true); expect(imageCache!.statusForKey(imageProvider).untracked, true);
final ImageStream result = imageProvider.resolve(ImageConfiguration.empty); final ImageStream result = imageProvider.resolve(ImageConfiguration.empty);
expect(imageCache.pendingImageCount, 1); expect(imageCache!.pendingImageCount, 1);
expect(imageCache.statusForKey(imageProvider).pending, true); expect(imageCache!.statusForKey(imageProvider).pending, true);
result.addListener(ImageStreamListener((ImageInfo info, bool syncCall) { result.addListener(ImageStreamListener((ImageInfo info, bool syncCall) {
}, onError: (dynamic error, StackTrace stackTrace) { }, onError: (dynamic error, StackTrace? stackTrace) {
caughtError.complete(error); caughtError.complete(error);
})); }));
final dynamic err = await caughtError.future; final dynamic err = await caughtError.future;
expect(imageCache.pendingImageCount, 0); expect(imageCache!.pendingImageCount, 0);
expect(imageCache.statusForKey(imageProvider).untracked, true); expect(imageCache!.statusForKey(imageProvider).untracked, true);
expect( expect(
err, err,
...@@ -73,12 +71,6 @@ void main() { ...@@ -73,12 +71,6 @@ void main() {
); );
}, skip: isBrowser); // Browser implementation does not use HTTP client but an <img> tag. }, skip: isBrowser); // Browser implementation does not use HTTP client but an <img> tag.
test('Disallows null urls', () {
expect(() {
NetworkImage(nonconst(null));
}, throwsAssertionError);
});
test('Uses the HttpClient provided by debugNetworkImageHttpClientProvider if set', () async { test('Uses the HttpClient provided by debugNetworkImageHttpClientProvider if set', () async {
httpClient.thrownError = 'client1'; httpClient.thrownError = 'client1';
final List<dynamic> capturedErrors = <dynamic>[]; final List<dynamic> capturedErrors = <dynamic>[];
...@@ -88,7 +80,7 @@ void main() { ...@@ -88,7 +80,7 @@ void main() {
final ImageStreamCompleter completer = networkImage.load(networkImage, _basicDecoder); final ImageStreamCompleter completer = networkImage.load(networkImage, _basicDecoder);
completer.addListener(ImageStreamListener( completer.addListener(ImageStreamListener(
(ImageInfo image, bool synchronousCall) { }, (ImageInfo image, bool synchronousCall) { },
onError: (dynamic error, StackTrace stackTrace) { onError: (dynamic error, StackTrace? stackTrace) {
capturedErrors.add(error); capturedErrors.add(error);
}, },
)); ));
...@@ -108,7 +100,7 @@ void main() { ...@@ -108,7 +100,7 @@ void main() {
httpClient.thrownError = Error(); httpClient.thrownError = Error();
bool uncaught = false; bool uncaught = false;
final FlutterExceptionHandler oldError = FlutterError.onError; final FlutterExceptionHandler? oldError = FlutterError.onError;
await runZoned(() async { await runZoned(() async {
const ImageProvider imageProvider = NetworkImage('asdasdasdas'); const ImageProvider imageProvider = NetworkImage('asdasdasdas');
final Completer<bool> caughtError = Completer<bool>(); final Completer<bool> caughtError = Completer<bool>();
...@@ -117,7 +109,7 @@ void main() { ...@@ -117,7 +109,7 @@ void main() {
}; };
final ImageStream result = imageProvider.resolve(ImageConfiguration.empty); final ImageStream result = imageProvider.resolve(ImageConfiguration.empty);
result.addListener(ImageStreamListener((ImageInfo info, bool syncCall) { result.addListener(ImageStreamListener((ImageInfo info, bool syncCall) {
}, onError: (dynamic error, StackTrace stackTrace) { }, onError: (dynamic error, StackTrace? stackTrace) {
caughtError.complete(true); caughtError.complete(true);
})); }));
expect(await caughtError.future, true); expect(await caughtError.future, true);
...@@ -153,8 +145,8 @@ void main() { ...@@ -153,8 +145,8 @@ void main() {
onChunk: (ImageChunkEvent event) { onChunk: (ImageChunkEvent event) {
events.add(event); events.add(event);
}, },
onError: (dynamic error, StackTrace stackTrace) { onError: (dynamic error, StackTrace? stackTrace) {
imageAvailable.completeError(error, stackTrace); imageAvailable.completeError(error as Object, stackTrace);
}, },
)); ));
await imageAvailable.future; await imageAvailable.future;
...@@ -171,17 +163,17 @@ void main() { ...@@ -171,17 +163,17 @@ void main() {
debugNetworkImageHttpClientProvider = () => mockHttpClient; debugNetworkImageHttpClientProvider = () => mockHttpClient;
final ImageProvider imageProvider = NetworkImage(nonconst('testing.url')); final ImageProvider imageProvider = NetworkImage(nonconst('testing.url'));
expect(imageCache.pendingImageCount, 0); expect(imageCache!.pendingImageCount, 0);
expect(imageCache.statusForKey(imageProvider).untracked, true); expect(imageCache!.statusForKey(imageProvider).untracked, true);
final ImageStream result = imageProvider.resolve(ImageConfiguration.empty); final ImageStream result = imageProvider.resolve(ImageConfiguration.empty);
expect(imageCache.pendingImageCount, 1); expect(imageCache!.pendingImageCount, 1);
expect(imageCache.statusForKey(imageProvider).pending, true); expect(imageCache!.statusForKey(imageProvider).pending, true);
final Completer<dynamic> caughtError = Completer<dynamic>(); final Completer<dynamic> caughtError = Completer<dynamic>();
result.addListener(ImageStreamListener( result.addListener(ImageStreamListener(
(ImageInfo info, bool syncCall) {}, (ImageInfo info, bool syncCall) {},
onError: (dynamic error, StackTrace stackTrace) { onError: (dynamic error, StackTrace? stackTrace) {
caughtError.complete(error); caughtError.complete(error);
}, },
)); ));
...@@ -190,14 +182,14 @@ void main() { ...@@ -190,14 +182,14 @@ void main() {
expect(err, isA<SocketException>()); expect(err, isA<SocketException>());
expect(imageCache.pendingImageCount, 0); expect(imageCache!.pendingImageCount, 0);
expect(imageCache.statusForKey(imageProvider).untracked, true); expect(imageCache!.statusForKey(imageProvider).untracked, true);
expect(imageCache.containsKey(result), isFalse); expect(imageCache!.containsKey(result), isFalse);
debugNetworkImageHttpClientProvider = null; debugNetworkImageHttpClientProvider = null;
}, skip: isBrowser); // Browser does not resolve images this way. }, skip: isBrowser); // Browser does not resolve images this way.
Future<Codec> _decoder(Uint8List bytes, {int cacheWidth, int cacheHeight, bool allowUpscaling}) async { Future<Codec> _decoder(Uint8List bytes, {int? cacheWidth, int? cacheHeight, bool? allowUpscaling}) async {
return FakeCodec(); return FakeCodec();
} }
...@@ -223,12 +215,12 @@ void main() { ...@@ -223,12 +215,12 @@ void main() {
class _FakeHttpClient extends Fake implements HttpClient { class _FakeHttpClient extends Fake implements HttpClient {
final _FakeHttpClientRequest request = _FakeHttpClientRequest(); final _FakeHttpClientRequest request = _FakeHttpClientRequest();
dynamic thrownError; Object? thrownError;
@override @override
Future<HttpClientRequest> getUrl(Uri url) async { Future<HttpClientRequest> getUrl(Uri url) async {
if (thrownError != null) { if (thrownError != null) {
throw thrownError; throw thrownError!;
} }
return request; return request;
} }
...@@ -252,10 +244,10 @@ class _FakeHttpClientResponse extends Fake implements HttpClientResponse { ...@@ -252,10 +244,10 @@ class _FakeHttpClientResponse extends Fake implements HttpClientResponse {
@override @override
HttpClientResponseCompressionState get compressionState => HttpClientResponseCompressionState.notCompressed; HttpClientResponseCompressionState get compressionState => HttpClientResponseCompressionState.notCompressed;
List<List<int>> content; late List<List<int>> content;
@override @override
StreamSubscription<List<int>> listen(void Function(List<int> event) onData, {Function onError, void Function() onDone, bool cancelOnError}) { StreamSubscription<List<int>> listen(void Function(List<int> event)? onData, {Function? onError, void Function()? onDone, bool? cancelOnError}) {
return Stream<List<int>>.fromIterable(content).listen( return Stream<List<int>>.fromIterable(content).listen(
onData, onData,
onDone: onDone, onDone: onDone,
......
...@@ -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 'dart:typed_data'; import 'dart:typed_data';
...@@ -17,8 +15,8 @@ void main() { ...@@ -17,8 +15,8 @@ void main() {
TestRenderingFlutterBinding(); TestRenderingFlutterBinding();
tearDown(() { tearDown(() {
PaintingBinding.instance.imageCache.clear(); PaintingBinding.instance!.imageCache!.clear();
PaintingBinding.instance.imageCache.clearLiveImages(); PaintingBinding.instance!.imageCache!.clearLiveImages();
}); });
test('ResizeImage resizes to the correct dimensions (up)', () async { test('ResizeImage resizes to the correct dimensions (up)', () async {
...@@ -100,11 +98,11 @@ void main() { ...@@ -100,11 +98,11 @@ void main() {
final MemoryImage memoryImage = MemoryImage(bytes); final MemoryImage memoryImage = MemoryImage(bytes);
final ResizeImage resizeImage = ResizeImage(memoryImage, width: 123, height: 321); final ResizeImage resizeImage = ResizeImage(memoryImage, width: 123, height: 321);
final DecoderCallback decode = (Uint8List bytes, {int cacheWidth, int cacheHeight, bool allowUpscaling}) { final DecoderCallback decode = (Uint8List bytes, {int? cacheWidth, int? cacheHeight, bool allowUpscaling = false}) {
expect(cacheWidth, 123); expect(cacheWidth, 123);
expect(cacheHeight, 321); expect(cacheHeight, 321);
expect(allowUpscaling, false); expect(allowUpscaling, false);
return PaintingBinding.instance.instantiateImageCodec(bytes, cacheWidth: cacheWidth, cacheHeight: cacheHeight, allowUpscaling: allowUpscaling); return PaintingBinding.instance!.instantiateImageCodec(bytes, cacheWidth: cacheWidth, cacheHeight: cacheHeight, allowUpscaling: allowUpscaling);
}; };
resizeImage.load(await resizeImage.obtainKey(ImageConfiguration.empty), decode); resizeImage.load(await resizeImage.obtainKey(ImageConfiguration.empty), decode);
......
...@@ -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 'dart:io'; import 'dart:io';
import 'dart:typed_data'; import 'dart:typed_data';
...@@ -22,15 +20,15 @@ import 'mocks_for_image_cache.dart'; ...@@ -22,15 +20,15 @@ import 'mocks_for_image_cache.dart';
void main() { void main() {
TestRenderingFlutterBinding(); TestRenderingFlutterBinding();
FlutterExceptionHandler oldError; FlutterExceptionHandler? oldError;
setUp(() { setUp(() {
oldError = FlutterError.onError; oldError = FlutterError.onError;
}); });
tearDown(() { tearDown(() {
FlutterError.onError = oldError; FlutterError.onError = oldError;
PaintingBinding.instance.imageCache.clear(); PaintingBinding.instance!.imageCache!.clear();
PaintingBinding.instance.imageCache.clearLiveImages(); PaintingBinding.instance!.imageCache!.clearLiveImages();
}); });
test('obtainKey errors will be caught', () async { test('obtainKey errors will be caught', () async {
...@@ -42,7 +40,7 @@ void main() { ...@@ -42,7 +40,7 @@ void main() {
final ImageStream stream = imageProvider.resolve(ImageConfiguration.empty); final ImageStream stream = imageProvider.resolve(ImageConfiguration.empty);
stream.addListener(ImageStreamListener((ImageInfo info, bool syncCall) { stream.addListener(ImageStreamListener((ImageInfo info, bool syncCall) {
caughtError.complete(false); caughtError.complete(false);
}, onError: (dynamic error, StackTrace stackTrace) { }, onError: (dynamic error, StackTrace? stackTrace) {
caughtError.complete(true); caughtError.complete(true);
})); }));
expect(await caughtError.future, true); expect(await caughtError.future, true);
...@@ -74,7 +72,7 @@ void main() { ...@@ -74,7 +72,7 @@ void main() {
}; };
final ImageStream result = imageProvider.resolve(ImageConfiguration.empty); final ImageStream result = imageProvider.resolve(ImageConfiguration.empty);
result.addListener(ImageStreamListener((ImageInfo info, bool syncCall) { result.addListener(ImageStreamListener((ImageInfo info, bool syncCall) {
}, onError: (dynamic error, StackTrace stackTrace) { }, onError: (dynamic error, StackTrace? stackTrace) {
caughtError.complete(true); caughtError.complete(true);
})); }));
expect(await caughtError.future, true); expect(await caughtError.future, true);
...@@ -97,7 +95,7 @@ void main() { ...@@ -97,7 +95,7 @@ void main() {
}; };
final ImageStream result = imageProvider.resolve(ImageConfiguration.empty); final ImageStream result = imageProvider.resolve(ImageConfiguration.empty);
result.addListener(ImageStreamListener((ImageInfo info, bool syncCall) { result.addListener(ImageStreamListener((ImageInfo info, bool syncCall) {
}, onError: (dynamic error, StackTrace stackTrace) { }, onError: (dynamic error, StackTrace? stackTrace) {
caughtError.complete(true); caughtError.complete(true);
})); }));
expect(await caughtError.future, true); expect(await caughtError.future, true);
...@@ -114,17 +112,17 @@ void main() { ...@@ -114,17 +112,17 @@ void main() {
final File file = fs.file('/empty.png')..createSync(recursive: true); final File file = fs.file('/empty.png')..createSync(recursive: true);
final FileImage provider = FileImage(file); final FileImage provider = FileImage(file);
expect(imageCache.statusForKey(provider).untracked, true); expect(imageCache!.statusForKey(provider).untracked, true);
expect(imageCache.pendingImageCount, 0); expect(imageCache!.pendingImageCount, 0);
provider.resolve(ImageConfiguration.empty); provider.resolve(ImageConfiguration.empty);
expect(imageCache.statusForKey(provider).pending, true); expect(imageCache!.statusForKey(provider).pending, true);
expect(imageCache.pendingImageCount, 1); expect(imageCache!.pendingImageCount, 1);
expect(await error.future, isStateError); expect(await error.future, isStateError);
expect(imageCache.statusForKey(provider).untracked, true); expect(imageCache!.statusForKey(provider).untracked, true);
expect(imageCache.pendingImageCount, 0); expect(imageCache!.pendingImageCount, 0);
}); });
test('File image with empty file throws expected error (load)', () async { test('File image with empty file throws expected error (load)', () async {
...@@ -136,14 +134,14 @@ void main() { ...@@ -136,14 +134,14 @@ void main() {
final File file = fs.file('/empty.png')..createSync(recursive: true); final File file = fs.file('/empty.png')..createSync(recursive: true);
final FileImage provider = FileImage(file); final FileImage provider = FileImage(file);
expect(provider.load(provider, (Uint8List bytes, {int cacheWidth, int cacheHeight, bool allowUpscaling}) async { expect(provider.load(provider, (Uint8List bytes, {int? cacheWidth, int? cacheHeight, bool? allowUpscaling}) async {
return Future<Codec>.value(FakeCodec()); return Future<Codec>.value(FakeCodec());
}), isA<MultiFrameImageStreamCompleter>()); }), isA<MultiFrameImageStreamCompleter>());
expect(await error.future, isStateError); expect(await error.future, isStateError);
}); });
Future<Codec> _decoder(Uint8List bytes, {int cacheWidth, int cacheHeight, bool allowUpscaling}) async { Future<Codec> _decoder(Uint8List bytes, {int? cacheWidth, int? cacheHeight, bool? allowUpscaling}) async {
return FakeCodec(); return FakeCodec();
} }
......
...@@ -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:convert'; import 'dart:convert';
import 'dart:typed_data'; import 'dart:typed_data';
......
...@@ -2,15 +2,12 @@ ...@@ -2,15 +2,12 @@
// 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 'dart:ui'; import 'dart:ui';
import 'package:flutter/painting.dart'; import 'package:flutter/painting.dart';
import 'package:flutter/scheduler.dart' show timeDilation, SchedulerBinding; import 'package:flutter/scheduler.dart' show timeDilation, SchedulerBinding;
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:meta/meta.dart';
class FakeFrameInfo implements FrameInfo { class FakeFrameInfo implements FrameInfo {
const FakeFrameInfo(this._duration, this._image); const FakeFrameInfo(this._duration, this._image);
...@@ -24,7 +21,7 @@ class FakeFrameInfo implements FrameInfo { ...@@ -24,7 +21,7 @@ class FakeFrameInfo implements FrameInfo {
@override @override
Image get image => _image; Image get image => _image;
int get imageHandleCount => image.debugGetOpenHandleStackTraces().length; int get imageHandleCount => image.debugGetOpenHandleStackTraces()!.length;
FakeFrameInfo clone() { FakeFrameInfo clone() {
return FakeFrameInfo( return FakeFrameInfo(
...@@ -35,12 +32,11 @@ class FakeFrameInfo implements FrameInfo { ...@@ -35,12 +32,11 @@ class FakeFrameInfo implements FrameInfo {
} }
class MockCodec implements Codec { class MockCodec implements Codec {
@override @override
int frameCount; late int frameCount;
@override @override
int repetitionCount; late int repetitionCount;
int numFramesAsked = 0; int numFramesAsked = 0;
...@@ -67,7 +63,7 @@ class MockCodec implements Codec { ...@@ -67,7 +63,7 @@ class MockCodec implements Codec {
} }
class FakeEventReportingImageStreamCompleter extends ImageStreamCompleter { class FakeEventReportingImageStreamCompleter extends ImageStreamCompleter {
FakeEventReportingImageStreamCompleter({Stream<ImageChunkEvent> chunkEvents,}) { FakeEventReportingImageStreamCompleter({Stream<ImageChunkEvent>? chunkEvents}) {
if (chunkEvents != null) { if (chunkEvents != null) {
chunkEvents.listen((ImageChunkEvent event) { chunkEvents.listen((ImageChunkEvent event) {
reportImageChunkEvent(event); reportImageChunkEvent(event);
...@@ -78,8 +74,8 @@ class FakeEventReportingImageStreamCompleter extends ImageStreamCompleter { ...@@ -78,8 +74,8 @@ class FakeEventReportingImageStreamCompleter extends ImageStreamCompleter {
} }
void main() { void main() {
Image image20x10; late Image image20x10;
Image image200x100; late Image image200x100;
setUp(() async { setUp(() async {
image20x10 = await createTestImage(width: 20, height: 10); image20x10 = await createTestImage(width: 20, height: 10);
image200x100 = await createTestImage(width: 200, height: 100); image200x100 = await createTestImage(width: 200, height: 100);
...@@ -602,7 +598,7 @@ void main() { ...@@ -602,7 +598,7 @@ void main() {
); );
dynamic capturedException; dynamic capturedException;
final ImageErrorListener errorListener = (dynamic exception, StackTrace stackTrace) { final ImageErrorListener errorListener = (dynamic exception, StackTrace? stackTrace) {
capturedException = exception; capturedException = exception;
}; };
...@@ -660,16 +656,16 @@ void main() { ...@@ -660,16 +656,16 @@ void main() {
testWidgets('ImageStreamListener hashCode and equals', (WidgetTester tester) async { testWidgets('ImageStreamListener hashCode and equals', (WidgetTester tester) async {
void handleImage(ImageInfo image, bool synchronousCall) { } void handleImage(ImageInfo image, bool synchronousCall) { }
void handleImageDifferently(ImageInfo image, bool synchronousCall) { } void handleImageDifferently(ImageInfo image, bool synchronousCall) { }
void handleError(dynamic error, StackTrace stackTrace) { } void handleError(dynamic error, StackTrace? stackTrace) { }
void handleChunk(ImageChunkEvent event) { } void handleChunk(ImageChunkEvent event) { }
void compare({ void compare({
@required ImageListener onImage1, required ImageListener onImage1,
@required ImageListener onImage2, required ImageListener onImage2,
ImageChunkListener onChunk1, ImageChunkListener? onChunk1,
ImageChunkListener onChunk2, ImageChunkListener? onChunk2,
ImageErrorListener onError1, ImageErrorListener? onError1,
ImageErrorListener onError2, ImageErrorListener? onError2,
bool areEqual = true, bool areEqual = true,
}) { }) {
final ImageStreamListener l1 = ImageStreamListener(onImage1, onChunk: onChunk1, onError: onError1); final ImageStreamListener l1 = ImageStreamListener(onImage1, onChunk: onChunk1, onError: onError1);
...@@ -690,7 +686,7 @@ void main() { ...@@ -690,7 +686,7 @@ void main() {
}); });
testWidgets('Keep alive handles do not drive frames or prevent last listener callbacks', (WidgetTester tester) async { testWidgets('Keep alive handles do not drive frames or prevent last listener callbacks', (WidgetTester tester) async {
final Image image10x10 = await tester.runAsync(() => createTestImage(width: 10, height: 10)); final Image image10x10 = (await tester.runAsync(() => createTestImage(width: 10, height: 10)))!;
final MockCodec mockCodec = MockCodec(); final MockCodec mockCodec = MockCodec();
mockCodec.frameCount = 2; mockCodec.frameCount = 2;
mockCodec.repetitionCount = -1; mockCodec.repetitionCount = -1;
...@@ -713,7 +709,7 @@ void main() { ...@@ -713,7 +709,7 @@ void main() {
expect(lastListenerDropped, false); expect(lastListenerDropped, false);
final ImageStreamCompleterHandle handle = imageStream.keepAlive(); final ImageStreamCompleterHandle handle = imageStream.keepAlive();
expect(lastListenerDropped, false); expect(lastListenerDropped, false);
SchedulerBinding.instance.debugAssertNoTransientCallbacks('Only passive listeners'); SchedulerBinding.instance!.debugAssertNoTransientCallbacks('Only passive listeners');
codecCompleter.complete(mockCodec); codecCompleter.complete(mockCodec);
await tester.idle(); await tester.idle();
...@@ -723,7 +719,7 @@ void main() { ...@@ -723,7 +719,7 @@ void main() {
final FakeFrameInfo frame1 = FakeFrameInfo(Duration.zero, image20x10); final FakeFrameInfo frame1 = FakeFrameInfo(Duration.zero, image20x10);
mockCodec.completeNextFrame(frame1); mockCodec.completeNextFrame(frame1);
await tester.idle(); await tester.idle();
SchedulerBinding.instance.debugAssertNoTransientCallbacks('Only passive listeners'); SchedulerBinding.instance!.debugAssertNoTransientCallbacks('Only passive listeners');
await tester.pump(); await tester.pump();
expect(onImageCount, 0); expect(onImageCount, 0);
...@@ -732,7 +728,7 @@ void main() { ...@@ -732,7 +728,7 @@ void main() {
final FakeFrameInfo frame2 = FakeFrameInfo(Duration.zero, image10x10); final FakeFrameInfo frame2 = FakeFrameInfo(Duration.zero, image10x10);
mockCodec.completeNextFrame(frame2); mockCodec.completeNextFrame(frame2);
await tester.idle(); await tester.idle();
expect(SchedulerBinding.instance.transientCallbackCount, 1); expect(SchedulerBinding.instance!.transientCallbackCount, 1);
await tester.pump(); await tester.pump();
expect(onImageCount, 1); expect(onImageCount, 1);
...@@ -742,16 +738,16 @@ void main() { ...@@ -742,16 +738,16 @@ void main() {
mockCodec.completeNextFrame(frame1); mockCodec.completeNextFrame(frame1);
await tester.idle(); await tester.idle();
expect(SchedulerBinding.instance.transientCallbackCount, 1); expect(SchedulerBinding.instance!.transientCallbackCount, 1);
await tester.pump(); await tester.pump();
expect(onImageCount, 1); expect(onImageCount, 1);
SchedulerBinding.instance.debugAssertNoTransientCallbacks('Only passive listeners'); SchedulerBinding.instance!.debugAssertNoTransientCallbacks('Only passive listeners');
mockCodec.completeNextFrame(frame2); mockCodec.completeNextFrame(frame2);
await tester.idle(); await tester.idle();
SchedulerBinding.instance.debugAssertNoTransientCallbacks('Only passive listeners'); SchedulerBinding.instance!.debugAssertNoTransientCallbacks('Only passive listeners');
await tester.pump(); await tester.pump();
expect(onImageCount, 1); expect(onImageCount, 1);
......
...@@ -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:math'; import 'dart:math';
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 'dart:math' as math; import 'dart:math' as math;
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 'dart:ui' as ui; import 'dart:ui' as ui;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -20,8 +18,8 @@ class TestCanvas implements Canvas { ...@@ -20,8 +18,8 @@ class TestCanvas implements Canvas {
} }
void main() { void main() {
ui.Image image300x300; late ui.Image image300x300;
ui.Image image300x200; late ui.Image image300x200;
setUpAll(() async { setUpAll(() async {
image300x300 = await createTestImage(width: 300, height: 300, cache: false); image300x300 = await createTestImage(width: 300, height: 300, cache: false);
image300x200 = await createTestImage(width: 300, height: 200, cache: false); image300x200 = await createTestImage(width: 300, height: 200, cache: false);
...@@ -53,7 +51,7 @@ void main() { ...@@ -53,7 +51,7 @@ void main() {
test('debugInvertOversizedImages', () async { test('debugInvertOversizedImages', () async {
debugInvertOversizedImages = true; debugInvertOversizedImages = true;
final FlutterExceptionHandler oldFlutterError = FlutterError.onError; final FlutterExceptionHandler? oldFlutterError = FlutterError.onError;
final List<String> messages = <String>[]; final List<String> messages = <String>[];
FlutterError.onError = (FlutterErrorDetails details) { FlutterError.onError = (FlutterErrorDetails details) {
...@@ -111,7 +109,7 @@ void main() { ...@@ -111,7 +109,7 @@ void main() {
}); });
testWidgets('Reports Image painting', (WidgetTester tester) async { testWidgets('Reports Image painting', (WidgetTester tester) async {
ImageSizeInfo imageSizeInfo; late ImageSizeInfo imageSizeInfo;
int count = 0; int count = 0;
debugOnPaintImage = (ImageSizeInfo info) { debugOnPaintImage = (ImageSizeInfo info) {
count += 1; count += 1;
...@@ -150,7 +148,7 @@ void main() { ...@@ -150,7 +148,7 @@ void main() {
}); });
testWidgets('Reports Image painting - change per frame', (WidgetTester tester) async { testWidgets('Reports Image painting - change per frame', (WidgetTester tester) async {
ImageSizeInfo imageSizeInfo; late ImageSizeInfo imageSizeInfo;
int count = 0; int count = 0;
debugOnPaintImage = (ImageSizeInfo info) { debugOnPaintImage = (ImageSizeInfo info) {
count += 1; count += 1;
...@@ -193,7 +191,7 @@ void main() { ...@@ -193,7 +191,7 @@ void main() {
}); });
testWidgets('Reports Image painting - no debug label', (WidgetTester tester) async { testWidgets('Reports Image painting - no debug label', (WidgetTester tester) async {
ImageSizeInfo imageSizeInfo; late ImageSizeInfo imageSizeInfo;
int count = 0; int count = 0;
debugOnPaintImage = (ImageSizeInfo info) { debugOnPaintImage = (ImageSizeInfo info) {
count += 1; count += 1;
......
...@@ -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/painting.dart'; import 'package:flutter/painting.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -75,18 +73,18 @@ void main() { ...@@ -75,18 +73,18 @@ void main() {
); );
expect(r.getOuterPath(rect), looksLikeR); expect(r.getOuterPath(rect), looksLikeR);
expect(c.getOuterPath(rect), looksLikeC); expect(c.getOuterPath(rect), looksLikeC);
expect(ShapeBorder.lerp(r, c, 0.1).getOuterPath(rect), looksLikeR); expect(ShapeBorder.lerp(r, c, 0.1)!.getOuterPath(rect), looksLikeR);
expect(ShapeBorder.lerp(r, c, 0.9).getOuterPath(rect), looksLikeC); expect(ShapeBorder.lerp(r, c, 0.9)!.getOuterPath(rect), looksLikeC);
expect(ShapeBorder.lerp(ShapeBorder.lerp(r, c, 0.9), r, 0.1).getOuterPath(rect), looksLikeC); expect(ShapeBorder.lerp(ShapeBorder.lerp(r, c, 0.9), r, 0.1)!.getOuterPath(rect), looksLikeC);
expect(ShapeBorder.lerp(ShapeBorder.lerp(r, c, 0.9), r, 0.9).getOuterPath(rect), looksLikeR); expect(ShapeBorder.lerp(ShapeBorder.lerp(r, c, 0.9), r, 0.9)!.getOuterPath(rect), looksLikeR);
expect(ShapeBorder.lerp(ShapeBorder.lerp(r, c, 0.1), c, 0.1).getOuterPath(rect), looksLikeR); expect(ShapeBorder.lerp(ShapeBorder.lerp(r, c, 0.1), c, 0.1)!.getOuterPath(rect), looksLikeR);
expect(ShapeBorder.lerp(ShapeBorder.lerp(r, c, 0.1), c, 0.9).getOuterPath(rect), looksLikeC); expect(ShapeBorder.lerp(ShapeBorder.lerp(r, c, 0.1), c, 0.9)!.getOuterPath(rect), looksLikeC);
expect(ShapeBorder.lerp(ShapeBorder.lerp(r, c, 0.1), ShapeBorder.lerp(r, c, 0.9), 0.1).getOuterPath(rect), looksLikeR); expect(ShapeBorder.lerp(ShapeBorder.lerp(r, c, 0.1), ShapeBorder.lerp(r, c, 0.9), 0.1)!.getOuterPath(rect), looksLikeR);
expect(ShapeBorder.lerp(ShapeBorder.lerp(r, c, 0.1), ShapeBorder.lerp(r, c, 0.9), 0.9).getOuterPath(rect), looksLikeC); expect(ShapeBorder.lerp(ShapeBorder.lerp(r, c, 0.1), ShapeBorder.lerp(r, c, 0.9), 0.9)!.getOuterPath(rect), looksLikeC);
expect(ShapeBorder.lerp(r, ShapeBorder.lerp(r, c, 0.9), 0.1).getOuterPath(rect), looksLikeR); expect(ShapeBorder.lerp(r, ShapeBorder.lerp(r, c, 0.9), 0.1)!.getOuterPath(rect), looksLikeR);
expect(ShapeBorder.lerp(r, ShapeBorder.lerp(r, c, 0.9), 0.9).getOuterPath(rect), looksLikeC); expect(ShapeBorder.lerp(r, ShapeBorder.lerp(r, c, 0.9), 0.9)!.getOuterPath(rect), looksLikeC);
expect(ShapeBorder.lerp(c, ShapeBorder.lerp(r, c, 0.1), 0.1).getOuterPath(rect), looksLikeC); expect(ShapeBorder.lerp(c, ShapeBorder.lerp(r, c, 0.1), 0.1)!.getOuterPath(rect), looksLikeC);
expect(ShapeBorder.lerp(c, ShapeBorder.lerp(r, c, 0.1), 0.9).getOuterPath(rect), looksLikeR); expect(ShapeBorder.lerp(c, ShapeBorder.lerp(r, c, 0.1), 0.9)!.getOuterPath(rect), looksLikeR);
expect(ShapeBorder.lerp(r, c, 0.1).toString(), expect(ShapeBorder.lerp(r, c, 0.1).toString(),
'RoundedRectangleBorder(BorderSide(Color(0xff000000), 0.0, BorderStyle.none), BorderRadius.circular(10.0), 10.0% of the way to being a CircleBorder)'); 'RoundedRectangleBorder(BorderSide(Color(0xff000000), 0.0, BorderStyle.none), BorderRadius.circular(10.0), 10.0% of the way to being a CircleBorder)');
...@@ -105,8 +103,8 @@ void main() { ...@@ -105,8 +103,8 @@ void main() {
expect(ShapeBorder.lerp(r, c, 0.1), ShapeBorder.lerp(r, c, 0.1)); expect(ShapeBorder.lerp(r, c, 0.1), ShapeBorder.lerp(r, c, 0.1));
expect(ShapeBorder.lerp(r, c, 0.1).hashCode, ShapeBorder.lerp(r, c, 0.1).hashCode); expect(ShapeBorder.lerp(r, c, 0.1).hashCode, ShapeBorder.lerp(r, c, 0.1).hashCode);
final ShapeBorder direct50 = ShapeBorder.lerp(r, c, 0.5); final ShapeBorder direct50 = ShapeBorder.lerp(r, c, 0.5)!;
final ShapeBorder indirect50 = ShapeBorder.lerp(ShapeBorder.lerp(c, r, 0.1), ShapeBorder.lerp(c, r, 0.9), 0.5); final ShapeBorder indirect50 = ShapeBorder.lerp(ShapeBorder.lerp(c, r, 0.1), ShapeBorder.lerp(c, r, 0.9), 0.5)!;
expect(direct50, indirect50); expect(direct50, indirect50);
expect(direct50.hashCode, indirect50.hashCode); expect(direct50.hashCode, indirect50.hashCode);
expect(direct50.toString(), indirect50.toString()); expect(direct50.toString(), indirect50.toString());
......
...@@ -2,32 +2,29 @@ ...@@ -2,32 +2,29 @@
// 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/painting.dart'; import 'package:flutter/painting.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
class TestCanvas implements Canvas { class TestCanvas implements Canvas {
TestCanvas([this.invocations]); TestCanvas();
final List<Invocation> invocations; final List<Invocation> invocations = <Invocation>[];
@override @override
void noSuchMethod(Invocation invocation) { void noSuchMethod(Invocation invocation) {
invocations?.add(invocation); invocations.add(invocation);
} }
} }
void main() { void main() {
test('DefaultShaderWarmUp has expected canvas invocations', () { test('DefaultShaderWarmUp has expected canvas invocations', () {
final List<Invocation> invocations = <Invocation>[]; final TestCanvas canvas = TestCanvas();
final TestCanvas canvas = TestCanvas(invocations);
const DefaultShaderWarmUp s = DefaultShaderWarmUp(); const DefaultShaderWarmUp s = DefaultShaderWarmUp();
s.warmUpOnCanvas(canvas); s.warmUpOnCanvas(canvas);
bool hasDrawRectAfterClipRRect = false; bool hasDrawRectAfterClipRRect = false;
for (int i = 0; i < invocations.length - 1; i += 1) { for (int i = 0; i < canvas.invocations.length - 1; i += 1) {
if (invocations[i].memberName == #clipRRect && invocations[i + 1].memberName == #drawRect) { if (canvas.invocations[i].memberName == #clipRRect && canvas.invocations[i + 1].memberName == #drawRect) {
hasDrawRectAfterClipRRect = true; hasDrawRectAfterClipRRect = true;
break; break;
} }
......
...@@ -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/painting.dart'; import 'package:flutter/painting.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 'dart:ui' as ui; import 'dart:ui' as ui;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -22,7 +20,6 @@ void main() { ...@@ -22,7 +20,6 @@ void main() {
const Gradient gradient = LinearGradient(colors: <Color>[colorR, colorG]); const Gradient gradient = LinearGradient(colors: <Color>[colorR, colorG]);
expect(const ShapeDecoration(shape: Border()), const ShapeDecoration(shape: Border())); expect(const ShapeDecoration(shape: Border()), const ShapeDecoration(shape: Border()));
expect(() => ShapeDecoration(color: colorR, gradient: nonconst(gradient), shape: const Border()), throwsAssertionError); expect(() => ShapeDecoration(color: colorR, gradient: nonconst(gradient), shape: const Border()), throwsAssertionError);
expect(() => ShapeDecoration(gradient: nonconst(gradient), shape: null), throwsAssertionError);
expect( expect(
ShapeDecoration.fromBoxDecoration(const BoxDecoration(shape: BoxShape.circle)), ShapeDecoration.fromBoxDecoration(const BoxDecoration(shape: BoxShape.circle)),
const ShapeDecoration(shape: CircleBorder(side: BorderSide.none)), const ShapeDecoration(shape: CircleBorder(side: BorderSide.none)),
...@@ -52,9 +49,9 @@ void main() { ...@@ -52,9 +49,9 @@ void main() {
expect(Decoration.lerp(a, b, 1.0), b); expect(Decoration.lerp(a, b, 1.0), b);
const Size size = Size(200.0, 100.0); // at t=0.5, width will be 150 (x=25 to x=175). const Size size = Size(200.0, 100.0); // at t=0.5, width will be 150 (x=25 to x=175).
expect(a.hitTest(size, const Offset(20.0, 50.0)), isFalse); expect(a.hitTest(size, const Offset(20.0, 50.0)), isFalse);
expect(Decoration.lerp(a, b, 0.1).hitTest(size, const Offset(20.0, 50.0)), isFalse); expect(Decoration.lerp(a, b, 0.1)!.hitTest(size, const Offset(20.0, 50.0)), isFalse);
expect(Decoration.lerp(a, b, 0.5).hitTest(size, const Offset(20.0, 50.0)), isFalse); expect(Decoration.lerp(a, b, 0.5)!.hitTest(size, const Offset(20.0, 50.0)), isFalse);
expect(Decoration.lerp(a, b, 0.9).hitTest(size, const Offset(20.0, 50.0)), isTrue); expect(Decoration.lerp(a, b, 0.9)!.hitTest(size, const Offset(20.0, 50.0)), isTrue);
expect(b.hitTest(size, const Offset(20.0, 50.0)), isTrue); expect(b.hitTest(size, const Offset(20.0, 50.0)), isTrue);
}); });
......
...@@ -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/painting.dart'; import 'package:flutter/painting.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -63,18 +61,18 @@ void main() { ...@@ -63,18 +61,18 @@ void main() {
); );
expect(stadium.getOuterPath(rect), looksLikeS); expect(stadium.getOuterPath(rect), looksLikeS);
expect(circle.getOuterPath(rect), looksLikeC); expect(circle.getOuterPath(rect), looksLikeC);
expect(ShapeBorder.lerp(stadium, circle, 0.1).getOuterPath(rect), looksLikeS); expect(ShapeBorder.lerp(stadium, circle, 0.1)!.getOuterPath(rect), looksLikeS);
expect(ShapeBorder.lerp(stadium, circle, 0.9).getOuterPath(rect), looksLikeC); expect(ShapeBorder.lerp(stadium, circle, 0.9)!.getOuterPath(rect), looksLikeC);
expect(ShapeBorder.lerp(ShapeBorder.lerp(stadium, circle, 0.9), stadium, 0.1).getOuterPath(rect), looksLikeC); expect(ShapeBorder.lerp(ShapeBorder.lerp(stadium, circle, 0.9), stadium, 0.1)!.getOuterPath(rect), looksLikeC);
expect(ShapeBorder.lerp(ShapeBorder.lerp(stadium, circle, 0.9), stadium, 0.9).getOuterPath(rect), looksLikeS); expect(ShapeBorder.lerp(ShapeBorder.lerp(stadium, circle, 0.9), stadium, 0.9)!.getOuterPath(rect), looksLikeS);
expect(ShapeBorder.lerp(ShapeBorder.lerp(stadium, circle, 0.1), circle, 0.1).getOuterPath(rect), looksLikeS); expect(ShapeBorder.lerp(ShapeBorder.lerp(stadium, circle, 0.1), circle, 0.1)!.getOuterPath(rect), looksLikeS);
expect(ShapeBorder.lerp(ShapeBorder.lerp(stadium, circle, 0.1), circle, 0.9).getOuterPath(rect), looksLikeC); expect(ShapeBorder.lerp(ShapeBorder.lerp(stadium, circle, 0.1), circle, 0.9)!.getOuterPath(rect), looksLikeC);
expect(ShapeBorder.lerp(ShapeBorder.lerp(stadium, circle, 0.1), ShapeBorder.lerp(stadium, circle, 0.9), 0.1).getOuterPath(rect), looksLikeS); expect(ShapeBorder.lerp(ShapeBorder.lerp(stadium, circle, 0.1), ShapeBorder.lerp(stadium, circle, 0.9), 0.1)!.getOuterPath(rect), looksLikeS);
expect(ShapeBorder.lerp(ShapeBorder.lerp(stadium, circle, 0.1), ShapeBorder.lerp(stadium, circle, 0.9), 0.9).getOuterPath(rect), looksLikeC); expect(ShapeBorder.lerp(ShapeBorder.lerp(stadium, circle, 0.1), ShapeBorder.lerp(stadium, circle, 0.9), 0.9)!.getOuterPath(rect), looksLikeC);
expect(ShapeBorder.lerp(stadium, ShapeBorder.lerp(stadium, circle, 0.9), 0.1).getOuterPath(rect), looksLikeS); expect(ShapeBorder.lerp(stadium, ShapeBorder.lerp(stadium, circle, 0.9), 0.1)!.getOuterPath(rect), looksLikeS);
expect(ShapeBorder.lerp(stadium, ShapeBorder.lerp(stadium, circle, 0.9), 0.9).getOuterPath(rect), looksLikeC); expect(ShapeBorder.lerp(stadium, ShapeBorder.lerp(stadium, circle, 0.9), 0.9)!.getOuterPath(rect), looksLikeC);
expect(ShapeBorder.lerp(circle, ShapeBorder.lerp(stadium, circle, 0.1), 0.1).getOuterPath(rect), looksLikeC); expect(ShapeBorder.lerp(circle, ShapeBorder.lerp(stadium, circle, 0.1), 0.1)!.getOuterPath(rect), looksLikeC);
expect(ShapeBorder.lerp(circle, ShapeBorder.lerp(stadium, circle, 0.1), 0.9).getOuterPath(rect), looksLikeS); expect(ShapeBorder.lerp(circle, ShapeBorder.lerp(stadium, circle, 0.1), 0.9)!.getOuterPath(rect), looksLikeS);
expect(ShapeBorder.lerp(stadium, circle, 0.1).toString(), expect(ShapeBorder.lerp(stadium, circle, 0.1).toString(),
'StadiumBorder(BorderSide(Color(0xff000000), 0.0, BorderStyle.none), 10.0% of the way to being a CircleBorder)'); 'StadiumBorder(BorderSide(Color(0xff000000), 0.0, BorderStyle.none), 10.0% of the way to being a CircleBorder)');
...@@ -93,8 +91,8 @@ void main() { ...@@ -93,8 +91,8 @@ void main() {
expect(ShapeBorder.lerp(stadium, circle, 0.1), ShapeBorder.lerp(stadium, circle, 0.1)); expect(ShapeBorder.lerp(stadium, circle, 0.1), ShapeBorder.lerp(stadium, circle, 0.1));
expect(ShapeBorder.lerp(stadium, circle, 0.1).hashCode, ShapeBorder.lerp(stadium, circle, 0.1).hashCode); expect(ShapeBorder.lerp(stadium, circle, 0.1).hashCode, ShapeBorder.lerp(stadium, circle, 0.1).hashCode);
final ShapeBorder direct50 = ShapeBorder.lerp(stadium, circle, 0.5); final ShapeBorder direct50 = ShapeBorder.lerp(stadium, circle, 0.5)!;
final ShapeBorder indirect50 = ShapeBorder.lerp(ShapeBorder.lerp(circle, stadium, 0.1), ShapeBorder.lerp(circle, stadium, 0.9), 0.5); final ShapeBorder indirect50 = ShapeBorder.lerp(ShapeBorder.lerp(circle, stadium, 0.1), ShapeBorder.lerp(circle, stadium, 0.9), 0.5)!;
expect(direct50, indirect50); expect(direct50, indirect50);
expect(direct50.hashCode, indirect50.hashCode); expect(direct50.hashCode, indirect50.hashCode);
expect(direct50.toString(), indirect50.toString()); expect(direct50.toString(), indirect50.toString());
...@@ -130,18 +128,18 @@ void main() { ...@@ -130,18 +128,18 @@ void main() {
); );
expect(stadium.getOuterPath(rect), looksLikeS); expect(stadium.getOuterPath(rect), looksLikeS);
expect(rrect.getOuterPath(rect), looksLikeR); expect(rrect.getOuterPath(rect), looksLikeR);
expect(ShapeBorder.lerp(stadium, rrect, 0.1).getOuterPath(rect), looksLikeS); expect(ShapeBorder.lerp(stadium, rrect, 0.1)!.getOuterPath(rect), looksLikeS);
expect(ShapeBorder.lerp(stadium, rrect, 0.9).getOuterPath(rect), looksLikeR); expect(ShapeBorder.lerp(stadium, rrect, 0.9)!.getOuterPath(rect), looksLikeR);
expect(ShapeBorder.lerp(ShapeBorder.lerp(stadium, rrect, 0.9), stadium, 0.1).getOuterPath(rect), looksLikeR); expect(ShapeBorder.lerp(ShapeBorder.lerp(stadium, rrect, 0.9), stadium, 0.1)!.getOuterPath(rect), looksLikeR);
expect(ShapeBorder.lerp(ShapeBorder.lerp(stadium, rrect, 0.9), stadium, 0.9).getOuterPath(rect), looksLikeS); expect(ShapeBorder.lerp(ShapeBorder.lerp(stadium, rrect, 0.9), stadium, 0.9)!.getOuterPath(rect), looksLikeS);
expect(ShapeBorder.lerp(ShapeBorder.lerp(stadium, rrect, 0.1), rrect, 0.1).getOuterPath(rect), looksLikeS); expect(ShapeBorder.lerp(ShapeBorder.lerp(stadium, rrect, 0.1), rrect, 0.1)!.getOuterPath(rect), looksLikeS);
expect(ShapeBorder.lerp(ShapeBorder.lerp(stadium, rrect, 0.1), rrect, 0.9).getOuterPath(rect), looksLikeS); expect(ShapeBorder.lerp(ShapeBorder.lerp(stadium, rrect, 0.1), rrect, 0.9)!.getOuterPath(rect), looksLikeS);
expect(ShapeBorder.lerp(ShapeBorder.lerp(stadium, rrect, 0.1), ShapeBorder.lerp(stadium, rrect, 0.9), 0.1).getOuterPath(rect), looksLikeS); expect(ShapeBorder.lerp(ShapeBorder.lerp(stadium, rrect, 0.1), ShapeBorder.lerp(stadium, rrect, 0.9), 0.1)!.getOuterPath(rect), looksLikeS);
expect(ShapeBorder.lerp(ShapeBorder.lerp(stadium, rrect, 0.1), ShapeBorder.lerp(stadium, rrect, 0.9), 0.9).getOuterPath(rect), looksLikeR); expect(ShapeBorder.lerp(ShapeBorder.lerp(stadium, rrect, 0.1), ShapeBorder.lerp(stadium, rrect, 0.9), 0.9)!.getOuterPath(rect), looksLikeR);
expect(ShapeBorder.lerp(stadium, ShapeBorder.lerp(stadium, rrect, 0.9), 0.1).getOuterPath(rect), looksLikeS); expect(ShapeBorder.lerp(stadium, ShapeBorder.lerp(stadium, rrect, 0.9), 0.1)!.getOuterPath(rect), looksLikeS);
expect(ShapeBorder.lerp(stadium, ShapeBorder.lerp(stadium, rrect, 0.9), 0.9).getOuterPath(rect), looksLikeR); expect(ShapeBorder.lerp(stadium, ShapeBorder.lerp(stadium, rrect, 0.9), 0.9)!.getOuterPath(rect), looksLikeR);
expect(ShapeBorder.lerp(rrect, ShapeBorder.lerp(stadium, rrect, 0.1), 0.1).getOuterPath(rect), looksLikeS); expect(ShapeBorder.lerp(rrect, ShapeBorder.lerp(stadium, rrect, 0.1), 0.1)!.getOuterPath(rect), looksLikeS);
expect(ShapeBorder.lerp(rrect, ShapeBorder.lerp(stadium, rrect, 0.1), 0.9).getOuterPath(rect), looksLikeS); expect(ShapeBorder.lerp(rrect, ShapeBorder.lerp(stadium, rrect, 0.1), 0.9)!.getOuterPath(rect), looksLikeS);
expect(ShapeBorder.lerp(stadium, rrect, 0.1).toString(), expect(ShapeBorder.lerp(stadium, rrect, 0.1).toString(),
'StadiumBorder(BorderSide(Color(0xff000000), 0.0, BorderStyle.none), ' 'StadiumBorder(BorderSide(Color(0xff000000), 0.0, BorderStyle.none), '
...@@ -166,8 +164,8 @@ void main() { ...@@ -166,8 +164,8 @@ void main() {
expect(ShapeBorder.lerp(stadium, rrect, 0.1), ShapeBorder.lerp(stadium, rrect, 0.1)); expect(ShapeBorder.lerp(stadium, rrect, 0.1), ShapeBorder.lerp(stadium, rrect, 0.1));
expect(ShapeBorder.lerp(stadium, rrect, 0.1).hashCode, ShapeBorder.lerp(stadium, rrect, 0.1).hashCode); expect(ShapeBorder.lerp(stadium, rrect, 0.1).hashCode, ShapeBorder.lerp(stadium, rrect, 0.1).hashCode);
final ShapeBorder direct50 = ShapeBorder.lerp(stadium, rrect, 0.5); final ShapeBorder direct50 = ShapeBorder.lerp(stadium, rrect, 0.5)!;
final ShapeBorder indirect50 = ShapeBorder.lerp(ShapeBorder.lerp(rrect, stadium, 0.1), ShapeBorder.lerp(rrect, stadium, 0.9), 0.5); final ShapeBorder indirect50 = ShapeBorder.lerp(ShapeBorder.lerp(rrect, stadium, 0.1), ShapeBorder.lerp(rrect, stadium, 0.9), 0.5)!;
expect(direct50, indirect50); expect(direct50, indirect50);
expect(direct50.hashCode, indirect50.hashCode); expect(direct50.hashCode, indirect50.hashCode);
expect(direct50.toString(), indirect50.toString()); expect(direct50.toString(), indirect50.toString());
......
...@@ -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/painting.dart'; import 'package:flutter/painting.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/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -22,10 +20,10 @@ void main() { ...@@ -22,10 +20,10 @@ void main() {
const Map<String, dynamic> data = <String, dynamic>{ const Map<String, dynamic> data = <String, dynamic>{
'type': 'fontsChange', 'type': 'fontsChange',
}; };
await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage( await ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage(
'flutter/system', 'flutter/system',
SystemChannels.system.codec.encodeMessage(data), SystemChannels.system.codec.encodeMessage(data),
(ByteData data) { }, (ByteData? data) { },
); );
final RenderObject renderObject = tester.renderObject(find.text('text widget')); final RenderObject renderObject = tester.renderObject(find.text('text widget'));
expect(renderObject.debugNeedsLayout, isTrue); expect(renderObject.debugNeedsLayout, isTrue);
...@@ -40,10 +38,10 @@ void main() { ...@@ -40,10 +38,10 @@ void main() {
const Map<String, dynamic> data = <String, dynamic>{ const Map<String, dynamic> data = <String, dynamic>{
'type': 'fontsChange', 'type': 'fontsChange',
}; };
await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage( await ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage(
'flutter/system', 'flutter/system',
SystemChannels.system.codec.encodeMessage(data), SystemChannels.system.codec.encodeMessage(data),
(ByteData data) { }, (ByteData? data) { },
); );
final EditableTextState state = tester.state(find.byType(EditableText)); final EditableTextState state = tester.state(find.byType(EditableText));
expect(state.renderEditable.debugNeedsLayout, isTrue); expect(state.renderEditable.debugNeedsLayout, isTrue);
...@@ -61,10 +59,10 @@ void main() { ...@@ -61,10 +59,10 @@ void main() {
const Map<String, dynamic> data = <String, dynamic>{ const Map<String, dynamic> data = <String, dynamic>{
'type': 'fontsChange', 'type': 'fontsChange',
}; };
await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage( await ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage(
'flutter/system', 'flutter/system',
SystemChannels.system.codec.encodeMessage(data), SystemChannels.system.codec.encodeMessage(data),
(ByteData data) { }, (ByteData? data) { },
); );
final RenderObject renderObject = tester.renderObject(find.byType(Banner)); final RenderObject renderObject = tester.renderObject(find.byType(Banner));
expect(renderObject.debugNeedsPaint, isTrue); expect(renderObject.debugNeedsPaint, isTrue);
...@@ -78,16 +76,16 @@ void main() { ...@@ -78,16 +76,16 @@ void main() {
), ),
), ),
); );
final dynamic state = tester.state(find.byType(CupertinoDatePicker)); final dynamic state = tester.state(find.byType(CupertinoDatePicker)); // ignore: unnecessary_nullable_for_final_variable_declarations
final Map<int, double> cache = state.estimatedColumnWidths as Map<int, double>; final Map<int, double> cache = state.estimatedColumnWidths as Map<int, double>;
expect(cache.isNotEmpty, isTrue); expect(cache.isNotEmpty, isTrue);
const Map<String, dynamic> data = <String, dynamic>{ const Map<String, dynamic> data = <String, dynamic>{
'type': 'fontsChange', 'type': 'fontsChange',
}; };
await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage( await ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage(
'flutter/system', 'flutter/system',
SystemChannels.system.codec.encodeMessage(data), SystemChannels.system.codec.encodeMessage(data),
(ByteData data) { }, (ByteData? data) { },
); );
// Cache should be cleaned. // Cache should be cleaned.
expect(cache.isEmpty, isTrue); expect(cache.isEmpty, isTrue);
...@@ -104,17 +102,17 @@ void main() { ...@@ -104,17 +102,17 @@ void main() {
), ),
), ),
); );
final dynamic state = tester.state(find.byType(CupertinoDatePicker)); final dynamic state = tester.state(find.byType(CupertinoDatePicker)); // ignore: unnecessary_nullable_for_final_variable_declarations
final Map<int, double> cache = state.estimatedColumnWidths as Map<int, double>; final Map<int, double> cache = state.estimatedColumnWidths as Map<int, double>;
// Simulates font missing. // Simulates font missing.
cache.clear(); cache.clear();
const Map<String, dynamic> data = <String, dynamic>{ const Map<String, dynamic> data = <String, dynamic>{
'type': 'fontsChange', 'type': 'fontsChange',
}; };
await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage( await ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage(
'flutter/system', 'flutter/system',
SystemChannels.system.codec.encodeMessage(data), SystemChannels.system.codec.encodeMessage(data),
(ByteData data) { }, (ByteData? data) { },
); );
// Cache should be replenished // Cache should be replenished
expect(cache.isNotEmpty, isTrue); expect(cache.isNotEmpty, isTrue);
...@@ -130,7 +128,7 @@ void main() { ...@@ -130,7 +128,7 @@ void main() {
), ),
), ),
); );
final dynamic state = tester.state(find.byType(CupertinoTimerPicker)); final dynamic state = tester.state(find.byType(CupertinoTimerPicker)); // ignore: unnecessary_nullable_for_final_variable_declarations
// Simulates wrong metrics due to font missing. // Simulates wrong metrics due to font missing.
state.numberLabelWidth = 0.0; state.numberLabelWidth = 0.0;
state.numberLabelHeight = 0.0; state.numberLabelHeight = 0.0;
...@@ -138,10 +136,10 @@ void main() { ...@@ -138,10 +136,10 @@ void main() {
const Map<String, dynamic> data = <String, dynamic>{ const Map<String, dynamic> data = <String, dynamic>{
'type': 'fontsChange', 'type': 'fontsChange',
}; };
await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage( await ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage(
'flutter/system', 'flutter/system',
SystemChannels.system.codec.encodeMessage(data), SystemChannels.system.codec.encodeMessage(data),
(ByteData data) { }, (ByteData? data) { },
); );
// Metrics should be refreshed // Metrics should be refreshed
expect(state.numberLabelWidth - 46.0 < precisionErrorTolerance, isTrue); expect(state.numberLabelWidth - 46.0 < precisionErrorTolerance, isTrue);
...@@ -165,14 +163,14 @@ void main() { ...@@ -165,14 +163,14 @@ void main() {
const Map<String, dynamic> data = <String, dynamic>{ const Map<String, dynamic> data = <String, dynamic>{
'type': 'fontsChange', 'type': 'fontsChange',
}; };
await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage( await ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage(
'flutter/system', 'flutter/system',
SystemChannels.system.codec.encodeMessage(data), SystemChannels.system.codec.encodeMessage(data),
(ByteData data) { }, (ByteData? data) { },
); );
final RenderObject renderObject = tester.renderObject(find.byType(RangeSlider)); final RenderObject renderObject = tester.renderObject(find.byType(RangeSlider));
bool sliderBoxNeedsLayout; late bool sliderBoxNeedsLayout;
renderObject.visitChildren((RenderObject child) {sliderBoxNeedsLayout = child.debugNeedsLayout;}); renderObject.visitChildren((RenderObject child) {sliderBoxNeedsLayout = child.debugNeedsLayout;});
expect(sliderBoxNeedsLayout, isTrue); expect(sliderBoxNeedsLayout, isTrue);
}); });
...@@ -191,10 +189,10 @@ void main() { ...@@ -191,10 +189,10 @@ void main() {
const Map<String, dynamic> data = <String, dynamic>{ const Map<String, dynamic> data = <String, dynamic>{
'type': 'fontsChange', 'type': 'fontsChange',
}; };
await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage( await ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage(
'flutter/system', 'flutter/system',
SystemChannels.system.codec.encodeMessage(data), SystemChannels.system.codec.encodeMessage(data),
(ByteData data) { }, (ByteData? data) { },
); );
// _RenderSlider is the last render object in the tree. // _RenderSlider is the last render object in the tree.
final RenderObject renderObject = tester.allRenderObjects.last; final RenderObject renderObject = tester.allRenderObjects.last;
...@@ -214,11 +212,11 @@ void main() { ...@@ -214,11 +212,11 @@ void main() {
showTimePicker( showTimePicker(
context: context, context: context,
initialTime: const TimeOfDay(hour: 7, minute: 0), initialTime: const TimeOfDay(hour: 7, minute: 0),
builder: (BuildContext context, Widget child) { builder: (BuildContext context, Widget? child) {
return Directionality( return Directionality(
key: const Key('parent'), key: const Key('parent'),
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: child, child: child!,
); );
}, },
); );
...@@ -235,10 +233,10 @@ void main() { ...@@ -235,10 +233,10 @@ void main() {
const Map<String, dynamic> data = <String, dynamic>{ const Map<String, dynamic> data = <String, dynamic>{
'type': 'fontsChange', 'type': 'fontsChange',
}; };
await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage( await ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage(
'flutter/system', 'flutter/system',
SystemChannels.system.codec.encodeMessage(data), SystemChannels.system.codec.encodeMessage(data),
(ByteData data) { }, (ByteData? data) { },
); );
final RenderObject renderObject = tester.renderObject( final RenderObject renderObject = tester.renderObject(
find.descendant( find.descendant(
......
...@@ -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/painting.dart'; import 'package:flutter/painting.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -46,7 +44,7 @@ void main() { ...@@ -46,7 +44,7 @@ void main() {
style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0), style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0),
); );
TextSpan textSpan = painter.text as TextSpan; TextSpan textSpan = painter.text as TextSpan;
expect(textSpan.text.length, 28); expect(textSpan.text!.length, 28);
painter.layout(); painter.layout();
// The skips here are because the old rendering code considers the bidi formatting characters // The skips here are because the old rendering code considers the bidi formatting characters
...@@ -131,7 +129,7 @@ void main() { ...@@ -131,7 +129,7 @@ void main() {
textSpan = painter.text as TextSpan; textSpan = painter.text as TextSpan;
final List<List<TextBox>> list = <List<TextBox>>[ final List<List<TextBox>> list = <List<TextBox>>[
for (int index = 0; index < textSpan.text.length; index += 1) for (int index = 0; index < textSpan.text!.length; index += 1)
painter.getBoxesForSelection(TextSelection(baseOffset: index, extentOffset: index + 1)), painter.getBoxesForSelection(TextSelection(baseOffset: index, extentOffset: index + 1)),
]; ];
expect(list, const <List<TextBox>>[ expect(list, const <List<TextBox>>[
...@@ -178,7 +176,7 @@ void main() { ...@@ -178,7 +176,7 @@ void main() {
style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0), style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0),
); );
final TextSpan textSpan = painter.text as TextSpan; final TextSpan textSpan = painter.text as TextSpan;
expect(textSpan.text.length, 28); expect(textSpan.text!.length, 28);
painter.layout(); painter.layout();
final TextRange hebrew1 = painter.getWordBoundary(const TextPosition(offset: 4, affinity: TextAffinity.downstream)); final TextRange hebrew1 = painter.getWordBoundary(const TextPosition(offset: 4, affinity: TextAffinity.downstream));
...@@ -268,7 +266,7 @@ void main() { ...@@ -268,7 +266,7 @@ void main() {
style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0), style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0),
); );
final TextSpan textSpan = painter.text as TextSpan; final TextSpan textSpan = painter.text as TextSpan;
expect(textSpan.text.length, 2); expect(textSpan.text!.length, 2);
painter.layout(maxWidth: 10.0); painter.layout(maxWidth: 10.0);
for (int index = 0; index <= 2; index += 1) { for (int index = 0; index <= 2; index += 1) {
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
// 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/painting.dart'; import 'package:flutter/painting.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import '../flutter_test_alternative.dart' show Fake;
void main() { void main() {
test('TextPainter caret test', () { test('TextPainter caret test', () {
final TextPainter painter = TextPainter() final TextPainter painter = TextPainter()
...@@ -149,7 +149,7 @@ void main() { ...@@ -149,7 +149,7 @@ void main() {
test('TextPainter error test', () { test('TextPainter error test', () {
final TextPainter painter = TextPainter(textDirection: TextDirection.ltr); final TextPainter painter = TextPainter(textDirection: TextDirection.ltr);
expect(() { painter.paint(null, Offset.zero); }, anyOf(throwsFlutterError, throwsAssertionError)); expect(() { painter.paint(MockCanvas(), Offset.zero); }, anyOf(throwsFlutterError, throwsAssertionError));
}); });
test('TextPainter requires textDirection', () { test('TextPainter requires textDirection', () {
...@@ -730,19 +730,19 @@ void main() { ...@@ -730,19 +730,19 @@ void main() {
caretOffset = painter.getOffsetForCaret(const ui.TextPosition(offset: 23), ui.Rect.zero); caretOffset = painter.getOffsetForCaret(const ui.TextPosition(offset: 23), ui.Rect.zero);
expect(caretOffset.dx, 250); expect(caretOffset.dx, 250);
expect(painter.inlinePlaceholderBoxes.length, 14); expect(painter.inlinePlaceholderBoxes!.length, 14);
expect(painter.inlinePlaceholderBoxes[0], const TextBox.fromLTRBD(56, 0, 106, 30, TextDirection.ltr)); expect(painter.inlinePlaceholderBoxes![0], const TextBox.fromLTRBD(56, 0, 106, 30, TextDirection.ltr));
expect(painter.inlinePlaceholderBoxes[2], const TextBox.fromLTRBD(212, 0, 262, 30, TextDirection.ltr)); expect(painter.inlinePlaceholderBoxes![2], const TextBox.fromLTRBD(212, 0, 262, 30, TextDirection.ltr));
expect(painter.inlinePlaceholderBoxes[3], const TextBox.fromLTRBD(318, 0, 368, 30, TextDirection.ltr)); expect(painter.inlinePlaceholderBoxes![3], const TextBox.fromLTRBD(318, 0, 368, 30, TextDirection.ltr));
expect(painter.inlinePlaceholderBoxes[4], const TextBox.fromLTRBD(368, 0, 418, 30, TextDirection.ltr)); expect(painter.inlinePlaceholderBoxes![4], const TextBox.fromLTRBD(368, 0, 418, 30, TextDirection.ltr));
expect(painter.inlinePlaceholderBoxes[5], const TextBox.fromLTRBD(418, 0, 468, 30, TextDirection.ltr)); expect(painter.inlinePlaceholderBoxes![5], const TextBox.fromLTRBD(418, 0, 468, 30, TextDirection.ltr));
// line should break here // line should break here
expect(painter.inlinePlaceholderBoxes[6], const TextBox.fromLTRBD(0, 30, 50, 60, TextDirection.ltr)); expect(painter.inlinePlaceholderBoxes![6], const TextBox.fromLTRBD(0, 30, 50, 60, TextDirection.ltr));
expect(painter.inlinePlaceholderBoxes[7], const TextBox.fromLTRBD(50, 30, 100, 60, TextDirection.ltr)); expect(painter.inlinePlaceholderBoxes![7], const TextBox.fromLTRBD(50, 30, 100, 60, TextDirection.ltr));
expect(painter.inlinePlaceholderBoxes[10], const TextBox.fromLTRBD(200, 30, 250, 60, TextDirection.ltr)); expect(painter.inlinePlaceholderBoxes![10], const TextBox.fromLTRBD(200, 30, 250, 60, TextDirection.ltr));
expect(painter.inlinePlaceholderBoxes[11], const TextBox.fromLTRBD(250, 30, 300, 60, TextDirection.ltr)); expect(painter.inlinePlaceholderBoxes![11], const TextBox.fromLTRBD(250, 30, 300, 60, TextDirection.ltr));
expect(painter.inlinePlaceholderBoxes[12], const TextBox.fromLTRBD(300, 30, 351, 60, TextDirection.ltr)); expect(painter.inlinePlaceholderBoxes![12], const TextBox.fromLTRBD(300, 30, 351, 60, TextDirection.ltr));
expect(painter.inlinePlaceholderBoxes[13], const TextBox.fromLTRBD(351, 30, 401, 60, TextDirection.ltr)); expect(painter.inlinePlaceholderBoxes![13], const TextBox.fromLTRBD(351, 30, 401, 60, TextDirection.ltr));
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/42086 }, skip: isBrowser); // https://github.com/flutter/flutter/issues/42086
// Null values are valid. See https://github.com/flutter/flutter/pull/48346#issuecomment-584839221 // Null values are valid. See https://github.com/flutter/flutter/pull/48346#issuecomment-584839221
...@@ -830,7 +830,11 @@ void main() { ...@@ -830,7 +830,11 @@ void main() {
final double caretHeight = painter.getFullHeightForCaret( final double caretHeight = painter.getFullHeightForCaret(
const ui.TextPosition(offset: 0), const ui.TextPosition(offset: 0),
ui.Rect.zero, ui.Rect.zero,
); )!;
expect(caretHeight, 50.0); expect(caretHeight, 50.0);
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/56308 }, skip: isBrowser); // https://github.com/flutter/flutter/issues/56308
} }
class MockCanvas extends Fake implements Canvas {
}
...@@ -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/painting.dart'; import 'package:flutter/painting.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -234,15 +232,4 @@ void main() { ...@@ -234,15 +232,4 @@ void main() {
expect(textSpan.getSpanForPosition(const TextPosition(offset: 2)).runtimeType, WidgetSpan); expect(textSpan.getSpanForPosition(const TextPosition(offset: 2)).runtimeType, WidgetSpan);
expect(textSpan.getSpanForPosition(const TextPosition(offset: 3)).runtimeType, TextSpan); expect(textSpan.getSpanForPosition(const TextPosition(offset: 3)).runtimeType, TextSpan);
}); });
test('TextSpan with a null child should throw FlutterError', () {
const TextSpan text = TextSpan(
text: 'foo bar',
children: <InlineSpan>[
null,
],
);
expect(() => text.computeToPlainText(StringBuffer()), anyOf(throwsFlutterError, throwsAssertionError));
});
} }
...@@ -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 TextStyle, ParagraphStyle, FontFeature, Shadow; import 'dart:ui' as ui show TextStyle, ParagraphStyle, FontFeature, Shadow;
import 'package:flutter/painting.dart'; import 'package:flutter/painting.dart';
...@@ -96,7 +94,7 @@ void main() { ...@@ -96,7 +94,7 @@ void main() {
expect(s4.height, 123.0); expect(s4.height, 123.0);
expect(s4.color, const Color(0xFF00FF00)); expect(s4.color, const Color(0xFF00FF00));
final TextStyle s5 = TextStyle.lerp(s1, s3, 0.25); final TextStyle s5 = TextStyle.lerp(s1, s3, 0.25)!;
expect(s1.fontFamily, isNull); expect(s1.fontFamily, isNull);
expect(s1.fontSize, 10.0); expect(s1.fontSize, 10.0);
expect(s1.fontWeight, FontWeight.w800); expect(s1.fontWeight, FontWeight.w800);
...@@ -117,7 +115,7 @@ void main() { ...@@ -117,7 +115,7 @@ void main() {
expect(TextStyle.lerp(null, null, 0.5), isNull); expect(TextStyle.lerp(null, null, 0.5), isNull);
final TextStyle s6 = TextStyle.lerp(null, s3, 0.25); final TextStyle s6 = TextStyle.lerp(null, s3, 0.25)!;
expect(s3.fontFamily, isNull); expect(s3.fontFamily, isNull);
expect(s3.fontSize, 18.0); expect(s3.fontSize, 18.0);
expect(s3.fontWeight, FontWeight.w400); expect(s3.fontWeight, FontWeight.w400);
...@@ -130,7 +128,7 @@ void main() { ...@@ -130,7 +128,7 @@ void main() {
expect(s6.height, isNull); expect(s6.height, isNull);
expect(s6.color, isNull); expect(s6.color, isNull);
final TextStyle s7 = TextStyle.lerp(null, s3, 0.75); final TextStyle s7 = TextStyle.lerp(null, s3, 0.75)!;
expect(s3.fontFamily, isNull); expect(s3.fontFamily, isNull);
expect(s3.fontSize, 18.0); expect(s3.fontSize, 18.0);
expect(s3.fontWeight, FontWeight.w400); expect(s3.fontWeight, FontWeight.w400);
...@@ -143,7 +141,7 @@ void main() { ...@@ -143,7 +141,7 @@ void main() {
expect(s7.height, 123.0); expect(s7.height, 123.0);
expect(s7.color, isNull); expect(s7.color, isNull);
final TextStyle s8 = TextStyle.lerp(s3, null, 0.25); final TextStyle s8 = TextStyle.lerp(s3, null, 0.25)!;
expect(s3.fontFamily, isNull); expect(s3.fontFamily, isNull);
expect(s3.fontSize, 18.0); expect(s3.fontSize, 18.0);
expect(s3.fontWeight, FontWeight.w400); expect(s3.fontWeight, FontWeight.w400);
...@@ -156,7 +154,7 @@ void main() { ...@@ -156,7 +154,7 @@ void main() {
expect(s8.height, 123.0); expect(s8.height, 123.0);
expect(s8.color, isNull); expect(s8.color, isNull);
final TextStyle s9 = TextStyle.lerp(s3, null, 0.75); final TextStyle s9 = TextStyle.lerp(s3, null, 0.75)!;
expect(s3.fontFamily, isNull); expect(s3.fontFamily, isNull);
expect(s3.fontSize, 18.0); expect(s3.fontSize, 18.0);
expect(s3.fontWeight, FontWeight.w400); expect(s3.fontWeight, FontWeight.w400);
...@@ -201,9 +199,9 @@ void main() { ...@@ -201,9 +199,9 @@ void main() {
expect(s7.getTextStyle().toString(), 'TextStyle(color: unspecified, decoration: unspecified, decorationColor: unspecified, decorationStyle: unspecified, decorationThickness: unspecified, fontWeight: unspecified, fontStyle: unspecified, textBaseline: unspecified, fontFamily: packages/p/test, fontFamilyFallback: unspecified, fontSize: unspecified, letterSpacing: unspecified, wordSpacing: unspecified, height: unspecified, locale: unspecified, background: unspecified, foreground: unspecified, shadows: unspecified, fontFeatures: unspecified)'); expect(s7.getTextStyle().toString(), 'TextStyle(color: unspecified, decoration: unspecified, decorationColor: unspecified, decorationStyle: unspecified, decorationThickness: unspecified, fontWeight: unspecified, fontStyle: unspecified, textBaseline: unspecified, fontFamily: packages/p/test, fontFamilyFallback: unspecified, fontSize: unspecified, letterSpacing: unspecified, wordSpacing: unspecified, height: unspecified, locale: unspecified, background: unspecified, foreground: unspecified, shadows: unspecified, fontFeatures: unspecified)');
const TextStyle s8 = TextStyle(fontFamilyFallback: <String>['test', 'test2'], package: 'p'); const TextStyle s8 = TextStyle(fontFamilyFallback: <String>['test', 'test2'], package: 'p');
expect(s8.fontFamilyFallback[0], 'packages/p/test'); expect(s8.fontFamilyFallback![0], 'packages/p/test');
expect(s8.fontFamilyFallback[1], 'packages/p/test2'); expect(s8.fontFamilyFallback![1], 'packages/p/test2');
expect(s8.fontFamilyFallback.length, 2); expect(s8.fontFamilyFallback!.length, 2);
const TextStyle s9 = TextStyle(package: 'p'); const TextStyle s9 = TextStyle(package: 'p');
expect(s9.fontFamilyFallback, null); expect(s9.fontFamilyFallback, null);
...@@ -214,15 +212,15 @@ void main() { ...@@ -214,15 +212,15 @@ void main() {
test('TextStyle font family fallback', () { test('TextStyle font family fallback', () {
const TextStyle s1 = TextStyle(fontFamilyFallback: <String>['Roboto', 'test']); const TextStyle s1 = TextStyle(fontFamilyFallback: <String>['Roboto', 'test']);
expect(s1.fontFamilyFallback[0], 'Roboto'); expect(s1.fontFamilyFallback![0], 'Roboto');
expect(s1.fontFamilyFallback[1], 'test'); expect(s1.fontFamilyFallback![1], 'test');
expect(s1.fontFamilyFallback.length, 2); expect(s1.fontFamilyFallback!.length, 2);
const TextStyle s2 = TextStyle(fontFamily: 'foo', fontFamilyFallback: <String>['Roboto', 'test']); const TextStyle s2 = TextStyle(fontFamily: 'foo', fontFamilyFallback: <String>['Roboto', 'test']);
expect(s2.fontFamilyFallback[0], 'Roboto'); expect(s2.fontFamilyFallback![0], 'Roboto');
expect(s2.fontFamilyFallback[1], 'test'); expect(s2.fontFamilyFallback![1], 'test');
expect(s2.fontFamily, 'foo'); expect(s2.fontFamily, 'foo');
expect(s2.fontFamilyFallback.length, 2); expect(s2.fontFamilyFallback!.length, 2);
const TextStyle s3 = TextStyle(fontFamily: 'foo'); const TextStyle s3 = TextStyle(fontFamily: 'foo');
expect(s3.fontFamily, 'foo'); expect(s3.fontFamily, 'foo');
...@@ -231,7 +229,7 @@ void main() { ...@@ -231,7 +229,7 @@ void main() {
const TextStyle s4 = TextStyle(fontFamily: 'foo', fontFamilyFallback: <String>[]); const TextStyle s4 = TextStyle(fontFamily: 'foo', fontFamilyFallback: <String>[]);
expect(s4.fontFamily, 'foo'); expect(s4.fontFamily, 'foo');
expect(s4.fontFamilyFallback, <String>[]); expect(s4.fontFamilyFallback, <String>[]);
expect(s4.fontFamilyFallback.isEmpty, true); expect(s4.fontFamilyFallback!.isEmpty, true);
final ui.TextStyle uis1 = s2.getTextStyle(); final ui.TextStyle uis1 = s2.getTextStyle();
expect(uis1.toString(), 'TextStyle(color: unspecified, decoration: unspecified, decorationColor: unspecified, decorationStyle: unspecified, decorationThickness: unspecified, fontWeight: unspecified, fontStyle: unspecified, textBaseline: unspecified, fontFamily: foo, fontFamilyFallback: [Roboto, test], fontSize: unspecified, letterSpacing: unspecified, wordSpacing: unspecified, height: unspecified, locale: unspecified, background: unspecified, foreground: unspecified, shadows: unspecified, fontFeatures: unspecified)'); expect(uis1.toString(), 'TextStyle(color: unspecified, decoration: unspecified, decorationColor: unspecified, decorationStyle: unspecified, decorationThickness: unspecified, fontWeight: unspecified, fontStyle: unspecified, textBaseline: unspecified, fontFamily: foo, fontFamilyFallback: [Roboto, test], fontSize: unspecified, letterSpacing: unspecified, wordSpacing: unspecified, height: unspecified, locale: unspecified, background: unspecified, foreground: unspecified, shadows: unspecified, fontFeatures: unspecified)');
...@@ -259,8 +257,8 @@ void main() { ...@@ -259,8 +257,8 @@ void main() {
expect(foo.merge(bar).merge(baz).debugLabel, '((foo).merge(bar)).merge(baz)'); expect(foo.merge(bar).merge(baz).debugLabel, '((foo).merge(bar)).merge(baz)');
expect(foo.copyWith().debugLabel, '(foo).copyWith'); expect(foo.copyWith().debugLabel, '(foo).copyWith');
expect(foo.apply().debugLabel, '(foo).apply'); expect(foo.apply().debugLabel, '(foo).apply');
expect(TextStyle.lerp(foo, bar, 0.5).debugLabel, 'lerp(foo ⎯0.5→ bar)'); expect(TextStyle.lerp(foo, bar, 0.5)!.debugLabel, 'lerp(foo ⎯0.5→ bar)');
expect(TextStyle.lerp(foo.merge(bar), baz, 0.51).copyWith().debugLabel, '(lerp((foo).merge(bar) ⎯0.5→ baz)).copyWith'); expect(TextStyle.lerp(foo.merge(bar), baz, 0.51)!.copyWith().debugLabel, '(lerp((foo).merge(bar) ⎯0.5→ baz)).copyWith');
}); });
test('TextStyle.hashCode', () { test('TextStyle.hashCode', () {
...@@ -297,18 +295,18 @@ void main() { ...@@ -297,18 +295,18 @@ void main() {
// apply // apply
expect(redPaintTextStyle.apply(color: blue).color, isNull); expect(redPaintTextStyle.apply(color: blue).color, isNull);
expect(redPaintTextStyle.apply(color: blue).foreground.color, red); expect(redPaintTextStyle.apply(color: blue).foreground!.color, red);
expect(redTextStyle.apply(color: blue).color, blue); expect(redTextStyle.apply(color: blue).color, blue);
// lerp // lerp
expect(TextStyle.lerp(redTextStyle, blueTextStyle, .25).color, Color.lerp(red, blue, .25)); expect(TextStyle.lerp(redTextStyle, blueTextStyle, .25)!.color, Color.lerp(red, blue, .25));
expect(TextStyle.lerp(redTextStyle, bluePaintTextStyle, .25).color, isNull); expect(TextStyle.lerp(redTextStyle, bluePaintTextStyle, .25)!.color, isNull);
expect(TextStyle.lerp(redTextStyle, bluePaintTextStyle, .25).foreground.color, red); expect(TextStyle.lerp(redTextStyle, bluePaintTextStyle, .25)!.foreground!.color, red);
expect(TextStyle.lerp(redTextStyle, bluePaintTextStyle, .75).foreground.color, blue); expect(TextStyle.lerp(redTextStyle, bluePaintTextStyle, .75)!.foreground!.color, blue);
expect(TextStyle.lerp(redPaintTextStyle, bluePaintTextStyle, .25).color, isNull); expect(TextStyle.lerp(redPaintTextStyle, bluePaintTextStyle, .25)!.color, isNull);
expect(TextStyle.lerp(redPaintTextStyle, bluePaintTextStyle, .25).foreground.color, red); expect(TextStyle.lerp(redPaintTextStyle, bluePaintTextStyle, .25)!.foreground!.color, red);
expect(TextStyle.lerp(redPaintTextStyle, bluePaintTextStyle, .75).foreground.color, blue); expect(TextStyle.lerp(redPaintTextStyle, bluePaintTextStyle, .75)!.foreground!.color, blue);
}); });
test('backgroundColor', () { test('backgroundColor', () {
...@@ -351,18 +349,18 @@ void main() { ...@@ -351,18 +349,18 @@ void main() {
// apply // apply
expect(redPaintTextStyle.apply(backgroundColor: blue).backgroundColor, isNull); expect(redPaintTextStyle.apply(backgroundColor: blue).backgroundColor, isNull);
expect(redPaintTextStyle.apply(backgroundColor: blue).background.color, red); expect(redPaintTextStyle.apply(backgroundColor: blue).background!.color, red);
expect(redTextStyle.apply(backgroundColor: blue).backgroundColor, blue); expect(redTextStyle.apply(backgroundColor: blue).backgroundColor, blue);
// lerp // lerp
expect(TextStyle.lerp(redTextStyle, blueTextStyle, .25).backgroundColor, Color.lerp(red, blue, .25)); expect(TextStyle.lerp(redTextStyle, blueTextStyle, .25)!.backgroundColor, Color.lerp(red, blue, .25));
expect(TextStyle.lerp(redTextStyle, bluePaintTextStyle, .25).backgroundColor, isNull); expect(TextStyle.lerp(redTextStyle, bluePaintTextStyle, .25)!.backgroundColor, isNull);
expect(TextStyle.lerp(redTextStyle, bluePaintTextStyle, .25).background.color, red); expect(TextStyle.lerp(redTextStyle, bluePaintTextStyle, .25)!.background!.color, red);
expect(TextStyle.lerp(redTextStyle, bluePaintTextStyle, .75).background.color, blue); expect(TextStyle.lerp(redTextStyle, bluePaintTextStyle, .75)!.background!.color, blue);
expect(TextStyle.lerp(redPaintTextStyle, bluePaintTextStyle, .25).backgroundColor, isNull); expect(TextStyle.lerp(redPaintTextStyle, bluePaintTextStyle, .25)!.backgroundColor, isNull);
expect(TextStyle.lerp(redPaintTextStyle, bluePaintTextStyle, .25).background.color, red); expect(TextStyle.lerp(redPaintTextStyle, bluePaintTextStyle, .25)!.background!.color, red);
expect(TextStyle.lerp(redPaintTextStyle, bluePaintTextStyle, .75).background.color, blue); expect(TextStyle.lerp(redPaintTextStyle, bluePaintTextStyle, .75)!.background!.color, blue);
}); });
test('TextStyle strut textScaleFactor', () { test('TextStyle strut textScaleFactor', () {
......
...@@ -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 'package:flutter/widgets.dart'; import 'package:flutter/widgets.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/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';
......
...@@ -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 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -70,12 +68,12 @@ void main() { ...@@ -70,12 +68,12 @@ void main() {
minHeight: 11.0, minHeight: 11.0,
maxHeight: 17.0, maxHeight: 17.0,
); );
BoxConstraints copy = BoxConstraints.lerp(null, constraints, 0.5); BoxConstraints copy = BoxConstraints.lerp(null, constraints, 0.5)!;
expect(copy.minWidth, moreOrLessEquals(1.5)); expect(copy.minWidth, moreOrLessEquals(1.5));
expect(copy.maxWidth, moreOrLessEquals(3.5)); expect(copy.maxWidth, moreOrLessEquals(3.5));
expect(copy.minHeight, moreOrLessEquals(5.5)); expect(copy.minHeight, moreOrLessEquals(5.5));
expect(copy.maxHeight, moreOrLessEquals(8.5)); expect(copy.maxHeight, moreOrLessEquals(8.5));
copy = BoxConstraints.lerp(constraints, null, 0.5); copy = BoxConstraints.lerp(constraints, null, 0.5)!;
expect(copy.minWidth, moreOrLessEquals(1.5)); expect(copy.minWidth, moreOrLessEquals(1.5));
expect(copy.maxWidth, moreOrLessEquals(3.5)); expect(copy.maxWidth, moreOrLessEquals(3.5));
expect(copy.minHeight, moreOrLessEquals(5.5)); expect(copy.minHeight, moreOrLessEquals(5.5));
...@@ -85,7 +83,7 @@ void main() { ...@@ -85,7 +83,7 @@ void main() {
maxWidth: 17.0, maxWidth: 17.0,
minHeight: 111.0, minHeight: 111.0,
maxHeight: 117.0, maxHeight: 117.0,
), constraints, 0.2); ), constraints, 0.2)!;
expect(copy.minWidth, moreOrLessEquals(11.0)); expect(copy.minWidth, moreOrLessEquals(11.0));
expect(copy.maxWidth, moreOrLessEquals(15.0)); expect(copy.maxWidth, moreOrLessEquals(15.0));
expect(copy.minHeight, moreOrLessEquals(91.0)); expect(copy.minHeight, moreOrLessEquals(91.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/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -46,7 +44,7 @@ void main() { ...@@ -46,7 +44,7 @@ void main() {
gradient: RadialGradient( gradient: RadialGradient(
center: Alignment.topLeft, center: Alignment.topLeft,
radius: 1.8, radius: 1.8,
colors: <Color>[Colors.yellow[500], Colors.blue[500]], colors: <Color>[Colors.yellow[500]!, Colors.blue[500]!],
), ),
boxShadow: kElevationToShadow[3], boxShadow: kElevationToShadow[3],
), ),
...@@ -57,7 +55,7 @@ void main() { ...@@ -57,7 +55,7 @@ void main() {
}); });
test('performLayout error message', () { test('performLayout error message', () {
FlutterError result; late FlutterError result;
try { try {
MissingPerformLayoutRenderBox().performLayout(); MissingPerformLayoutRenderBox().performLayout();
} on FlutterError catch (e) { } on FlutterError catch (e) {
...@@ -95,7 +93,7 @@ void main() { ...@@ -95,7 +93,7 @@ void main() {
// BoxParentData. // BoxParentData.
paddingBox.parentData = ParentData(); paddingBox.parentData = ParentData();
FlutterError result; late FlutterError result;
try { try {
root.applyPaintTransform(paddingBox, Matrix4.identity()); root.applyPaintTransform(paddingBox, Matrix4.identity());
} on FlutterError catch (e) { } on FlutterError catch (e) {
...@@ -151,7 +149,7 @@ void main() { ...@@ -151,7 +149,7 @@ void main() {
final MissingPerformLayoutRenderBox testBox = MissingPerformLayoutRenderBox(); final MissingPerformLayoutRenderBox testBox = MissingPerformLayoutRenderBox();
{ {
FlutterError result; late FlutterError result;
try { try {
testBox.triggerExceptionSettingSizeOutsideOfLayout(); testBox.triggerExceptionSettingSizeOutsideOfLayout();
} on FlutterError catch (e) { } on FlutterError catch (e) {
...@@ -173,7 +171,7 @@ void main() { ...@@ -173,7 +171,7 @@ void main() {
expect(result.diagnostics.where((DiagnosticsNode node) => node.level == DiagnosticLevel.hint), isEmpty); expect(result.diagnostics.where((DiagnosticsNode node) => node.level == DiagnosticLevel.hint), isEmpty);
} }
{ {
FlutterError result; late FlutterError result;
try { try {
testBox.debugAdoptSize(root.size); testBox.debugAdoptSize(root.size);
} on FlutterError catch (e) { } on FlutterError catch (e) {
...@@ -392,7 +390,7 @@ void main() { ...@@ -392,7 +390,7 @@ void main() {
layout(unconstrained, constraints: viewport); layout(unconstrained, constraints: viewport);
{ {
FlutterError result; late FlutterError result;
try { try {
unconstrained.getMinIntrinsicWidth(-1); unconstrained.getMinIntrinsicWidth(-1);
} on FlutterError catch (e) { } on FlutterError catch (e) {
...@@ -420,7 +418,7 @@ void main() { ...@@ -420,7 +418,7 @@ void main() {
} }
{ {
FlutterError result; late FlutterError result;
try { try {
unconstrained.getMinIntrinsicHeight(-1); unconstrained.getMinIntrinsicHeight(-1);
} on FlutterError catch (e) { } on FlutterError catch (e) {
...@@ -448,7 +446,7 @@ void main() { ...@@ -448,7 +446,7 @@ void main() {
} }
{ {
FlutterError result; late FlutterError result;
try { try {
unconstrained.getMaxIntrinsicWidth(-1); unconstrained.getMaxIntrinsicWidth(-1);
} on FlutterError catch (e) { } on FlutterError catch (e) {
...@@ -476,7 +474,7 @@ void main() { ...@@ -476,7 +474,7 @@ void main() {
} }
{ {
FlutterError result; late FlutterError result;
try { try {
unconstrained.getMaxIntrinsicHeight(-1); unconstrained.getMaxIntrinsicHeight(-1);
} on FlutterError catch (e) { } on FlutterError catch (e) {
...@@ -934,7 +932,7 @@ void main() { ...@@ -934,7 +932,7 @@ void main() {
final RenderBox renderObject = RenderConstrainedBox( final RenderBox renderObject = RenderConstrainedBox(
additionalConstraints: const BoxConstraints().tighten(height: 100.0), additionalConstraints: const BoxConstraints().tighten(height: 100.0),
); );
FlutterError result; late FlutterError result;
try { try {
final BoxHitTestResult result = BoxHitTestResult(); final BoxHitTestResult result = BoxHitTestResult();
renderObject.hitTest(result, position: Offset.zero); renderObject.hitTest(result, position: Offset.zero);
...@@ -971,7 +969,7 @@ void main() { ...@@ -971,7 +969,7 @@ void main() {
} }
{ {
FlutterError result; late FlutterError result;
final FakeMissingSizeRenderBox renderObject = FakeMissingSizeRenderBox(); final FakeMissingSizeRenderBox renderObject = FakeMissingSizeRenderBox();
layout(renderObject); layout(renderObject);
renderObject.fakeMissingSize = true; renderObject.fakeMissingSize = true;
...@@ -1019,16 +1017,9 @@ void main() { ...@@ -1019,16 +1017,9 @@ void main() {
}); });
}); });
test('BoxConstraints parameters should be non-null', () {
expect(() => BoxConstraints(minWidth: null), throwsAssertionError);
expect(() => BoxConstraints(maxWidth: null), throwsAssertionError);
expect(() => BoxConstraints(minHeight: null), throwsAssertionError);
expect(() => BoxConstraints(maxHeight: null), throwsAssertionError);
});
test('Error message when size has not been set in RenderBox performLayout should be well versed', () { test('Error message when size has not been set in RenderBox performLayout should be well versed', () {
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;
}; };
......
...@@ -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 '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_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:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.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';
...@@ -33,7 +31,7 @@ class RenderFixedSize extends RenderBox { ...@@ -33,7 +31,7 @@ class RenderFixedSize extends RenderBox {
} }
class RenderParentSize extends RenderProxyBox { class RenderParentSize extends RenderProxyBox {
RenderParentSize({ RenderBox child }) : super(child); RenderParentSize({ required RenderBox child }) : super(child);
@override @override
bool get sizedByParent => true; bool get sizedByParent => true;
...@@ -45,19 +43,19 @@ class RenderParentSize extends RenderProxyBox { ...@@ -45,19 +43,19 @@ class RenderParentSize extends RenderProxyBox {
@override @override
void performLayout() { void performLayout() {
child.layout(constraints); child!.layout(constraints);
} }
} }
class RenderIntrinsicSize extends RenderProxyBox { class RenderIntrinsicSize extends RenderProxyBox {
RenderIntrinsicSize({ RenderBox child }) : super(child); RenderIntrinsicSize({ required RenderBox child }) : super(child);
@override @override
void performLayout() { void performLayout() {
child.layout(constraints); child!.layout(constraints);
size = Size( size = Size(
child.getMinIntrinsicWidth(double.infinity), child!.getMinIntrinsicWidth(double.infinity),
child.getMinIntrinsicHeight(double.infinity), child!.getMinIntrinsicHeight(double.infinity),
); );
} }
} }
......
...@@ -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/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
...@@ -42,7 +40,7 @@ void main() { ...@@ -42,7 +40,7 @@ void main() {
editable.layout(BoxConstraints.loose(const Size(1000.0, 1000.0))); editable.layout(BoxConstraints.loose(const Size(1000.0, 1000.0)));
final PipelineOwner owner = PipelineOwner(onNeedVisualUpdate: () { }); final PipelineOwner owner = PipelineOwner(onNeedVisualUpdate: () { });
final _PointerRouterSpy spy = GestureBinding.instance.pointerRouter as _PointerRouterSpy; final _PointerRouterSpy spy = GestureBinding.instance!.pointerRouter as _PointerRouterSpy;
editable.attach(owner); editable.attach(owner);
// This should register pointer into GestureBinding.instance.pointerRouter. // This should register pointer into GestureBinding.instance.pointerRouter.
editable.handleEvent(const PointerDownEvent(), BoxHitTestEntry(editable, const Offset(10,10))); editable.handleEvent(const PointerDownEvent(), BoxHitTestEntry(editable, const Offset(10,10)));
...@@ -64,7 +62,7 @@ class FakeEditableTextState extends TextSelectionDelegate with Fake { } ...@@ -64,7 +62,7 @@ class FakeEditableTextState extends TextSelectionDelegate with Fake { }
class _PointerRouterSpy extends PointerRouter { class _PointerRouterSpy extends PointerRouter {
int routeCount = 0; int routeCount = 0;
@override @override
void addRoute(int pointer, PointerRoute route, [Matrix4 transform]) { void addRoute(int pointer, PointerRoute route, [Matrix4? transform]) {
super.addRoute(pointer, route, transform); super.addRoute(pointer, route, transform);
routeCount++; routeCount++;
} }
......
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