Skip to content

Commit f376755

Browse files
authored
Merge pull request #37 from viamichelin/improve-await-images
Support `ShapeDecoration` in widget image precaching for tests
2 parents 821d738 + 20bf6dc commit f376755

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/src/helpers/await_images.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ extension AwaitImages on WidgetTester {
3030
for (final element in find.byType(DecoratedBox).evaluate().toList()) {
3131
final widget = element.widget as DecoratedBox;
3232
final decoration = widget.decoration;
33-
if (decoration is BoxDecoration) {
34-
final image = decoration.image?.image;
35-
if (image != null) {
36-
await precacheImage(image, element);
37-
await pump();
38-
}
33+
final image = switch (decoration) {
34+
BoxDecoration() => decoration.image?.image,
35+
ShapeDecoration() => decoration.image?.image,
36+
_ => null,
37+
};
38+
if (image != null) {
39+
await precacheImage(image, element);
40+
await pump();
3941
}
4042
}
4143
});

0 commit comments

Comments
 (0)