liveCellScreenshotPaths function

List<String> liveCellScreenshotPaths({
  1. required String root,
  2. required String device,
  3. required String mode,
  4. required DateTime at,
  5. required List<LiveCell> cells,
  6. String? requested,
  7. bool several = false,
  8. String suffix = '',
  9. bool exists(
    1. String path
    )?,
})

Where screenshot --locales/--themes saves the capture of each of cells, in the same order.

By default they're <cell>.png files in a folder named like liveScreenshotPath names a file: screenshots/<mode>-<device>-<time>/. An --out folder (requested) holds them instead, in a folder per device when several apps are captured. An --out .png gets each cell's name added, after the device's when there are several. suffix (e.g. -ios-6.9) follows each cell's name.

Implementation

List<String> liveCellScreenshotPaths({
  required String root,
  required String device,
  required String mode,
  required DateTime at,
  required List<LiveCell> cells,
  String? requested,
  bool several = false,
  String suffix = '',
  bool Function(String path)? exists,
}) {
  final String separator = Platform.pathSeparator;
  if (requested != null && !liveOutIsFolder(requested, root: root)) {
    final String path = _resolve(requested, root);
    final int dot = path.lastIndexOf('.');
    final String stem =
        '${path.substring(0, dot)}${several ? '-${liveSlug(device)}' : ''}';
    return [
      for (final LiveCell cell in cells)
        '$stem-${cell.name}$suffix${path.substring(dot)}',
    ];
  }
  final String folder = requested != null
      ? [
          _resolve(requested, root).replaceAll(RegExp(r'[\\/]+$'), ''),
          if (several) liveSlug(device),
        ].join(separator)
      : liveScreenshotPath(
          root: root,
          device: device,
          mode: mode,
          at: at,
          extension: '',
          exists: exists,
        );
  return [
    for (final LiveCell cell in cells)
      '$folder$separator${cell.name}$suffix.png',
  ];
}