createSchema method Null safety

Future<CreateSchemaResponse?> createSchema(
  1. String label,
  2. Map<String, SchemaKind> fields,
  3. Map<String, String>? metadata,
  4. [ResponseCallback<CreateSchemaResponse>? callback]
)

createSchema creates a schema

Args: label (String): The label of the schema to create. fields (Map<String, SchemaKind>): A map of field names to their schema kind. metadata (Map<String, String>): A map of metadata to be associated with the schema. callback (ResponseCallback): A callback function that will be called when the request is complete.

Implementation

Future<CreateSchemaResponse?> createSchema(String label, Map<String, SchemaKind> fields, Map<String, String>? metadata,
    [ResponseCallback<CreateSchemaResponse>? callback]) async {
  final resp = await MotorFlutterPlatform.instance.createSchema(CreateSchemaRequest(
    label: label,
    fields: fields,
    metadata: metadata,
  ));
  if (callback != null) {
    callback(resp);
  }
  if (resp != null) {
    schemaHistory.add(resp.schemaDefinition);
  }
  return resp;
}