Skip to content

Commit 4d1865e

Browse files
committed
package_info_plus_windows: split product version at '+'
As proposed by @deakjahn in #25.
1 parent cc68f8e commit 4d1865e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/package_info_plus_windows/lib/package_info_plus_windows.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,19 @@ class PackageInfoWindows extends PackageInfoPlatform {
1818
@override
1919
Future<PackageInfoData> getAll() {
2020
final info = _FileVersionInfo(Platform.resolvedExecutable);
21+
final versions = info.productVersion.split('+');
2122
final data = PackageInfoData(
2223
appName: info.productName,
2324
packageName: info.internalName,
24-
version: info.productVersion,
25-
buildNumber: info.fileVersion,
25+
version: versions.getOrNull(0),
26+
buildNumber: versions.getOrNull(1),
2627
);
2728
info.dispose();
2829
return Future.value(data);
2930
}
3031
}
32+
33+
extension _GetOrNull<T> on List<T> {
34+
T getOrNull(int index) => _checkIndex(index) ? this[index] : null;
35+
bool _checkIndex(int index) => index >= 0 && index < length;
36+
}

0 commit comments

Comments
 (0)