newAtKey method

AtKey newAtKey(
  1. int ttr,
  2. String key,
  3. String sharedWith, {
  4. int? ttl,
})

Creates a new AtKey with the specified parameters

Implementation

AtKey newAtKey(int ttr, String key, String sharedWith, {int? ttl}) {
  if (sharedWith[0] != '@') {
    sharedWith = '@$sharedWith';
  }

  String sharedBy = (atClient!.getCurrentAtSign()![0] != '@')
      ? ('@${atClient!.getCurrentAtSign()!}')
      : atClient!.getCurrentAtSign()!;
  var atKey = AtKey()
    ..metadata = Metadata()
    ..metadata.ttr = ttr
    ..metadata.ccd = true
    ..key = key
    ..sharedWith = sharedWith
    ..sharedBy = sharedBy;
  if (ttl != null) atKey.metadata.ttl = ttl;
  return atKey;
}