openFileImage function

Future<MutableSqliteDatabase> openFileImage(
  1. String path
)

Opens path as an in-process database image.

A missing file starts empty and is not created. An existing file is read and is not replaced. Later SQL stays in memory until the caller writes MutableSqliteDatabase.exportImage. Register a tokenizer or a module on this connection. openDatabase keeps the file and does not receive that registration.

Implementation

Future<MutableSqliteDatabase> openFileImage(String path) async {
  final file = File(path);
  if (await file.exists()) {
    return MutableSqliteDatabase.fromImage(
        Uint8List.fromList(await file.readAsBytes()));
  }
  return MutableSqliteDatabase.create();
}