firestack library

Firestack Flutter SDK

A complete Flutter SDK for interacting with Firestack backend services.

import 'package:firestack/firestack.dart';

final app = Firestack.initialize(
  apiKey: 'fsk_your_api_key',
  appId: '550e8400-e29b-41d4-a716-446655440000', // Your app UUID from the Firestack dashboard
);

// Or with a custom server URL:
final app2 = Firestack.initialize(
  apiKey: 'fsk_your_api_key',
  appId: '550e8400-e29b-41d4-a716-446655440000',
  baseUrl: 'https://your-server.com',
);

// Auth
final auth = app.auth;
await auth.signUp(
  email: 'user@example.com',
  password: 'password',
  name: 'John Doe',
);
await auth.signIn(email: 'user@example.com', password: 'password');

// Firestore
final firestore = app.firestore;
final docs = await firestore.collection('users').get();

// Storage
final storage = app.storage;
final file = await storage.upload(File('photo.jpg'));

// Realtime
app.realtime.subscribe('collections', onDocumentCreated: (data) {
  print('New document: $data');
});

Classes

AnalyticsEvent
An analytics event for batch logging.
CachedResult<T>
Result wrapper that indicates the source (cache or server).
CloudFile
A file from a cloud storage provider.
CloudStorageProvider
A connected cloud storage provider.
CollectionReference
Reference to a specific collection.
DocumentReference
Reference to a specific document within a collection.
FieldValue
Sentinel values for atomic field-level operations on documents.
FileDownloadUrl
A signed download URL with expiration.
Firestack
Main entry point for the Firestack SDK.
FirestackAi
Firestack AI API for insights, classification, recommendations, entity extraction, and anomaly detection.
FirestackAnalytics
Analytics service for tracking events.
FirestackAuditLogs
Firestack audit log API.
FirestackAuth
Authentication service for Firestack.
FirestackAutoApi
Firestack auto-generated REST API helpers.
FirestackCache
In-memory document cache with TTL for offline-first reads.
FirestackChannel
Firestack messaging channel model.
FirestackChannelMessage
Minimal message reference used in channel's lastMessage.
FirestackClient
Low-level HTTP client for Firestack API.
FirestackCloudStorage
Firestack Cloud Storage API for third-party integrations.
FirestackCollection
Firestack collection model (Firestore-like).
FirestackDataExport
Firestack data export/import API.
FirestackDocument
Firestack document model (Firestore-like).
FirestackEmailTemplates
Firestack email template API for app users.
FirestackFile
Firestack file resource model.
FirestackFirestore
Firestore-like database service.
FirestackInAppNotifications
Firestack in-app notification inbox API.
FirestackMessage
Firestack message model for instant messaging.
FirestackMessageSender
Sender info embedded in a message.
FirestackMessaging
Instant messaging service for Firestack.
FirestackNotification
Firestack notification model.
FirestackNotifications
Notification service for Firestack.
FirestackReaction
Aggregated reaction on a message.
FirestackRealtime
Realtime engine for Firestack using WebSockets (Pusher protocol).
FirestackRemoteConfig
Remote config service for Firestack.
FirestackSearch
Firestack search API for querying documents across collections.
FirestackSms
Firestack SMS API for sending text messages.
FirestackSmtp
Firestack SMTP API for sending emails via project/user SMTP settings.
FirestackStorage
File storage service for Firestack.
FirestackTwoFactorAuth
Firestack two-factor authentication (TOTP) API.
FirestackUser
Firestack user model.
NotificationPreference
In-app notification preference item.
NotificationSettings
Settings returned after requesting notification permissions.
PaginatedResult<T>
Paginated result wrapper.
QueryBuilder
Query builder for Firestack document queries.
RemoteConfigEntry
Firestack remote config entry.
SmtpConfig
SMTP configuration for a project.
Transaction
A transaction for reading and writing documents atomically.
UploadSnapshot
A snapshot of upload progress.
UploadTask
Represents an ongoing file upload with progress tracking.
WriteBatch
A batch of write operations to execute together.

Enums

AggregateOperation
Aggregate operation for collection data.
AiAnalysisType
Type of AI analysis.
AiClassificationType
Type of AI classification.
AiSuggestionType
Type of AI suggestion.
CacheSource
Source of a cached read result.
CloudProvider
Cloud storage providers supported by Firestack.
ConnectionState
Connection state of the realtime engine.
ExportFormat
Export format for collection data.
FirestackLogLevel
Log level for debug output.
ImportFormat
Import format for collection data.
InAppNotificationType
In-app notification type.
NotificationAuthorizationStatus
The authorization status for notifications.
NotificationChannel
Notification channel for preferences.
RemoteConfigFetchStatus
The status of the last remote config fetch.
SmsProvider
SMS provider preference.
UploadTaskState
Upload task state.

Constants

firestackDefaultBaseUrl → const String
Default base URL for the Firestack API server.

Functions

encodeFieldValues(Map<String, dynamic> data) Map<String, dynamic>
Encodes a data map, converting any FieldValue instances to their JSON representations for the API.

Typedefs

DeviceTokenProvider = Future<String?> Function()
Callback the SDK consumer provides to retrieve the device push token.
ForegroundMessageHandler = void Function(FirestackNotification message)
Callback invoked when a push notification is received while the app is in the foreground.
PermissionRequestHandler = Future<NotificationSettings> Function()
Callback the SDK consumer provides to request native notification permission.
TokenPersistenceCallback = Future<void> Function(String? token)
Callback for persisting or clearing the auth token.
UploadProgressCallback = void Function(int bytesSent, int totalBytes)
Callback for upload progress. bytesSent / totalBytes.

Exceptions / Errors

FirestackException
Custom exception for Firestack SDK errors.