Hint about sdk constraint update for workspace and resolution (#4384)

diff --git a/lib/src/pubspec.dart b/lib/src/pubspec.dart
index fcd9259..1542768 100644
--- a/lib/src/pubspec.dart
+++ b/lib/src/pubspec.dart
@@ -72,6 +72,12 @@
         '`workspace` and `resolution` requires at least language version '
         '${LanguageVersion.firstVersionWithWorkspaces}',
         r.span,
+        hint: '''
+Consider updating the SDK constraint to:
+
+environment:
+  sdk: '^${sdk.version}'
+''',
       );
     }
     if (r == null || r.value == null) return <String>[];
@@ -103,6 +109,12 @@
         '`workspace` and `resolution` requires at least language version '
         '${LanguageVersion.firstVersionWithWorkspaces}',
         r.span,
+        hint: '''
+Consider updating the SDK constraint to:
+
+environment:
+  sdk: '^${sdk.version}'
+''',
       );
     }
     return switch (r?.value) {
@@ -720,8 +732,8 @@
 }
 
 /// Throws a [SourceSpanApplicationException] with the given message.
-Never _error(String message, SourceSpan? span) {
-  throw SourceSpanApplicationException(message, span);
+Never _error(String message, SourceSpan? span, {String? hint}) {
+  throw SourceSpanApplicationException(message, span, hint: hint);
 }
 
 enum _FileType {
diff --git a/test/pubspec_test.dart b/test/pubspec_test.dart
index 5db5bf3..8dbff18 100644
--- a/test/pubspec_test.dart
+++ b/test/pubspec_test.dart
@@ -24,6 +24,7 @@
       String contents,
       void Function(Pubspec) fn, {
       String? expectedContains,
+      String? hintContains,
       Description? containingDescription,
     }) {
       var expectation = const TypeMatcher<SourceSpanApplicationException>();
@@ -34,6 +35,13 @@
           contains(expectedContains),
         );
       }
+      if (hintContains != null) {
+        expectation = expectation.having(
+          (error) => error.hint,
+          'hint',
+          contains(hintContains),
+        );
+      }
 
       final pubspec = Pubspec.parse(
         contents,
@@ -384,6 +392,14 @@
 workspace: ['a', 'b', 'c']
 ''',
         (p) => p.workspace,
+        expectedContains: '`workspace` and `resolution` '
+            'requires at least language version 3.5',
+        hintContains: '''
+Consider updating the SDK constraint to:
+
+environment:
+  sdk: '^${Platform.version.split(' ').first}'
+''',
       );
       // but no error if you don't look at it.
       expect(
@@ -406,9 +422,17 @@
         '''
 environment:
   sdk: ^1.2.3
-resolution: local
+resolution: workspace
 ''',
         (p) => p.resolution,
+        expectedContains: '`workspace` and `resolution` '
+            'requires at least language version 3.5',
+        hintContains: '''
+Consider updating the SDK constraint to:
+
+environment:
+  sdk: '^${Platform.version.split(' ').first}'
+''',
       );
     });