Skip to content
pubscout

test_screenshot

0.0.8, released 2 years ago by an unverified publisher

Take screenshots during your flutter unit tests for debugging

$ flutter pub add test_screenshot
Source repository

What it does

It allows developers to capture screenshots of widget trees during Flutter unit tests by wrapping the widget tree in a Screenshotter widget and calling a tester extension method. It also supports capturing screenshots that include custom fonts and network images.

AI-written summary of version 0.0.8, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You want to visually debug Flutter unit tests using screenshots
  • You need to capture images of rendered widgets during automated testing

Skip it when

  • You are looking for golden file testing infrastructure to compare pixels against baseline images
  • You are not writing Flutter unit or widget tests

Strengths

  • Simple API with a Screenshotter widget and tester extension method
  • Supports capturing screenshots with fonts and network images

Weaknesses

  • Limited to debugging purposes during unit tests
  • Not documented for pixel-by-pixel golden test matching

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
4

Wrap the widget tree with a Screenshotter widget and call tester.screenshot() inside your testWidgets.

testWidgets('should create a screenshot', (tester) async {
  await tester.pumpWidget(
    Screenshotter(
      child: MaterialApp(
        home: Scaffold(body: Center(child: Icon(Icons.home))),
      ),
    ),
  );

  await tester.screenshot(path: 'screenshot.png');
});

Alternatives

Packages that do the same job and could replace test_screenshot.

Works with

Packages commonly used together with test_screenshot: ones it builds on, ones built on it, and its own family.