deleteCredential method

Future<CtrlMessage> deleteCredential(
  1. String method,
  2. String value
)

Delete validation credential

Implementation

Future<CtrlMessage> deleteCredential(String method, String value) async {
  if (!isSubscribed) {
    return Future.error(
        Exception("Cannot delete credential in inactive 'me' topic"));
  }

  // Send {del} message, return promise
  var response = await _tinodeService.deleteCredential(method, value);
  var ctrl = CtrlMessage.fromMessage(response);

  // Remove deleted credential from the cache.
  var index = _credentials.indexWhere((el) {
    return el.meth == method && el.val == value;
  });

  if (index > -1) {
    _credentials.removeAt(index);
  }

  onCredsUpdated.add(_credentials);
  return ctrl;
}