poptart_core 0.1.1
poptart_core: ^0.1.1 copied to clipboard
Core library for clients and tools. This package is mainly used by https://atprotodart.com packages.
poptart_core #
Core client, session, retry, blob, CAR, and shared protocol utilities for the Poptart package family.
Most applications should import package:poptart/poptart.dart. Reach for
poptart_core when you are building a package, test harness, or framework layer
that needs the warm filling under the main app-facing facade.
Install #
dart pub add poptart_core
import 'package:poptart_core/poptart_core.dart';
App-Password Sessions #
import 'package:poptart_core/poptart_core.dart';
Future<PoptartClient> createClient(String handle, String appPassword) async {
final response = await createSession(
identifier: handle,
password: appPassword,
);
return PoptartClient.fromSession(response.data);
}
Service Contexts #
ServiceContext is useful when you are building reusable clients and want the
same transport behavior that powers PoptartClient.
import 'package:poptart_core/poptart_core.dart';
Future<void> describeServer() async {
final ctx = ServiceContext(
retryConfig: RetryConfig(maxAttempts: 2),
);
final response = await ctx.get<String>(
NSID.parse('com.atproto.server.describeServer'),
);
print(response.data);
}
Retry Configuration #
import 'package:poptart_core/poptart_core.dart';
final client = PoptartClient.anonymous(
retryConfig: RetryConfig(
maxAttempts: 3,
jitter: Jitter(minInSeconds: 1, maxInSeconds: 3),
),
);
Utility Types #
poptart_core also exports:
Session,OAuthSession, and JWT helpers.BlobandBlobRefmodels.AtUriConverter,NSIDConverter, and blob converters.CARDecoderfor repository archive data.XRPCResponse,XRPCMethodDescriptor,Subscription, and related transport types.CIDthroughpoptart_multiformats.
Use this package when you need stable building blocks, not just the quick breakfast import.