I try to use a 665 MB size Database file (SQLite file) for my flutter app. (the file is needed since it provides offline-data for a public transportation App. And therefore I cannot make it smaller).
So far, when using any SQLite file in Flutter, I normally copy it in code.
The original location of the file is ./assets/db_file.db.
The destination location of the file is DocumentsDirectory.
Now I have the problem that the file-copy does not work for my 665 MB large DB-file.
Here is my code that fails to copy due to the large size of the file.
(for smaller files, this code works well)...:
(also, in the Simulator the code works well, no matter the large file-size. The problem only occurs on an actual iPhone)...
Directory directory = await getApplicationDocumentsDirectory();
var dbPath = join(directory.path, "destinationFile.db");
if (FileSystemEntity.typeSync(dbPath) == FileSystemEntityType.notFound) {
ByteData data = await rootBundle.load("assets/largeFile.db");
List<int> bytes =
data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
await File(dbPath).writeAsBytes(bytes);
}
For my 665 MB file the above code crashes - without error message :/
The line of code it crashes is the following:
ByteData data = await rootBundle.load("assets/largeFile.db");
Questions:
is there any way to improve my above code for very large files so that no crash ocurrs ??
is there any way to provide the db-file inside the documents-folder in the first place (as part of the bundle, i.e. so that no copying is needed) ??
how should I proceed with such a large file anyway ??