exportChecked function

Future<ExportReport> exportChecked(
  1. ModelDocument document,
  2. CheckedModelWriter writer, {
  3. String name = 'model',
})

Writes document through writer, reads the files back through the same writer and compares at CheckedModelWriter.tolerance.

The one body every exportTo… below is, so a writer an application adds is checked the same way the built-in ones are.

Implementation

Future<ExportReport> exportChecked(
  ModelDocument document,
  CheckedModelWriter writer, {
  String name = 'model',
}) async {
  final ModelWrite written = writer.write(document, baseName: name);
  final ModelDocument readBack = await writer.readBack(written);
  return ExportReport(
    files: <String, Uint8List>{
      for (final WrittenFile each in written.files) each.name: each.bytes,
    },
    writerWarnings: written.warnings,
    differences: compareModelDocuments(
      document,
      readBack,
      tolerance: writer.tolerance,
    ),
  );
}