createSchema method Null safety

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

Builds a request for recording a SchemaDefinition on the blockchain. metadata is for any additional information that should be stored with the schema. callback is an optional function that will be called when the transaction is complete. Returns a CreateSchemaResponse if the transaction is successful.

Example

final res = await MotorFlutter.to.createSchema('My Schema', {'name': SchemaKind.STRING, 'age': SchemaKind.INT});
if (res == null) {
   throw Exception('Failed to create schema');
}

Next Steps:

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);
  }
  return resp;
}