initialize static method

void initialize({
  1. required String projectId,
  2. required String databaseId,
  3. String endpoint = 'https://cloud.appwrite.io/v1',
  4. bool selfSigned = false,
  5. String? jwt,
})

Initializes the AppwriteAdapter configuration and sets up Appwrite services

Parameters:

  • projectId: Your Appwrite project ID
  • databaseId: Your Appwrite database ID
  • endpoint: 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,
    ),
  );
}