createSequenceGolden method

Future<void> createSequenceGolden(
  1. NvGoldenSingular nvGolden,
  2. String name, {
  3. List<NvGesture>? gestures,
  4. Future<void> afterPump()?,
  5. Color touchColor = Colors.orange,
})

Implementation

Future<void> createSequenceGolden(
  NvGoldenSingular nvGolden,
  String name, {
  List<NvGesture>? gestures,
  Future<void> Function()? afterPump,
  Color touchColor = Colors.orange,
}) async {
  final isPumped = this.any(find.byKey(nvGolden.uniqueKey));

  if (!isPumped) {
    throw Exception('Make sure you called [pumpSequence] first!');
  }

  await pumpAndSettle();

  await expectLater(
    find.byKey(nvGolden.uniqueKey),
    matchesGoldenFile(path.join('goldens', '$name.png')),
  );

  if (gestures?.isNotEmpty ?? false) {
    await _applyGesturesToGolden(
      nvGolden: nvGolden,
      name: name,
      gestures: gestures!,
    );
  }

  for (NvGesture gesture in gestures ?? []) {
    final finder = find.descendant(
      of: find.byKey(nvGolden.uniqueKey),
      matching: gesture.finder(),
    );
    await gesture.map(
      tap: (gesture) => tap(finder),
      drag: (gesture) => drag(finder, gesture.offset),
    );
  }

  await pumpAndSettle();
}