Skip to content

Commit

Permalink
Fix db locations on desktop
Browse files Browse the repository at this point in the history
  • Loading branch information
hhanh00 committed Apr 12, 2022
1 parent f714f74 commit d54ade5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,12 @@ DynamicLibrary _openOnLinux() {

Future<String> getDbPath() async {
if (isMobile()) return await getDatabasesPath();
final home = Platform.environment['XDG_DATA_HOME'] ?? Platform.environment['HOME'] ?? '/';
return "$home/databases";
String? home;
if (Platform.isWindows) home = Platform.environment['LOCALAPPDATA'];
if (Platform.isLinux) home = Platform.environment['XDG_DATA_HOME'];
if (Platform.isMacOS) home = Platform.environment['HOME'];
final h = home ?? "";
return "$h/databases";
}

bool isMobile() => Platform.isAndroid || Platform.isIOS;

0 comments on commit d54ade5

Please sign in to comment.