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 (var expectedTable in expectedSchema.tables) {
    var actualTable = actualSchema[expectedTable.name!];
    if (actualTable == null) {
      _differingTables.add(SchemaTableDifference(expectedTable, null));
    } else {
      var 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);
  }));
}