Baseflow / Baseflow/flutter_cache_manager
How to test imagebuilder
- Vorherrschende Sprache
- Dart
- Sterne
- 809
- Forks
- 510
- Ø Merge
- 6 Min.
- Gemergte PRs (30 T.)
- 1
Beschreibung
## 💬 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);
});
Beitragsleitfaden
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- dart
- Bereich
- mobile, testing
- Issue-Typ
- Dokumentation
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100