Baseflow / Baseflow/flutter_cache_manager
How to test imagebuilder
- Dominant language
- Dart
- Stars
- 809
- Forks
- 510
- Avg merge
- 6m
- Merged PRs (30d)
- 1
Description
## 💬 Questions and Help
I need to test imageBuilder, I have this code, but I can't.
```dart
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);
});
Contributor guide
Research direction
Start with the testWidgets example and its FakeCacheManager setup. Check the widget states represented by the imageBuilder, progressIndicatorBuilder, and errorWidget callbacks, then verify the intended state with tester.pumpAndSettle. Done means the test reliably reaches the expected widget identified by the image key.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- mobile, testing
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100