fetchSupportedDartSdkVersions function

Future<List<String>> fetchSupportedDartSdkVersions(
  1. Client cloudApiClient
)

Fetches the Dart SDK minor versions supported by Serverpod Cloud, such as ['3.11', '3.12', '3.13'], ordered lowest to highest.

Throws FailureException if they cannot be fetched, such as on a network error or a server that does not serve the policy endpoint. A deployment cannot select a Dart SDK version without them.

Implementation

Future<List<String>> fetchSupportedDartSdkVersions(
  Client cloudApiClient,
) async {
  try {
    final policy = await cloudApiClient.platform.getDartSdkVersionPolicy();
    return [for (final version in policy.supportedVersions) version.version];
  } on Exception catch (e, stackTrace) {
    throw FailureException(
      error:
          'Could not fetch the Dart SDK versions supported by Serverpod Cloud.',
      hint: platformFaultHint,
      reason: e.toString(),
      nestedException: e,
      nestedStackTrace: stackTrace,
    );
  }
}