| Index: lib/src/validator/sdk_constraint.dart
|
| diff --git a/lib/src/validator/sdk_constraint.dart b/lib/src/validator/sdk_constraint.dart
|
| index bdf7e7be8bf98309738a9e77e1561546cde6c208..aa57baaa31f89e54aaf2751a61523e4e9485bd10 100644
|
| --- a/lib/src/validator/sdk_constraint.dart
|
| +++ b/lib/src/validator/sdk_constraint.dart
|
| @@ -4,9 +4,15 @@
|
|
|
| import 'dart:async';
|
|
|
| +import 'package:pub_semver/pub_semver.dart';
|
| +
|
| import '../entrypoint.dart';
|
| import '../validator.dart';
|
|
|
| +/// The range of all Dart SDK versions that don't support Flutter SDK
|
| +/// constraints.
|
| +final _preFlutterSupport = new VersionConstraint.parse("<1.19.0");
|
| +
|
| /// A validator that validates that a package's SDK constraint doesn't use the
|
| /// "^" syntax.
|
| class SdkConstraintValidator extends Validator {
|
| @@ -14,15 +20,33 @@ class SdkConstraintValidator extends Validator {
|
| : super(entrypoint);
|
|
|
| Future validate() async {
|
| - var constraint = entrypoint.root.pubspec.dartSdkConstraint;
|
| - if (!constraint.toString().startsWith("^")) return;
|
| -
|
| - errors.add(
|
| - "^ version constraints aren't allowed for SDK constraints since "
|
| - "older versions of pub don't support them.\n"
|
| - "Expand it manually instead:\n"
|
| - "\n"
|
| - "environment:\n"
|
| - " sdk: \">=${constraint.min} <${constraint.max}\"");
|
| + var dartConstraint = entrypoint.root.pubspec.dartSdkConstraint;
|
| + if (dartConstraint.toString().startsWith("^")) {
|
| + errors.add(
|
| + "^ version constraints aren't allowed for SDK constraints since "
|
| + "older versions of pub don't support them.\n"
|
| + "Expand it manually instead:\n"
|
| + "\n"
|
| + "environment:\n"
|
| + " sdk: \">=${dartConstraint.min} <${dartConstraint.max}\"");
|
| + }
|
| +
|
| + if (entrypoint.root.pubspec.flutterSdkConstraint != null &&
|
| + dartConstraint.allowsAny(_preFlutterSupport)) {
|
| + var newDartConstraint = dartConstraint.difference(_preFlutterSupport);
|
| + if (newDartConstraint.isEmpty ||
|
| + newDartConstraint ==
|
| + VersionConstraint.any.difference(_preFlutterSupport)) {
|
| + newDartConstraint = new VersionConstraint.parse("<2.0.0")
|
| + .difference(_preFlutterSupport);
|
| + }
|
| +
|
| + errors.add(
|
| + "Older versions of pub don't support Flutter SDK constraints.\n"
|
| + "Make sure your SDK constraint excludes those old versions:\n"
|
| + "\n"
|
| + "environment:\n"
|
| + " sdk: \"$newDartConstraint\"");
|
| + }
|
| }
|
| }
|
|
|