diff --git a/packages/flutter_tools/lib/src/commands/create.dart b/packages/flutter_tools/lib/src/commands/create.dart index ad0d67ca22..9b21bbb7f7 100644 --- a/packages/flutter_tools/lib/src/commands/create.dart +++ b/packages/flutter_tools/lib/src/commands/create.dart @@ -339,7 +339,7 @@ class CreateCommand extends CreateBase { linux: includeLinux, macos: includeMacos, windows: includeWindows, - dartSdkVersionBounds: "'>=$dartSdk <4.0.0'", + dartSdkVersionBounds: '^$dartSdk', implementationTests: boolArg('implementation-tests'), agpVersion: gradle.templateAndroidGradlePluginVersion, kotlinVersion: gradle.templateKotlinGradlePluginVersion, diff --git a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart index 703562449c..9c0e086ab9 100644 --- a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart +++ b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart @@ -3446,6 +3446,27 @@ void main() { expect(pubspec.description, 'a: b'); }); + testUsingContext('should use caret syntax in SDK version', () async { + await _createProject( + projectDir, + [ + '--no-pub', + ], + [ + 'pubspec.yaml', + ], + ); + + final String rawPubspec = await projectDir.childFile('pubspec.yaml').readAsString(); + final Pubspec pubspec = Pubspec.parse(rawPubspec); + + expect( + pubspec.environment!['sdk'].toString(), + startsWith('^'), + reason: 'The caret syntax is recommended over the traditional syntax.', + ); + }); + testUsingContext('create an FFI plugin with ios, then add macos', () async { Cache.flutterRoot = '../..';