mirror of https://github.com/AMT-Cheif/drift.git
Convert ByteData before writing into file (#1555)
ByteData can not be written directly into file using writeAsBytes method. It must be converted to Uint8List before the operation.
This commit is contained in:
parent
214fbe2409
commit
1eb36eaaea
|
@ -45,7 +45,8 @@ LazyDatabase _openConnection() {
|
||||||
if (!await file.exists()) {
|
if (!await file.exists()) {
|
||||||
// Extract the pre-populated database file from assets
|
// Extract the pre-populated database file from assets
|
||||||
final blob = await rootBundle.load('assets/my_database.db');
|
final blob = await rootBundle.load('assets/my_database.db');
|
||||||
await file.writeAsBytes(blob);
|
final buffer = blob.buffer;
|
||||||
|
await file.writeAsBytes(buffer.asUint8List(blob.offsetInBytes, blob.lengthInBytes));
|
||||||
}
|
}
|
||||||
|
|
||||||
return NativeDatabase(file);
|
return NativeDatabase(file);
|
||||||
|
|
Loading…
Reference in New Issue