addTemplate method

JsonMap addTemplate({
  1. required String scope,
  2. required String name,
  3. required String contentMd,
  4. String? ownerId,
  5. String? channelId,
})

Adds a template of scope (personal of ownerId, or channel of channelId) and returns it.

Implementation

JsonMap addTemplate({
  required String scope,
  required String name,
  required String contentMd,
  String? ownerId,
  String? channelId,
}) {
  final id = nextId();
  final template = <String, Object?>{
    'id': id,
    'scope': scope,
    'channel_id': ?channelId,
    'name': name,
    'content_md': contentMd,
    'version': 1,
  };
  templates[id] = template;
  if (ownerId != null) templateOwners[id] = ownerId;
  return template;
}