forked from firka/flutter
Fix leaky test. (#153780)
This commit is contained in:
committed by
GitHub
parent
b53b285f3d
commit
ba7d7d5bb1
@@ -14,13 +14,9 @@ import 'dart:ui' as ui;
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('ImageDecoration.lerp',
|
||||
// TODO(polina-c): make sure images are disposed, https://github.com/flutter/flutter/issues/141388 [leaks-to-clean]
|
||||
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('ImageDecoration.lerp 1', (WidgetTester tester) async {
|
||||
final MemoryImage green = MemoryImage(Uint8List.fromList(<int>[
|
||||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
|
||||
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x00, 0x00, 0x00, 0x25, 0xdb, 0x56,
|
||||
@@ -38,9 +34,12 @@ void main() {
|
||||
0x60, 0x82,
|
||||
]));
|
||||
|
||||
late final _ImageLoader greenLoader = _ImageLoader(green);
|
||||
late final _ImageLoader redLoader = _ImageLoader(red);
|
||||
|
||||
await tester.runAsync(() async {
|
||||
await load(green);
|
||||
await load(red);
|
||||
await greenLoader.load();
|
||||
await redLoader.load();
|
||||
});
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -52,49 +51,49 @@ void main() {
|
||||
child: Wrap(
|
||||
textDirection: TextDirection.ltr,
|
||||
children: <Widget>[
|
||||
TestImage(
|
||||
_TestImage(
|
||||
DecorationImage(image: green, repeat: ImageRepeat.repeat)
|
||||
),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: green, repeat: ImageRepeat.repeat),
|
||||
DecorationImage(image: red, repeat: ImageRepeat.repeat),
|
||||
0.0,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: green, repeat: ImageRepeat.repeat),
|
||||
DecorationImage(image: red, repeat: ImageRepeat.repeat),
|
||||
0.1,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: green, repeat: ImageRepeat.repeat),
|
||||
DecorationImage(image: red, repeat: ImageRepeat.repeat),
|
||||
0.2,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: green, repeat: ImageRepeat.repeat),
|
||||
DecorationImage(image: red, repeat: ImageRepeat.repeat),
|
||||
0.5,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: green, repeat: ImageRepeat.repeat),
|
||||
DecorationImage(image: red, repeat: ImageRepeat.repeat),
|
||||
0.8,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: green, repeat: ImageRepeat.repeat),
|
||||
DecorationImage(image: red, repeat: ImageRepeat.repeat),
|
||||
0.9,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: green, repeat: ImageRepeat.repeat),
|
||||
DecorationImage(image: red, repeat: ImageRepeat.repeat),
|
||||
1.0,
|
||||
)),
|
||||
TestImage(
|
||||
_TestImage(
|
||||
DecorationImage(image: red, repeat: ImageRepeat.repeat),
|
||||
),
|
||||
for (double t = 0.0; t < 1.0; t += 0.125)
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage.lerp(
|
||||
DecorationImage(image: green, repeat: ImageRepeat.repeat),
|
||||
DecorationImage(image: green, repeat: ImageRepeat.repeat),
|
||||
@@ -108,7 +107,7 @@ void main() {
|
||||
t,
|
||||
)),
|
||||
for (double t = 0.0; t < 1.0; t += 0.125)
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage.lerp(
|
||||
DecorationImage(image: green, repeat: ImageRepeat.repeat),
|
||||
DecorationImage(image: green, repeat: ImageRepeat.repeat),
|
||||
@@ -122,7 +121,7 @@ void main() {
|
||||
t,
|
||||
)),
|
||||
for (double t = 0.0; t < 1.0; t += 0.125)
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage.lerp(
|
||||
DecorationImage(image: green, repeat: ImageRepeat.repeat),
|
||||
DecorationImage(image: green, repeat: ImageRepeat.repeat),
|
||||
@@ -136,7 +135,7 @@ void main() {
|
||||
t,
|
||||
)),
|
||||
for (double t = 0.0; t < 1.0; t += 0.125)
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage.lerp(
|
||||
DecorationImage(image: green, repeat: ImageRepeat.repeat),
|
||||
DecorationImage(image: green, repeat: ImageRepeat.repeat),
|
||||
@@ -192,12 +191,13 @@ void main() {
|
||||
expect(getBlockPixel(index), lime);
|
||||
}
|
||||
}
|
||||
|
||||
greenLoader.dispose();
|
||||
redLoader.dispose();
|
||||
imageCache.clear();
|
||||
}, skip: kIsWeb); // TODO(ianh): https://github.com/flutter/flutter/issues/130612, https://github.com/flutter/flutter/issues/130609
|
||||
|
||||
testWidgets('ImageDecoration.lerp',
|
||||
// TODO(polina-c): make sure images are disposed, https://github.com/flutter/flutter/issues/141388 [leaks-to-clean]
|
||||
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('ImageDecoration.lerp 2', (WidgetTester tester) async {
|
||||
final MemoryImage cmyk = MemoryImage(Uint8List.fromList(<int>[
|
||||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
|
||||
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x02, 0x03, 0x00, 0x00, 0x00, 0xd4, 0x9f, 0x76,
|
||||
@@ -215,9 +215,12 @@ void main() {
|
||||
0x78, 0x1d, 0x41, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
|
||||
]));
|
||||
|
||||
late final _ImageLoader cmykLoader = _ImageLoader(cmyk);
|
||||
late final _ImageLoader wrgbLoader = _ImageLoader(wrgb);
|
||||
|
||||
await tester.runAsync(() async {
|
||||
await load(cmyk);
|
||||
await load(wrgb);
|
||||
await cmykLoader.load();
|
||||
await wrgbLoader.load();
|
||||
});
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -229,122 +232,122 @@ void main() {
|
||||
child: Wrap(
|
||||
textDirection: TextDirection.ltr,
|
||||
children: <Widget>[
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, fit: BoxFit.contain),
|
||||
DecorationImage(image: cmyk, fit: BoxFit.contain),
|
||||
0.0,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, fit: BoxFit.contain),
|
||||
DecorationImage(image: cmyk, fit: BoxFit.contain),
|
||||
0.1,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, fit: BoxFit.contain),
|
||||
DecorationImage(image: cmyk, fit: BoxFit.contain),
|
||||
0.2,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, fit: BoxFit.contain),
|
||||
DecorationImage(image: cmyk, fit: BoxFit.contain),
|
||||
0.5,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, fit: BoxFit.contain),
|
||||
DecorationImage(image: cmyk, fit: BoxFit.contain),
|
||||
0.8,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, fit: BoxFit.contain),
|
||||
DecorationImage(image: cmyk, fit: BoxFit.contain),
|
||||
0.9,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, fit: BoxFit.contain),
|
||||
DecorationImage(image: cmyk, fit: BoxFit.contain),
|
||||
1.0,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, fit: BoxFit.cover),
|
||||
DecorationImage(image: cmyk, repeat: ImageRepeat.repeat),
|
||||
0.5,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, repeat: ImageRepeat.repeat),
|
||||
DecorationImage(image: cmyk, repeat: ImageRepeat.repeatY),
|
||||
0.5,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, repeat: ImageRepeat.repeatX),
|
||||
DecorationImage(image: cmyk, repeat: ImageRepeat.repeat),
|
||||
0.5,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, repeat: ImageRepeat.repeat, opacity: 0.2),
|
||||
DecorationImage(image: cmyk, repeat: ImageRepeat.repeat, opacity: 0.2),
|
||||
0.25,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, repeat: ImageRepeat.repeat, opacity: 0.2),
|
||||
DecorationImage(image: cmyk, repeat: ImageRepeat.repeat, opacity: 0.2),
|
||||
0.5,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, repeat: ImageRepeat.repeat, opacity: 0.2),
|
||||
DecorationImage(image: cmyk, repeat: ImageRepeat.repeat, opacity: 0.2),
|
||||
0.75,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, scale: 0.5, repeat: ImageRepeat.repeatX),
|
||||
DecorationImage(image: cmyk, scale: 0.25, repeat: ImageRepeat.repeatY),
|
||||
0.5,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
0.0,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
0.25,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
0.5,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
0.75,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
1.0,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(0.0, 0.0, 1.0, 1.0)),
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
0.0,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(0.0, 0.0, 1.0, 1.0)),
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
0.25,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(0.0, 0.0, 1.0, 1.0)),
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
0.5,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(0.0, 0.0, 1.0, 1.0)),
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
0.75,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(0.0, 0.0, 1.0, 1.0)),
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
1.0,
|
||||
@@ -413,12 +416,13 @@ void main() {
|
||||
expect(getPixelFromBlock(19, 18, 18), const Color(0xFF000000));
|
||||
expect(getPixelFromBlock(19, 19, 19), const Color(0xFF000000));
|
||||
}
|
||||
|
||||
cmykLoader.dispose();
|
||||
wrgbLoader.dispose();
|
||||
imageCache.clear();
|
||||
}, skip: kIsWeb); // TODO(ianh): https://github.com/flutter/flutter/issues/130612, https://github.com/flutter/flutter/issues/130609
|
||||
|
||||
testWidgets('ImageDecoration.lerp with colored background',
|
||||
// TODO(polina-c): make sure images are disposed, https://github.com/flutter/flutter/issues/141388 [leaks-to-clean]
|
||||
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('ImageDecoration.lerp with colored background', (WidgetTester tester) async {
|
||||
final MemoryImage cmyk = MemoryImage(Uint8List.fromList(<int>[
|
||||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
|
||||
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x02, 0x03, 0x00, 0x00, 0x00, 0xd4, 0x9f, 0x76,
|
||||
@@ -436,9 +440,12 @@ void main() {
|
||||
0x78, 0x1d, 0x41, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
|
||||
]));
|
||||
|
||||
late final _ImageLoader cmykLoader = _ImageLoader(cmyk);
|
||||
late final _ImageLoader wrgbLoader = _ImageLoader(wrgb);
|
||||
|
||||
await tester.runAsync(() async {
|
||||
await load(cmyk);
|
||||
await load(wrgb);
|
||||
await cmykLoader.load();
|
||||
await wrgbLoader.load();
|
||||
});
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -449,122 +456,122 @@ void main() {
|
||||
child: Wrap(
|
||||
textDirection: TextDirection.ltr,
|
||||
children: <Widget>[
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, fit: BoxFit.contain),
|
||||
DecorationImage(image: cmyk, fit: BoxFit.contain),
|
||||
0.0,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, fit: BoxFit.contain),
|
||||
DecorationImage(image: cmyk, fit: BoxFit.contain),
|
||||
0.1,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, fit: BoxFit.contain),
|
||||
DecorationImage(image: cmyk, fit: BoxFit.contain),
|
||||
0.2,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, fit: BoxFit.contain),
|
||||
DecorationImage(image: cmyk, fit: BoxFit.contain),
|
||||
0.5,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, fit: BoxFit.contain),
|
||||
DecorationImage(image: cmyk, fit: BoxFit.contain),
|
||||
0.8,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, fit: BoxFit.contain),
|
||||
DecorationImage(image: cmyk, fit: BoxFit.contain),
|
||||
0.9,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, fit: BoxFit.contain),
|
||||
DecorationImage(image: cmyk, fit: BoxFit.contain),
|
||||
1.0,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, fit: BoxFit.cover),
|
||||
DecorationImage(image: cmyk, repeat: ImageRepeat.repeat),
|
||||
0.5,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, repeat: ImageRepeat.repeat),
|
||||
DecorationImage(image: cmyk, repeat: ImageRepeat.repeatY),
|
||||
0.5,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, repeat: ImageRepeat.repeatX),
|
||||
DecorationImage(image: cmyk, repeat: ImageRepeat.repeat),
|
||||
0.5,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, repeat: ImageRepeat.repeat, opacity: 0.2),
|
||||
DecorationImage(image: cmyk, repeat: ImageRepeat.repeat, opacity: 0.2),
|
||||
0.25,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, repeat: ImageRepeat.repeat, opacity: 0.2),
|
||||
DecorationImage(image: cmyk, repeat: ImageRepeat.repeat, opacity: 0.2),
|
||||
0.5,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, repeat: ImageRepeat.repeat, opacity: 0.2),
|
||||
DecorationImage(image: cmyk, repeat: ImageRepeat.repeat, opacity: 0.2),
|
||||
0.75,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: wrgb, scale: 0.5, repeat: ImageRepeat.repeatX),
|
||||
DecorationImage(image: cmyk, scale: 0.25, repeat: ImageRepeat.repeatY),
|
||||
0.5,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
0.0,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
0.25,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
0.5,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
0.75,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
1.0,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(0.0, 0.0, 1.0, 1.0)),
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
0.0,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(0.0, 0.0, 1.0, 1.0)),
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
0.25,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(0.0, 0.0, 1.0, 1.0)),
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
0.5,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(0.0, 0.0, 1.0, 1.0)),
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
0.75,
|
||||
)),
|
||||
TestImage(DecorationImage.lerp(
|
||||
_TestImage(DecorationImage.lerp(
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(0.0, 0.0, 1.0, 1.0)),
|
||||
DecorationImage(image: cmyk, centerSlice: const Rect.fromLTWH(2.0, 2.0, 1.0, 1.0)),
|
||||
1.0,
|
||||
@@ -579,21 +586,40 @@ void main() {
|
||||
find.byType(Wrap),
|
||||
matchesGoldenFile('decoration_image.lerp.2.png'),
|
||||
);
|
||||
|
||||
cmykLoader.dispose();
|
||||
wrgbLoader.dispose();
|
||||
imageCache.clear();
|
||||
}, skip: kIsWeb); // TODO(ianh): https://github.com/flutter/flutter/issues/130612, https://github.com/flutter/flutter/issues/130609
|
||||
}
|
||||
|
||||
Future<void> load(MemoryImage image) {
|
||||
final ImageStream stream = image.resolve(ImageConfiguration.empty);
|
||||
final Completer<ImageInfo> completer = Completer<ImageInfo>();
|
||||
void listener(ImageInfo image, bool syncCall) {
|
||||
completer.complete(image);
|
||||
class _ImageLoader {
|
||||
_ImageLoader(this.image);
|
||||
|
||||
late final MemoryImage image;
|
||||
late final ImageStream stream;
|
||||
final Completer<ImageInfo> _completer = Completer<ImageInfo>();
|
||||
late final ImageStreamListener wrappedListener;
|
||||
|
||||
void _listener(ImageInfo image, bool syncCall) {
|
||||
_completer.complete(image);
|
||||
addTearDown(image.dispose);
|
||||
}
|
||||
|
||||
Future<void> load() {
|
||||
stream = image.resolve(ImageConfiguration.empty);
|
||||
wrappedListener = ImageStreamListener(_listener);
|
||||
stream.addListener(wrappedListener);
|
||||
return _completer.future;
|
||||
}
|
||||
|
||||
void dispose(){
|
||||
stream.removeListener(wrappedListener);
|
||||
}
|
||||
stream.addListener(ImageStreamListener(listener));
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
class TestImage extends StatelessWidget {
|
||||
TestImage(this.image); // ignore: use_key_in_widget_constructors, prefer_const_constructors_in_immutables
|
||||
class _TestImage extends StatelessWidget {
|
||||
const _TestImage(this.image);
|
||||
|
||||
final DecorationImage? image;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user