SchemaDifference constructor Null safety

SchemaDifference(
  1. Schema expectedSchema,
  2. Schema actualSchema
)

Creates a new instance that represents the difference between expectedSchema and actualSchema.

Implementation

SchemaDifference(this.expectedSchema, this.actualSchema) {
  for (final expectedTable in expectedSchema.tables) {
    final actualTable = actualSchema[expectedTable.name!];
    if (actualTable == null) {
      _differingTables.add(SchemaTableDifference(expectedTable, null));
    } else {
      final diff = expectedTable.differenceFrom(actualTable);
      if (diff.hasDifferences) {
        _differingTables.add(diff);
      }
    }
  }

  _differingTables.addAll(
    actualSchema.tables
        .where((t) => expectedSchema[t.name!] == null)
        .map((unexpectedTable) {
      return SchemaTableDifference(null, unexpectedTable);
    }),
  );
}