@@ -140,6 +140,17 @@ class PubContext {
140140 }
141141}
142142
143+ /// Describes the amount of output that should get printed from a `pub` command.
144+ /// [PubOutputMode.all] indicates that the complete output is printed. This is
145+ /// typically the default.
146+ /// [PubOutputMode.none] indicates that no output should be printed.
147+ /// [PubOutputMode.summaryOnly] indicates that only summary information should be printed.
148+ enum PubOutputMode {
149+ none,
150+ all,
151+ summaryOnly,
152+ }
153+
143154/// A handle for interacting with the pub tool.
144155abstract class Pub {
145156 /// Create a default [Pub] instance.
@@ -172,6 +183,14 @@ abstract class Pub {
172183 /// If [shouldSkipThirdPartyGenerator] is true, the overall pub get will be
173184 /// skipped if the package config file has a "generator" other than "pub".
174185 /// Defaults to true.
186+ ///
187+ /// [outputMode] determines how verbose the output from `pub get` will be.
188+ /// If [PubOutputMode.all] is used, `pub get` will print its typical output
189+ /// which includes information about all changed dependencies. If
190+ /// [PubOutputMode.summaryOnly] is used, only summary information will be printed.
191+ /// This is useful for cases where the user is typically not interested in
192+ /// what dependencies were changed, such as when running `flutter create` .
193+ ///
175194 /// Will also resolve dependencies in the example folder if present.
176195 Future <void > get ({
177196 required PubContext context,
@@ -181,7 +200,7 @@ abstract class Pub {
181200 String ? flutterRootOverride,
182201 bool checkUpToDate = false ,
183202 bool shouldSkipThirdPartyGenerator = true ,
184- bool printProgress = true ,
203+ PubOutputMode outputMode = PubOutputMode .all
185204 });
186205
187206 /// Runs pub in 'batch' mode.
@@ -221,7 +240,7 @@ abstract class Pub {
221240 required String command,
222241 bool touchesPackageConfig = false ,
223242 bool generateSyntheticPackage = false ,
224- bool printProgress = true ,
243+ PubOutputMode outputMode = PubOutputMode .all
225244 });
226245}
227246
@@ -286,7 +305,7 @@ class _DefaultPub implements Pub {
286305 String ? flutterRootOverride,
287306 bool checkUpToDate = false ,
288307 bool shouldSkipThirdPartyGenerator = true ,
289- bool printProgress = true ,
308+ PubOutputMode outputMode = PubOutputMode .all
290309 }) async {
291310 final String directory = project.directory.path;
292311 final File packageConfigFile = project.packageConfigFile;
@@ -358,7 +377,7 @@ class _DefaultPub implements Pub {
358377 directory: directory,
359378 failureMessage: 'pub $command failed' ,
360379 flutterRootOverride: flutterRootOverride,
361- printProgress : printProgress
380+ outputMode : outputMode,
362381 );
363382 await _updateVersionAndPackageConfig (project);
364383 }
@@ -375,7 +394,7 @@ class _DefaultPub implements Pub {
375394 Future <void > _runWithStdioInherited (
376395 List <String > arguments, {
377396 required String command,
378- required bool printProgress ,
397+ required PubOutputMode outputMode ,
379398 required PubContext context,
380399 required String directory,
381400 String failureMessage = 'pub failed' ,
@@ -384,10 +403,10 @@ class _DefaultPub implements Pub {
384403 int exitCode;
385404
386405 final List <String > pubCommand = _pubCommand (arguments);
387- final Map <String , String > pubEnvironment = await _createPubEnvironment (context, flutterRootOverride);
406+ final Map <String , String > pubEnvironment = await _createPubEnvironment (context: context , flutterRootOverride: flutterRootOverride, summaryOnly : outputMode == PubOutputMode .summaryOnly );
388407
389408 try {
390- if (printProgress ) {
409+ if (outputMode != PubOutputMode .none ) {
391410 final io.Stdio ? stdio = _stdio;
392411 if (stdio == null ) {
393412 // Let pub inherit stdio and output directly to the tool's stdout and
@@ -450,8 +469,7 @@ class _DefaultPub implements Pub {
450469 ? 'exists'
451470 : 'does not exist' ;
452471 buffer.writeln ('Working directory: "$directory " ($directoryExistsMessage )' );
453- final Map <String , String > env = await _createPubEnvironment (context, flutterRootOverride);
454- buffer.write (_stringifyPubEnv (env));
472+ buffer.write (_stringifyPubEnv (pubEnvironment));
455473 throw io.ProcessException (
456474 exception.executable,
457475 exception.arguments,
@@ -517,7 +535,7 @@ class _DefaultPub implements Pub {
517535 if (showTraceForErrors) {
518536 arguments.insert (0 , '--trace' );
519537 }
520- final Map <String , String > pubEnvironment = await _createPubEnvironment (context, flutterRootOverride);
538+ final Map <String , String > pubEnvironment = await _createPubEnvironment (context: context, flutterRootOverride : flutterRootOverride);
521539 final List <String > pubCommand = _pubCommand (arguments);
522540 final int code = await _processUtils.stream (
523541 pubCommand,
@@ -557,14 +575,14 @@ class _DefaultPub implements Pub {
557575 required String command,
558576 bool touchesPackageConfig = false ,
559577 bool generateSyntheticPackage = false ,
560- bool printProgress = true ,
578+ PubOutputMode outputMode = PubOutputMode .all
561579 }) async {
562580 await _runWithStdioInherited (
563581 arguments,
564582 command: command,
565583 directory: _fileSystem.currentDirectory.path,
566584 context: context,
567- printProgress : printProgress ,
585+ outputMode : outputMode ,
568586 );
569587 if (touchesPackageConfig && project != null ) {
570588 await _updateVersionAndPackageConfig (project);
@@ -697,10 +715,15 @@ class _DefaultPub implements Pub {
697715 ///
698716 /// [context] provides extra information to package server requests to
699717 /// understand usage.
700- Future <Map <String , String >> _createPubEnvironment (PubContext context, [ String ? flutterRootOverride ]) async {
718+ Future <Map <String , String >> _createPubEnvironment ({
719+ required PubContext context,
720+ String ? flutterRootOverride,
721+ bool ? summaryOnly = false ,
722+ }) async {
701723 final Map <String , String > environment = < String , String > {
702724 'FLUTTER_ROOT' : flutterRootOverride ?? Cache .flutterRoot! ,
703725 _kPubEnvironmentKey: await _getPubEnvironmentValue (context),
726+ if (summaryOnly ?? false ) 'PUB_SUMMARY_ONLY' : '1' ,
704727 };
705728 final String ? pubCache = _getPubCacheIfAvailable ();
706729 if (pubCache != null ) {
0 commit comments