put method Null safety

  1. @override
Future<bool> put(
  1. AtKey atKey,
  2. dynamic value,
  3. {bool isDedicated = false}
)
override

Updates value of AtKey.key is if it is already present. Otherwise creates a new key. Set AtKey.sharedWith if the key has to be shared with another atSign. Set AtKey.metadata.isBinary if you are updating binary value e.g image,file. By default namespace that is used to create the AtClient instance will be appended to the key. phone@alice will be saved as phone.persona@alice where 'persona' is the namespace. If you want to save by ignoring the namespace set AtKey.metadata.namespaceAware to false. Additional metadata can be set using AtKey.metadata isDedicated need to be set to true to create a dedicated connection

update:phone@alice +1 999 9999
  var key = AtKey()..key='phone'
  put(key,'+1 999 9999');
update:public:phone@alice +1 999 9999
  var metaData = Metadata()..isPublic=true;
  var key = AtKey()..key='phone'
            ..metadata=metaData
  put(key,'+1 999 9999');
update:@bob:phone@alice +1 999 9999
  var metaData = Metadata()..sharedWith='@bob';
   var key = AtKey()..key='phone'
                  ..metadata=metaData
  put(key,'+1 999 9999');
update:@alice:phone.persona@alice +1 999 9999
  var key = AtKey()..key='phone'
            ..sharedWith='@alice'
  put(key, '+1 999 9999');
update:@alice:phone@alice +1 999 9999
  var metaData = Metadata()..namespaceAware=false
  var key = AtKey()..key='phone'
           sharedWith='@alice'
  put(key, '+1 999 9999');
update:@bob:phone.persona@alice +1 999 9999
  var key = AtKey()..key='phone'
            sharedWith='@bob'
   put(key, '+1 999 9999');

Implementation

@override
Future<bool> put(AtKey atKey, dynamic value,
    {bool isDedicated = false}) async {
  if (atKey.metadata != null && atKey.metadata!.isBinary!) {
    if (value != null && value.length > _preference!.maxDataSize) {
      throw AtClientException('AT0005', 'BufferOverFlowException');
    }
    value = Base2e15.encode(value);
  }
  return _put(atKey.key, value,
      sharedWith: atKey.sharedWith,
      metadata: atKey.metadata,
      isDedicated: isDedicated);
}