Simplify the version string for customer consumption. (#23578)
Fixes #21825
diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart
index cf8b1ea..b3e365f 100644
--- a/packages/flutter_tools/lib/src/cache.dart
+++ b/packages/flutter_tools/lib/src/cache.dart
@@ -112,7 +112,18 @@
String _dartSdkVersion;
- String get dartSdkVersion => _dartSdkVersion ??= platform.version;
+ String get dartSdkVersion {
+ if (_dartSdkVersion == null) {
+ // Make the version string more customer-friendly.
+ // Changes '2.1.0-dev.8.0.flutter-4312ae32' to '2.1.0 (build 2.1.0-dev.8.0 4312ae32)'
+ final String justVersion = platform.version.split(' ')[0];
+ _dartSdkVersion = justVersion.replaceFirstMapped(RegExp(r'(\d+\.\d+\.\d+)(.+)'), (Match match) {
+ final String noFlutter = match[2].replaceAll('.flutter-', ' ');
+ return '${match[1]} (build ${match[1]}$noFlutter)';
+ });
+ }
+ return _dartSdkVersion;
+ }
String _engineRevision;
diff --git a/packages/flutter_tools/lib/src/version.dart b/packages/flutter_tools/lib/src/version.dart
index 896227b..e3ae88f 100644
--- a/packages/flutter_tools/lib/src/version.dart
+++ b/packages/flutter_tools/lib/src/version.dart
@@ -82,7 +82,7 @@
String get frameworkDate => frameworkCommitDate;
- String get dartSdkVersion => Cache.instance.dartSdkVersion.split(' ')[0];
+ String get dartSdkVersion => Cache.instance.dartSdkVersion;
String get engineRevision => Cache.instance.engineRevision;
String get engineRevisionShort => _shortGitRevision(engineRevision);
@@ -99,10 +99,10 @@
final String engineText = 'Engine • revision $engineRevisionShort';
final String toolsText = 'Tools • Dart $dartSdkVersion';
- // Flutter 1.3.922-pre.2 • channel master • https://github.com/flutter/flutter.git
- // Framework • revision 2259c59be8 • 19 minutes ago • 2016-08-15 22:51:40
- // Engine • revision fe509b0d96
- // Tools • Dart 1.19.0-dev.5.0
+ // Flutter 1.10.2-pre.69 • channel master • https://github.com/flutter/flutter.git
+ // Framework • revision 340c158f32 (84 minutes ago) • 2018-10-26 11:27:22 -0400
+ // Engine • revision 9c46333e14
+ // Tools • Dart 2.1.0 (build 2.1.0-dev.8.0 bf26f760b1)
return '$flutterText\n$frameworkText\n$engineText\n$toolsText';
}