fix: Use Platform.environment instead String.fromEnvironment

The latter seems return an empty string.
See: https://github.com/flutter/flutter/issues/55870#issuecomment-936612420
This commit is contained in:
Zhang Hua 2024-07-08 11:03:17 +08:00
parent e6479c2841
commit 0eaf3a5e0c
No known key found for this signature in database
GPG Key ID: 69528D6DCD2BE030

View File

@ -99,11 +99,11 @@ class AppLogger {
// See https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
// TODO: Use path_provider once it supports XDG_STATE_HOME
if (const bool.hasEnvironment("XDG_STATE_HOME")) {
String xdgStateHomeRaw = const String.fromEnvironment("XDG_STATE_HOME");
String xdgStateHomeRaw = Platform.environment["XDG_STATE_HOME"] ?? "";
if (xdgStateHomeRaw.isNotEmpty) {
return xdgStateHomeRaw;
}
}
return join(const String.fromEnvironment("HOME"), ".local", "state");
return join(Platform.environment["HOME"] ?? "", ".local", "state");
}
}