diff --git a/lib/logs/file.dart b/lib/logs/file.dart index 9ee16ef..39c6418 100644 --- a/lib/logs/file.dart +++ b/lib/logs/file.dart @@ -26,6 +26,29 @@ class LogsFile { await dir.create(recursive: true); } _cachedLogDirectory = dir; + final d1 = _file(DateTime.now()); + if (d1 == null) { + throw Exception("Failed to create log file."); + } + return; + } + } catch (e) { + // Do nothing + } + } + if (isAndroid) { + try { + final io.Directory? dir = await getExternalStorageDirectory(); + if (dir != null) { + final d = fs.directory(path.join(dir.path, "logs")); + if (!(await d.exists())) { + await d.create(recursive: true); + } + _cachedLogDirectory = d; + final d2 = _file(DateTime.now()); + if (d2 == null) { + throw Exception("Failed to create log file."); + } return; } } catch (e) { diff --git a/lib/utils.dart b/lib/utils.dart index 6e5453f..1f8e2c6 100644 --- a/lib/utils.dart +++ b/lib/utils.dart @@ -4,3 +4,4 @@ import 'package:flutter/foundation.dart'; bool get isDesktop => !kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS); bool get isWindows => !kIsWeb && Platform.isWindows; +bool get isAndroid => !kIsWeb && Platform.isAndroid;