init function

Future<void> init(
  1. String filename,
  2. String mode
)

Initializes the SQLite database.

filename is the name of the database file mode specifies the database access mode

Implementation

Future<void> init(String filename, String mode) {
  if (_initializationFuture != null) {
    throw SqliteException('SQLite is already initialized');
  }

  try {
    final promise = callSqlite('init', [filename.toJS, mode.toJS].toJS);
    _initializationFuture = promise.toDart.then((_) {});
    return _initializationFuture!;
  } catch (e) {
    throw SqliteException('Failed to initialize SQLite: $e');
  }
}