Skip to content

Commit

Permalink
Added fallback for version validation
Browse files Browse the repository at this point in the history
  • Loading branch information
leoafarias committed Feb 16, 2024
1 parent 047d08b commit 5d40bd0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
6 changes: 6 additions & 0 deletions lib/src/services/releases_service/releases_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ class FlutterReleases {
}
}

static Future<bool> isVersionValid(String version) async {
final releases = await get();

return releases.containsVersion(version);
}

/// Returns a [Release] channel [version]
static Future<Release> getLatestReleaseOfChannel(
FlutterChannel channel,
Expand Down
8 changes: 8 additions & 0 deletions lib/src/workflows/ensure_cache.workflow.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -173,6 +174,13 @@ Future<FlutterVersion> validateFlutterVersion(String version) async {
if (isTag) {
return flutterVersion;
}

final isVersion =
await FlutterReleases.isVersionValid(flutterVersion.version);

if (isVersion) {
return flutterVersion;
}
}

if (flutterVersion.isCommit) {
Expand Down
5 changes: 2 additions & 3 deletions lib/src/workflows/use_version.workflow.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 5d40bd0

Please sign in to comment.