Change min Dart SDK constraint to track actual version (#88743)
This commit is contained in:
@@ -371,6 +371,22 @@ class Cache {
|
||||
}
|
||||
String? _dartSdkVersion;
|
||||
|
||||
/// The current version of Dart used to build Flutter and run the tool.
|
||||
String get dartSdkBuild {
|
||||
if (_dartSdkBuild == 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];
|
||||
_dartSdkBuild = justVersion.replaceFirstMapped(RegExp(r'(\d+\.\d+\.\d+)(.+)'), (Match match) {
|
||||
final String noFlutter = match[2]!.replaceAll('.flutter-', ' ');
|
||||
return '${match[1]}$noFlutter';
|
||||
});
|
||||
}
|
||||
return _dartSdkBuild!;
|
||||
}
|
||||
String? _dartSdkBuild;
|
||||
|
||||
|
||||
/// The current version of the Flutter engine the flutter tool will download.
|
||||
String get engineRevision {
|
||||
_engineRevision ??= getVersionFor('engine');
|
||||
|
||||
@@ -230,6 +230,8 @@ class CreateCommand extends CreateBase {
|
||||
);
|
||||
}
|
||||
|
||||
final String dartSdk = globals.cache.dartSdkBuild;
|
||||
|
||||
final Map<String, Object> templateContext = createTemplateContext(
|
||||
organization: organization,
|
||||
projectName: projectName,
|
||||
@@ -246,7 +248,7 @@ class CreateCommand extends CreateBase {
|
||||
windows: featureFlags.isWindowsEnabled && platforms.contains('windows'),
|
||||
windowsUwp: featureFlags.isWindowsUwpEnabled && platforms.contains('winuwp'),
|
||||
// Enable null safety everywhere.
|
||||
dartSdkVersionBounds: '">=2.12.0 <3.0.0"',
|
||||
dartSdkVersionBounds: '">=$dartSdk <3.0.0"',
|
||||
implementationTests: boolArg('implementation-tests'),
|
||||
);
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/dart/pub.dart';
|
||||
import 'package:flutter_tools/src/flutter_cache.dart';
|
||||
import 'package:flutter_tools/src/globals_null_migrated.dart' as globals;
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:test/fake.dart';
|
||||
|
||||
@@ -864,6 +865,15 @@ void main() {
|
||||
expect(pub.calledGet, 1);
|
||||
});
|
||||
|
||||
// Check that the build number matches the format documented here:
|
||||
// https://dart.dev/get-dart#release-channels
|
||||
testUsingContext('Check current Dart SDK build number', () async {
|
||||
final String currentDartSdkVersion = globals.cache.dartSdkBuild;
|
||||
final RegExp dartSdkVersionFormat = RegExp(r'\d+\.\d+\.\d+(?:-\S+)?');
|
||||
|
||||
expect(dartSdkVersionFormat.allMatches(currentDartSdkVersion).length, 1,);
|
||||
});
|
||||
|
||||
group('AndroidMavenArtifacts', () {
|
||||
MemoryFileSystem memoryFileSystem;
|
||||
Cache cache;
|
||||
|
||||
Reference in New Issue
Block a user