plateGoldens function

void plateGoldens(
  1. String prefix,
  2. PlateCountry? country,
  3. Map<String, PlateGoldenCase> cases, {
  4. List<String> fonts = const <String>[],
  5. String separator = ' ',
  6. Duration? decodeDelay,
})

Registers one golden test per entry of cases, written to goldens/<prefix>_<key>.png and drawn on a 680×300 stage under country's panel (each spec's own country when null).

fonts are extra faces loaded after plateGoldenFont (a script the default face lacks). decodeDelay gives decals that decode off the fake clock real time before the picture is taken.

Regenerate with flutter test --update-goldens after a deliberate change.

Implementation

void plateGoldens(
  String prefix,
  PlateCountry? country,
  Map<String, PlateGoldenCase> cases, {
  List<String> fonts = const <String>[],
  String separator = ' ',
  Duration? decodeDelay,
}) {
  setUpAll(() async {
    final FontLoader loader = FontLoader('Roboto');
    for (final String path in <String>[plateGoldenFont, ...fonts]) {
      final File face = File(path);
      if (!face.existsSync()) continue;
      loader.addFont(face.readAsBytes().then((b) => ByteData.view(b.buffer)));
    }
    await loader.load();
  });

  for (final MapEntry<String, PlateGoldenCase> c in cases.entries) {
    testWidgets(c.key, (tester) async {
      final (PlateSpec spec, PlateTheme theme, String values) = c.value;
      await pumpPlateGolden(
        tester,
        PlateController.fromValues(
          spec,
          values.isEmpty ? const <String>[] : values.split(separator),
        ),
        'goldens/${prefix}_${c.key}.png',
        theme: theme,
        country: country ?? spec.country,
        decodeDelay: decodeDelay,
      );
    });
  }
}