goldenNameFor function

String goldenNameFor(
  1. DeviceSpec device, {
  2. required String scenario,
  3. Orientation orientation = Orientation.portrait,
  4. FoldPosture posture = FoldPosture.flat,
})

A stable golden file name for device under the given scenario.

Includes the posture for foldables so cover and unfolded goldens do not collide.

Implementation

String goldenNameFor(
  DeviceSpec device, {
  required String scenario,
  Orientation orientation = Orientation.portrait,
  FoldPosture posture = FoldPosture.flat,
}) {
  final parts = [
    scenario,
    device.id.replaceAll('.', '-'),
    orientation.name,
    if (device.isFoldable) posture.name,
  ];
  return 'goldens/${parts.join('_')}.png';
}