initialize static method
void
initialize({})
Initializes the AppwriteAdapter configuration and sets up Appwrite services
Parameters:
projectId
: Your Appwrite project IDdatabaseId
: Your Appwrite database IDendpoint
: Appwrite API endpoint (defaults to 'https://cloud.appwrite.io/v1')selfSigned
: Whether to allow self-signed certificates (defaults to false)jwt
: Optional JWT token for authenticated requests
Example:
void main() {
AppwriteOffline.initialize(
projectId: 'your_project_id',
databaseId: 'your_database_id',
endpoint: 'https://your-appwrite-instance.com/v1',
jwt: 'your-jwt-token', // Optional JWT for authenticated requests
);
}
Implementation
static void initialize({
required String projectId,
required String databaseId,
String endpoint = 'https://cloud.appwrite.io/v1',
bool selfSigned = false,
String? jwt,
}) {
// Create Appwrite client
final client = Client()
..setEndpoint(endpoint)
..setProject(projectId)
..setSelfSigned(status: selfSigned);
// Set JWT if provided
if (jwt != null) {
client.setJWT(jwt);
}
// Register Appwrite client
locator.registerSingleton<Client>(client);
// Register Appwrite services
locator.registerSingleton<Databases>(
Databases(client),
);
locator.registerSingleton<Realtime>(
Realtime(client),
);
// Register configuration
locator.registerSingleton<AppwriteOffline>(
AppwriteOffline._(
projectId: projectId,
databaseId: databaseId,
endpoint: endpoint,
),
);
}