The at_client library is the non-platform specific Client SDK which provides the essential methods for building an app using the @protocol.
SDK that provides the essential methods for building an app using The @protocol. You may also want to look at at_client_mobile.
at_client package is written in Dart, supports Flutter and follows the @platform's decentralized, edge computing model with the following features:
- Cryptographic control of data access through personal data stores
- No application backend needed
- End to end encryption where only the data owner has the keys
- Private and surveillance free connectivity
We call giving people control of access to their data "flipping the internet".
Initially to get a basic overview of the SDK, you must read the atsign docs.
To use this package you must be having a basic setup, Follow here to get started.
Check how to use this package in the at_client installation tab.
- Set
AtClientPreferences
to your preferred settings.
Directory appSupportDir = await getApplicationSupportDirectory();
AtClientPreference preferences = AtClientPreference()
..rootDomain = 'root.atsign.org'
..namespace = '.my_namespace'
..hiveStoragePath = appSupportDir.path
..commitLogPath = appSupportDirdir.path
..isLocalStoreRequired = true;
- These
preferences
are used for your application.
AtClientManager atClientManagerInstance = await AtClientManager.getInstance().setCurrentAtSign(atSign, AtEnv.appNamespace, preferences);
- Update the user data using the
put()
method.
AtKey atKey = AtKey()
..key = 'phone'
..namespace = '.myApp';
await atClientInstance.put(atKey, '+00 123-456-7890');
- Get the data using the
get()
method.
AtKey atKey = AtKey()
..key='phone'
..namespace = '.myApp';
AtValue value = await atClientInstance.get(atKey);
print(value.value); // +00 123-456-7890
- Delete the data using the
delete()
method.
bool isDeleted = await atClientInstance.delete(atKey);
print(isDeleted); // true if deleted
- Sync the data to the server using the
sync()
method if needed.
late SyncService _syncService;
_syncService = atClientManagerInstance.syncService;
_syncService.sync(onDone: _onSuccessCallback); // prints 'Sync done' on done.
void _onSuccessCallback() {
print('Sync done');
}
- Notify the server that the data has changed using the
notify()
method.
AtClientManager atClientManagerInstance = AtClientManager.getInstance();
MetaData metaData = Metadata()..ttl='60000'
..ttb='30000'
AtKey key = AtKey()..key='phone'
..sharedWith='@bob'
..metadata=metaData
..namespace = '.myApp';
String value = (await atClientInstance.get(atKey)).value;
OperationEnum operation = OperationEnum.update;
bool isNotified = await atClientManagerInstance.notify(atKey, value, operation);
print(isNotified); // true if notified
- Notify an update operation to an atsign.
String toAtsign = '@bob';
var key = AtKey()
..key = 'phone'
..sharedWith = toAtSign;
var notification = NotificationServiceImpl(atClient!);
await notification.notify(NotificationParams.forUpdate(key));
- Want to check connection status? Why another package in you app? Use
ConnectivityListener
.
ConnectivityListener().subscribe().listen((isConnected) {
if (isConnected) {
print('connection available');
} else {
print('connection lost');
}
});
AtClient has many more methods that are exposed. Please refer to the atsign docs for more details.
We have a good example with explanation in the at_client_mobile package.