network_image_mock 2.1.1 copy "network_image_mock: ^2.1.1" to clipboard
network_image_mock: ^2.1.1 copied to clipboard

Utility for providing mocked Image.network response in Flutter widget tests.

example/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:network_image_mock/network_image_mock.dart';

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Image.network('https://example.com/some_image.jpg'),
    );
  }
}

void main() {
  testWidgets(
    'should properly mock Image.network and not crash',
    (WidgetTester tester) async {
      mockNetworkImagesFor(() => tester.pumpWidget(MyApp()));
    },
  );
}
54
likes
160
pub points
94%
popularity

Publisher

verified publisherstelynx.com

Utility for providing mocked Image.network response in Flutter widget tests.

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter, mockito

More

Packages that depend on network_image_mock