matchesSnapshot method Null safety

void matchesSnapshot(
  1. Snapshot newSnapshot
)

Implementation

void matchesSnapshot(Snapshot newSnapshot) {
  if (type != newSnapshot.type) {
    throw Exception('Snapshot: Cannot compare snapshots of different types');
  }

  var prevSnap = getSnapshotData();
  var newSnap = newSnapshot.getSnapshotData();

  if (prevSnap is List && newSnap is List) {
    expect(prevSnap, newSnap);
    return;
  } else if (prevSnap is String && newSnap is String) {
    expect(prevSnap, newSnap);
    return;
  }
}