📅  最后修改于: 2022-03-11 14:55:27.132000             🧑  作者: Mango
Future _copyDatabase() async {
final String databasePath = await getDatabasesPath();
final String path = join(databasePath, 'dic.db');
final File file = File(path);
if (!file.existsSync()) {
ByteData data = await rootBundle.load(join('assets', 'dic.db'));
List bytes = data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
await file.writeAsBytes(bytes, flush: true);
logger.i('database successfully copied to $path');
} else {
logger.i('database already exist');
}
}