start static method

String start(
  1. List<String> names, {
  2. PlaybookSpeed? speed,
  3. Map<String, dynamic>? data,
  4. bool overlay = true,
  5. bool loop = false,
  6. int countdown = 0,
  7. PlaybookScreenshots screenshots = PlaybookScreenshots.off,
  8. double pixelRatio = 1.0,
  9. ({String? locale, String? theme})? matrix,
  10. ScreenshotStore? store,
  11. bool frame = false,
  12. Color? background,
  13. bool native = false,
  14. PlaybookClock? clock,
})

Starts the playbooks names back to back and returns the run's id.

speed overrides each playbook's own, and data is shared by all of them. With loop, the list repeats until stop. A countdown counts that many seconds down on screen first, so there's time to start a screen recording. screenshots chooses the screens captured for Metro to collect, at pixelRatio relative to the device, and matrix is the locale and theme Metro switched to for this pass of --locales / --themes. store, frame and background convert step and marked screenshots for a store listing. native says Metro can capture the whole screen for screenshot() steps; see nativeTaken. Throws a LiveException when a name is unknown or a playbook is running.

Implementation

static String start(
  List<String> names, {
  PlaybookSpeed? speed,
  Map<String, dynamic>? data,
  bool overlay = true,
  bool loop = false,
  int countdown = 0,
  PlaybookScreenshots screenshots = PlaybookScreenshots.off,
  double pixelRatio = 1.0,
  ({String? locale, String? theme})? matrix,
  ScreenshotStore? store,
  bool frame = false,
  Color? background,
  bool native = false,
  PlaybookClock? clock,
}) {
  if (_runId != null || Playbook.isRunning) {
    throw LiveException(
      'A playbook is already running${_runId == null ? '' : ' ($_runId)'}. '
      'Stop it first.',
    );
  }
  if (names.isEmpty) {
    throw const LiveException.invalidParams('Name a playbook to run.');
  }
  for (final String name in names) {
    if (PlaybookRegistry.find(name) == null) {
      final List<String> registered = PlaybookRegistry.playbooks.keys
          .toList();
      throw LiveException.invalidParams(
        'There\'s no playbook called "$name".'
        '${registered.isEmpty ? ' Create one with metro make:playbook $name' : ' Registered: ${registered.join(', ')}.'}',
      );
    }
  }

  final String runId = 'pb_${++_counter}';
  _runId = runId;
  _running = _run(
    runId,
    names,
    speed: speed,
    data: data,
    overlay: overlay,
    loop: loop,
    countdown: countdown,
    screenshots: screenshots,
    pixelRatio: pixelRatio,
    matrix: matrix,
    store: store,
    frame: frame,
    background: background,
    native: native,
    clock: clock,
  );
  return runId;
}