tryResolveVersions function

Future<SolveResult?> tryResolveVersions(
  1. SolveType type,
  2. SystemCache cache,
  3. Package root, {
  4. LockFile? lockFile,
  5. Iterable<String>? unlock,
  6. Iterable<ConstraintAndCause>? additionalConstraints,
})

Attempts to select the best concrete versions for all of the transitive dependencies of root taking into account all of the VersionConstraints that those dependencies place on each other and the requirements imposed by lockFile.

Like resolveVersions except that this function returns null where a similar call to resolveVersions would throw a SolveFailure.

If unlock is given, only packages listed in unlock will be unlocked from lockFile. This is useful for a upgrading specific packages only.

If unlock is empty SolveType.get interprets this as lock everything, while SolveType.upgrade and SolveType.downgrade interprets an empty unlock as unlock everything.

Implementation

Future<SolveResult?> tryResolveVersions(
  SolveType type,
  SystemCache cache,
  Package root, {
  LockFile? lockFile,
  Iterable<String>? unlock,
  Iterable<ConstraintAndCause>? additionalConstraints,
}) async {
  try {
    return await resolveVersions(
      type,
      cache,
      root,
      lockFile: lockFile,
      unlock: unlock ?? [],
      additionalConstraints: additionalConstraints,
    );
  } on SolveFailure {
    return null;
  }
}