我在 Flutter 应用程序中使用@protocol,想知道是否有办法在尝试与其共享密钥之前验证是否存在另一个@sign。现在我创建了一个函数,它将尝试与指定的@sign 共享一个密钥。如果有AtLookUpException,我认为用户不存在:
/// Check if user exists in this namespace by trying to share a key with them
Future<bool> checkForUser(String atSign) async {
/// Do test send to see if @ sign exists
AtKey testKey = AtKey();
testKey.key = 'test';
testKey.sharedWith = atSign;
try {
await atProtocolService.atClientImpl.put(testKey, 'Are you there?');
return true;
} on AtLookUpException catch (e){
print('AtLookUpException: '+ e.errorMessage);
return false;
}
}
为了进一步验证,您可以检查 AtLookUpException 的错误消息,如下所示:
未找到辅助服务器:未找到 atsign 的辅助 url:@bob
这是最好或最快的方法吗?