at_client 3.0.33 icon indicating copy to clipboard operation
at_client: ^3.0.33 copied to clipboard

The at_client library is the non-platform specific Client SDK which provides the essential methods for building an app using the @protocol.

Now for some internet optimism. #

pub package pub points build status gitHub license

at_client #

Introduction #

The at_client library is the non-platform specific Client SDK which provides the essential methods for building an app using the atProtocol.

SDK that provides the essential methods for building an app using The atProtocol. You may also want to look at at_client_mobile.

at_client package is written in Dart, supports Flutter and follows the atPlatform'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".

Get Started #

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.

Usage #

  • 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.

Example #

We have a good example with explanation in the at_client_mobile package.

8
likes
100
pub points
82%
popularity

Publisher

verified publisher iconatsign.org

The at_client library is the non-platform specific Client SDK which provides the essential methods for building an app using the @protocol.

Homepage
Repository (GitHub)

Documentation

Documentation
API reference

License

Icon for licenses.BSD-3-Clause (LICENSE)

Dependencies

archive, async, at_base2e15, at_commons, at_lookup, at_persistence_secondary_server, at_persistence_spec, at_utf7, at_utils, collection, convert, cron, crypto, crypton, encrypt, hive, http, internet_connection_checker, meta, path, uuid

More

Packages that depend on at_client