Skip to content

Commit

Permalink
fix(package_info_plus): Get Windows package info when app is on a net…
Browse files Browse the repository at this point in the history
…work drive (#1697)

Co-authored-by: Volodymyr Buberenko <vbuberen@users.noreply.github.com>
Co-authored-by: Volodymyr Buberenko <v.buberenko@gmail.com>
  • Loading branch information
3 people committed May 15, 2023
1 parent e8d3b44 commit d7f9c28
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ class PackageInfoPlusWindowsPlugin extends PackageInfoPlatform {
/// appName, packageName, version, buildNumber
@override
Future<PackageInfoData> getAll() {
String resolvedExecutable = Platform.resolvedExecutable;

/// Workaround for https://github.com/dart-lang/sdk/issues/52309
if (resolvedExecutable.startsWith(r"UNC\")) {
resolvedExecutable = resolvedExecutable.replaceFirst(r"UNC\", r"\\");
}

final info = FileVersionInfo(Platform.resolvedExecutable);
final versions = info.productVersion.split('+');
final data = PackageInfoData(
Expand All @@ -35,5 +42,6 @@ class PackageInfoPlusWindowsPlugin extends PackageInfoPlatform {

extension _GetOrNull<T> on List<T> {
T? getOrNull(int index) => _checkIndex(index) ? this[index] : null;

bool _checkIndex(int index) => index >= 0 && index < length;
}

0 comments on commit d7f9c28

Please sign in to comment.