SDK ReferenceFlutterSetup

Flutter SDK

The Flutter SDK is generated from the OpenAPI spec and focuses on client-side features: auth, storage uploads, and realtime.

Install

Add to pubspec.yaml:

dependencies:
  aerostack: ^1.0.0
flutter pub get

Initialize

import 'package:aerostack/aerostack.dart';
 
final client = AerostackClient(
  projectId: 'your-project-id',
  apiKey: 'your-api-key',
  baseUrl: 'https://api.aerostack.ai/v1',
);

Authentication

// Register
final result = await client.auth.register(
  email: '[email protected]',
  password: 'password123',
  name: 'Jane Doe',
);
 
// Login
final result = await client.auth.login(
  email: '[email protected]',
  password: 'password123',
);
final accessToken = result.accessToken;
 
// OTP (passwordless)
await client.auth.sendOtp(email: '[email protected]');
final result = await client.auth.verifyOtp(
  email: '[email protected]',
  code: '123456',
);
 
// Get current user
final user = await client.auth.me(accessToken: accessToken);

Realtime

final channel = client.realtime.channel('chat/general');
 
channel.on('message', (payload) {
  print('New message: ${payload.data}');
});
 
await channel.subscribe();
 
// Publish
channel.publish('message', {'text': 'Hello!', 'userId': userId});
 
// Presence
channel.track({'userId': userId, 'name': userName, 'status': 'online'});
channel.untrack();
 
// Cleanup
channel.unsubscribe();

Storage (file upload)

final file = File('/path/to/image.jpg');
final result = await client.storage.upload(
  file: file,
  path: 'avatars/$userId.jpg',
  contentType: 'image/jpeg',
);
final url = result.url; // CDN URL

See API Reference for the full method listing.