openSQLiteOnLinux function
This function open SQLite3 in memory and return the associated DynamicLibrary.
Implementation
DynamicLibrary openSQLiteOnLinux() {
late DynamicLibrary library;
String executableDirectoryPath =
File(Platform.resolvedExecutable).parent.path;
print('executableDirectoryPath: $executableDirectoryPath');
try {
String sqliteLibraryPath =
executableDirectoryPath + defaultSQLite3LinuxLibraryPath;
print('SQLite3LibraryPath: $sqliteLibraryPath');
library = DynamicLibrary.open(sqliteLibraryPath);
print(_yellow("SQLite3 successfully loaded"));
} catch (e) {
try {
print(e);
//some linux distributions like debian cannot run the first version
print(_red("Failed to load SQLite3, "
"trying to load an old version of SQLite3..."));
String sqliteLibraryPath =
executableDirectoryPath + oldSQLite3LinuxLibraryPath;
print('SQLite3LibraryPath: $sqliteLibraryPath');
library = DynamicLibrary.open(sqliteLibraryPath);
print(_yellow("SQLite3 successfully loaded"));
} catch (e) {
try {
print(e);
print(_red("Failed to load SQLite3 from library file, "
"trying loading from system..."));
library = DynamicLibrary.open('libsqlite3.so');
print(_yellow("SQLite3 successfully loaded"));
} catch (e) {
print(e);
print(_red("Failed to load SQLite3."));
}
}
}
return library;
}