internalZcodeDBInit function

void internalZcodeDBInit()

init zcode word database for platform other than web.

Implementation

void internalZcodeDBInit() async {
  if (zcodeDB == null) {
    final documentsDirectory = await getApplicationDocumentsDirectory();
    String path = join(documentsDirectory.path, "zcode_ime.db");
    if (FileSystemEntity.typeSync(path) == FileSystemEntityType.notFound) {
      ByteData data =
          await rootBundle.load('packages/zcode_embed_ime_db/db/zcode_ime.db');
      final bytes =
          data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
      await File(path).writeAsBytes(bytes);
    }
    zcodeDB = sqlite3.open(path);
  }
}