pumpPlateGolden function

Future<void> pumpPlateGolden(
  1. WidgetTester tester,
  2. PlateController controller,
  3. String golden, {
  4. PlateTheme? theme,
  5. bool scoped = true,
  6. PlateCountry? country,
  7. Size stage = const Size(680, 300),
  8. Duration? decodeDelay,
})

Draws controller's plate centred on a stage-sized box, compares it with the golden file golden, then unmounts and disposes controller.

With a theme the plate sits under a PlateThemeScope of it, unless scoped is false; without one it takes the default. decodeDelay gives decals that decode off the fake clock real time before the picture is taken.

Implementation

Future<void> pumpPlateGolden(
  WidgetTester tester,
  PlateController controller,
  String golden, {
  PlateTheme? theme,
  bool scoped = true,
  PlateCountry? country,
  Size stage = const Size(680, 300),
  Duration? decodeDelay,
}) async {
  final Widget view = PlateView(
    controller: controller,
    theme: theme,
    country: country,
  );
  await tester.pumpWidget(
    MaterialApp(
      home: Scaffold(
        body: Center(
          child: SizedBox.fromSize(
            size: stage,
            child: theme == null || !scoped
                ? view
                : PlateThemeScope(theme: theme, child: view),
          ),
        ),
      ),
    ),
  );
  await tester.pumpAndSettle();
  if (decodeDelay != null) {
    await tester.runAsync(() => Future<void>.delayed(decodeDelay));
    await tester.pumpAndSettle();
  }
  await expectLater(find.byType(PlateView), matchesGoldenFile(golden));
  // Unmount before disposing: the canvas detaches from the controller on
  // dispose, which notifies listeners.
  await tester.pumpWidget(const SizedBox.shrink());
  controller.dispose();
}