flutter_cache_manager icon indicating copy to clipboard operation
flutter_cache_manager copied to clipboard

How to test imagebuilder

Open ramonchop opened this issue 3 years ago • 1 comments

💬 Questions and Help

I need to test imageBuilder, I have this code, but I can't.

testWidgets('Cached networked image builder', (tester) async {
final widget = CachedNetworkImage(
        cacheManager: cacheManager, //<<< FakeCacheManager
        imageBuilder: (
          context,
          url,
        ) =>
            Container(
          key: Key('image'),
        ),
        progressIndicatorBuilder: (context, url, progress) => Container(
          key: Key('progress'),
        ),
        errorWidget: (context, url, error) => Container(
          key: Key('failed'),
        ),
        imageUrl: 'foo.nl',
      );
      await tester.pumpWidget(
        MediaQuery(
          data: MediaQueryData(),
          child: MaterialApp(
            home: widget,
          ),
        ),
      );

      await tester.pumpAndSettle();

      expect(find.byKey(Key('image')), findsOneWidget);
    });

ramonchop avatar Mar 05 '21 21:03 ramonchop

https://github.com/Baseflow/flutter_cached_network_image/issues/307#issuecomment-1155893624

susatthi avatar Jun 15 '22 02:06 susatthi