From 5d40bd0fcb6f03ca964b08519062bc0497eeb3e8 Mon Sep 17 00:00:00 2001 From: Leo Farias Date: Fri, 16 Feb 2024 17:08:52 -0500 Subject: [PATCH] Added fallback for version validation --- lib/src/services/releases_service/releases_client.dart | 6 ++++++ lib/src/workflows/ensure_cache.workflow.dart | 8 ++++++++ lib/src/workflows/use_version.workflow.dart | 5 ++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/src/services/releases_service/releases_client.dart b/lib/src/services/releases_service/releases_client.dart index 9aa1568d..7f180340 100644 --- a/lib/src/services/releases_service/releases_client.dart +++ b/lib/src/services/releases_service/releases_client.dart @@ -73,6 +73,12 @@ class FlutterReleases { } } + static Future isVersionValid(String version) async { + final releases = await get(); + + return releases.containsVersion(version); + } + /// Returns a [Release] channel [version] static Future getLatestReleaseOfChannel( FlutterChannel channel, diff --git a/lib/src/workflows/ensure_cache.workflow.dart b/lib/src/workflows/ensure_cache.workflow.dart index e0909458..7faba749 100644 --- a/lib/src/workflows/ensure_cache.workflow.dart +++ b/lib/src/workflows/ensure_cache.workflow.dart @@ -7,6 +7,7 @@ import '../models/flutter_version_model.dart'; import '../services/cache_service.dart'; import '../services/flutter_service.dart'; import '../services/logger_service.dart'; +import '../services/releases_service/releases_client.dart'; import '../utils/context.dart'; import '../utils/exceptions.dart'; import '../utils/helpers.dart'; @@ -173,6 +174,13 @@ Future validateFlutterVersion(String version) async { if (isTag) { return flutterVersion; } + + final isVersion = + await FlutterReleases.isVersionValid(flutterVersion.version); + + if (isVersion) { + return flutterVersion; + } } if (flutterVersion.isCommit) { diff --git a/lib/src/workflows/use_version.workflow.dart b/lib/src/workflows/use_version.workflow.dart index 3e274029..cf34b4fc 100644 --- a/lib/src/workflows/use_version.workflow.dart +++ b/lib/src/workflows/use_version.workflow.dart @@ -207,9 +207,8 @@ void _checkProjectVersionConstraints( final allowedInConstraint = constraints.allows(dartSdkVersion); - final message = cachedVersion.isRelease - ? 'Version: ${cachedVersion.name}.' - : '${cachedVersion.printFriendlyName} has SDK $sdkVersion'; + final message = + '${cachedVersion.printFriendlyName} has Dart SDK $sdkVersion'; if (!allowedInConstraint) { logger.notice('Flutter SDK does not meet project constraints');