sourceForSchemaUpgrade method Null safety

String sourceForSchemaUpgrade(
  1. Schema existingSchema,
  2. Schema newSchema,
  3. int version,
  4. {List<String>? changeList}
)

Implementation

static String sourceForSchemaUpgrade(
    Schema existingSchema, Schema newSchema, int version,
    {List<String>? changeList}) {
  final diff = existingSchema.differenceFrom(newSchema);
  final source =
      SchemaBuilder.fromDifference(null, diff, changeList: changeList!)
          .commands
          .map((line) => "\t\t$line")
          .join("\n");

  return """
import 'dart:async';
import 'package:liquidart/liquidart.dart';

class Migration$version extends Migration {
@override
Future upgrade() async {
 $source
}

@override
Future downgrade() async {}

@override
Future seed() async {}
}
  """;
}