flutterVersionsOf function

List<FlutterVersion> flutterVersionsOf(
  1. Map<FlutterSystem, Map<Version, FlutterRelease>> releases, {
  2. required VersionConstraint flutter,
  3. required VersionConstraint dart,
})

The versions of Flutter that the nightly run of CI checks the apps with, the oldest first: every stable release for Linux among releases (see stableReleasesOf) whose Flutter flutter allows and whose Dart dart allows, such as those of matrixSdkConstraints.

The jobs on macOS and Windows run with the oldest, and with the latest patch of each minor version, such as 3.44.0, 3.44.9 and 3.47.5 of >=3.44.0, of which the last is the latest stable release.

Throws a FlutterVersionsException if no release is allowed, or if one that the jobs on macOS and Windows run with has no release for either.

Implementation

List<FlutterVersion> flutterVersionsOf(
  Map<FlutterSystem, Map<Version, FlutterRelease>> releases, {
  required VersionConstraint flutter,
  required VersionConstraint dart,
}) {
  final allowed = [
    for (final release
        in releases[FlutterSystem.linux]?.values ?? const <FlutterRelease>[])
      if (flutter.allows(release.version) && dart.allows(release.dart)) release,
  ]..sort((a, b) => a.version.compareTo(b.version));
  if (allowed.isEmpty) {
    throw FlutterVersionsException(
      'No stable release of Flutter for Linux has a Flutter $flutter with a '
      'Dart $dart.',
    );
  }
  FlutterRelease releaseFor(FlutterSystem system, Version version) =>
      releases[system]?[version] ??
      (throw FlutterVersionsException(
        'Flutter $version has no stable release for ${system.name} on '
        '${system.arch}.',
      ));

  return [
    for (final (index, release) in allowed.indexed)
      if (index == 0 ||
          index == allowed.length - 1 ||
          !_sameMinor(release.version, allowed[index + 1].version))
        FlutterVersion(
          release,
          macos: releaseFor(FlutterSystem.macos, release.version),
          windows: releaseFor(FlutterSystem.windows, release.version),
        )
      else
        FlutterVersion(release, macos: null, windows: null),
  ];
}