get method Null safety

  1. @override
Future<AtValue> get(
  1. AtKey atKey,
  2. {bool isDedicated = false}
)
override

Get the value of AtKey.key from user's cloud secondary if AtKey.sharedBy is set. Otherwise looks up the key from local secondary. If the key was stored with public access, set AtKey.metadata.isPublic to true. If the key was shared with another atSign set AtKey.sharedWith isDedicated need to be set to true to create a dedicated connection

e.g alice is current atsign
llookup:phone@alice
  var atKey = AtKey()..key='phone'
  get(atKey);
llookup:public:phone@alice
  var metaData = Metadata()..isPublic=true;
  var atKey = AtKey()..key='phone'
            ..metadata=metaData
  get(atKey);
lookup:phone@bob
  var metaData = Metadata()..sharedWith='@bob';
  var key = AtKey()..key='phone'
                  ..metadata=metaData
  get(key);
llookup:@alice:phone.persona@alice
  var key = AtKey()..key='phone'
            ..sharedWith='@alice'
  get(key);
llookup:@alice:phone@alice
  var metaData = Metadata()..namespaceAware=false
  var key = AtKey()..key='phone'
            ..sharedWith='@alice'
  get(key);

@alice : update:@bob:phone.personal@alice
@bob   : lookup:phone.persona@alice
  var key = AtKey()..key='phone'
            ..sharedBy='@bob';
  get(key);

lookup:public:phone@alice
  var metaData = Metadata()..isPublic=true
                  ..namespaceAware='false'
  var key = AtKey()..key='phone'
            ..metadata=metaData
  get(key);

Implementation

@override
Future<AtValue> get(AtKey atKey, {bool isDedicated = false}) async {
  var isPublic = atKey.metadata != null ? atKey.metadata!.isPublic : false;
  var namespaceAware =
      atKey.metadata != null ? atKey.metadata!.namespaceAware : true;
  var isCached = atKey.metadata != null ? atKey.metadata!.isCached : false;
  var getResult = await _get(atKey.key,
      sharedWith: AtUtils.formatAtSign(atKey.sharedWith),
      sharedBy: AtUtils.formatAtSign(atKey.sharedBy),
      isPublic: isPublic,
      isCached: isCached,
      namespaceAware: namespaceAware,
      operation: UPDATE_ALL,
      isDedicated: isDedicated);

  var atValue = AtValue();
  if (getResult == null || getResult == 'null') {
    return atValue;
  }
  if (atKey.metadata != null && atKey.metadata!.isBinary!) {
    atValue.value = Base2e15.decode(getResult['data']);
  } else {
    atValue.value = getResult['data'];
    if (atValue.value is String) {
      atValue.value = VerbUtil.getFormattedValue(atValue.value);
    }
  }
  atValue.metadata = _prepareMetadata(getResult['metaData'], isPublic);
  return atValue;
}