ensurePubspecResolved function

Future<void> ensurePubspecResolved(
  1. String dir, {
  2. bool isOffline = false,
  3. bool summaryOnly = true,
  4. bool onlyOutputWhenTerminal = true,
  5. FileSystem? fileSystem,
  6. Map<String, String>? environment,
  7. String? platformVersion,
  8. Stream<List<int>>? stdin,
  9. StreamSink<List<int>>? stdout,
  10. StreamSink<List<int>>? stderr,
  11. Client? httpClient,
})

Makes sure that dir/pubspec.yaml is resolved such that pubspec.lock and .dart_tool/package_config.json are up-to-date and all packages are downloaded to the cache.

Will compare file timestamps to see if full resolution can be skipped.

If summaryOnly is true (the default) only a short summary is shown of the solve.

If onlyOutputWhenTerminal is true (the default) there will be no output if no terminal is attached.

Throws a ResolutionFailedException if resolution fails.

Implementation

Future<void> ensurePubspecResolved(
  String dir, {
  bool isOffline = false,
  bool summaryOnly = true,
  bool onlyOutputWhenTerminal = true,
  f.FileSystem? fileSystem,
  Map<String, String>? environment,
  String? platformVersion,
  Stream<List<int>>? stdin,
  StreamSink<List<int>>? stdout,
  StreamSink<List<int>>? stderr,
  http.Client? httpClient,
}) async {
  return await withOverrides(
    () async {
      try {
        await Entrypoint.ensureUpToDate(
          dir,
          cache: SystemCache(isOffline: isOffline),
          summaryOnly: summaryOnly,
          onlyOutputWhenTerminal: onlyOutputWhenTerminal,
        );
      } on ApplicationException catch (e) {
        throw ResolutionFailedException._(e.toString());
      } finally {
        // TODO(https://github.com/dart-lang/pub/issues/4200)
        // This is a bit of a hack.
        // We should most likely take a client here.
        globalHttpClient.close();
      }
    },
    fileSystem: fileSystem,
    environment: environment,
    platformVersion: platformVersion,
    stdin: stdin,
    stdout: stdout,
    stderr: stderr,
    httpClient: httpClient,
  );
}