flutter-screenshot

command module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

README

Flutter Screenshot

example workflow name Coverage Status Go Report Card codebeat badge

A tool which helps in multi device screenshot creation for Flutter projects.

Requirements

  1. Go 1.15 or later, to install this project
  2. Installed Xcode and simulator
  3. Installed Android emulator, avdmanager and adb (e.x.: Command Line Tools)
  4. Flutter Integration tests
  5. Extend Integration tests with screenshot calls

Usage

Install
  1. go get -u -t github.com/borosr/flutter-screenshot
  2. Create a configuration file in your Flutter project's root and name it screenshots.yaml, config example below
  3. Just call flutter-screenshot in you Flutter project's directory
  4. (Optional) Use --verbose after the command, to see more log messages
Note
  • The flutter-screenshot will set the EMU_DEVICE environment variable before every flutter drive execution, the value will be the momentary device name from the configuration
Configuration
Example
# screenshots.yaml
command: flutter drive --target=test_driver/app.dart
devices:
  ios:
    - name: iPhone X
      mode: both # can be both, light, dark, the default value is light
    - name: iPad Pro (12.9-inch) (4th generation)
      mode: dark
  android:
    - name: Pixel_API_30
In Flutter project

You should create a helper method for your UI tests, something like:

final now = new DateTime.now();
makeScreenshot(FlutterDriver driver, String filename) async {
    final imageInPixels = await driver.screenshot();
    new File('screenshots/${Platform.environment['EMU_DEVICE']}_${now.toString()}/$filename.png')
        .writeAsBytes(imageInPixels);
}

Then call this makeScreenshot method with the current FlutterDriver object and a (test level) unique filename. The result will appear in a screenshots directory in you Flutter project root and will contains subdirectories with the configured device names which will contains the captured images.

Licence

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg
ios
src
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL