Baseflow / Baseflow/flutter_cache_manager
How to test imagebuilder
- Langage dominant
- Dart
- Étoiles
- 809
- Forks
- 510
- Merge moyen
- 6 min
- PR mergées (30 j)
- 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);
});
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- dart
- Domaine
- mobile, testing
- Type d'issue
- Documentation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 25/100