flutter_cached_network_image icon indicating copy to clipboard operation
flutter_cached_network_image copied to clipboard

ImageBuilder is never called during the tests in flutter with CachedNetworkImage

Open dirceudn opened this issue 3 years ago • 1 comments

Hello,

I'm having an issue with the widget tests using the CachedNetworkImage. The problem is the imageBuilder is never called.You can reproduce the behavior with this test:

testWidgets("CircleAvatar shown", (WidgetTester tester) async {
  await mockNetworkImagesFor(() async {
    await tester.pumpWidget(
      CachedNetworkImage(
        imageUrl: "https://imgur.com/aZyQZTZ",
        placeholder: (context, url) => CircularProgressIndicator(),
        errorWidget: (context, url, error) => CircleAvatar(child: Icon(Icons.broken_image)),
        imageBuilder: (context, imageProvider) => CircleAvatar(backgroundImage: imageProvider),
      ),
    );
    expect(find.byType(CachedNetworkImage), findsOneWidget); // OK
    expect(find.byType(CircleAvatar), findsOneWidget); // Fail
  });
});

dirceudn avatar Mar 18 '22 09:03 dirceudn

This might be the same question: https://github.com/Baseflow/flutter_cache_manager/issues/290

etienn01 avatar Mar 22 '22 10:03 etienn01