atproto 0.0.2 copy "atproto: ^0.0.2" to clipboard
atproto: ^0.0.2 copied to clipboard

The Easiest and Powerful Dart/Flutter Library for AT Protocol.

example/example.dart

// Copyright 2023 Kato Shinya. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided the conditions.

import 'package:atproto/atproto.dart' as atp;

Future<void> main() async {
  try {
    //! First you need to establish session with ATP server.
    final session = await atp.createSession(
      serviceName: 'SERVICE_NAME', //! The default is `bsky.social`
      handle: 'YOUR_HANDLE', //! Like `shinyakato.bsky.social`
      password: 'YOUR_PASSWORD',
    );

    print(session);

    final atproto = atp.ATProto(
      awtToken: session.data.accessJwt,

      //! Automatic retry is available when server error or network error occurs
      //! when communicating with the API.
      retryConfig: atp.RetryConfig(
        maxAttempts: 5,
        jitter: atp.Jitter(
          minInSeconds: 2,
          maxInSeconds: 5,
        ),
        onExecute: (event) => print(
          'Retry after ${event.intervalInSeconds} seconds...'
          '[${event.retryCount} times]',
        ),
      ),

      //! The default timeout is 10 seconds.
      timeout: Duration(seconds: 20),
    );

    final currentSession = await atproto.sessions.lookupCurrentSession();

    print(currentSession);
  } on atp.UnauthorizedException catch (e) {
    print(e);
  } on atp.ATProtoException catch (e) {
    print(e);
  }
}
12
likes
0
pub points
44%
popularity

Publisher

verified publisheratprotodart.com

The Easiest and Powerful Dart/Flutter Library for AT Protocol.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

freezed_annotation, http, json_annotation, universal_io

More

Packages that depend on atproto