Baseflow / Baseflow/flutter_cache_manager

How to test imagebuilder

Đang mở
#290 1 bình luận 2 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Dart
Star
809
Fork
510
Merge trung bình
6 phút
Pull request đã merge (30 ngày)
1

Mô tả

## 💬 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);
});

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
dart
Lĩnh vực
mobile, testing
Loại issue
Tài liệu
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.