newDocument method Null safety

SchemaDocument newDocument()

Converts a SchemaDefinition to a base SchemaDocument with its fields being set to the associated SchemaKind from the underlying definition.

Implementation

SchemaDocument newDocument() {
  return SchemaDocument(
    schemaDid: did,
    fields: List<SchemaDocumentValue>.generate(fields.length, (index) {
      return SchemaDocumentValue(
        key: fields[index].name,
        kind: fields[index].fieldKind.kind,
      );
    }),
  );
}