Skip to content

Commit 94c7ecb

Browse files
Mr-Pepebkonyi
andauthored
Add progress bar to artifact downloads (flutter#182836)
<!-- Thanks for filing a pull request! Reviewers are typically assigned within a week of filing a request. To learn more about code review, see our documentation on Tree Hygiene: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md --> Follow-up to flutter#181808 Resolves flutter#14268 Adds a new `DownloadProgress` class that contains the logic for tracking and formatting download progress, i.e., a progress bar, % display, download speed, and ETA. The rest is mostly ANSI control logic. Bumped the width of the lines to 80 characters. Before: <img width="799" height="716" alt="image" src="https://github.com/user-attachments/assets/f479b1b4-bb2b-4c90-bec4-125fba805270" /> After: <img width="886" height="747" alt="image" src="https://github.com/user-attachments/assets/99e08a23-df7f-4aa3-8945-40bc1be13e4a" /> ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. --------- Co-authored-by: Ben Konyi <bkonyi@google.com>
1 parent 41670b7 commit 94c7ecb

6 files changed

Lines changed: 653 additions & 12 deletions

File tree

packages/flutter_tools/lib/src/base/logger.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import 'package:meta/meta.dart';
1010
import '../convert.dart';
1111
import 'common.dart';
1212
import 'io.dart';
13-
import 'terminal.dart' show OutputPreferences, Terminal, TerminalColor;
13+
import 'terminal.dart' show AnsiTerminal, OutputPreferences, Terminal, TerminalColor;
1414
import 'utils.dart';
1515

1616
const kDefaultStatusPadding = 59;
@@ -1404,7 +1404,7 @@ class AnonymousSpinnerStatus extends Status {
14041404
assert(_timer != null);
14051405
assert(_timer!.isActive);
14061406
if (_terminal.supportsColor) {
1407-
_writeToStdOut('\r\x1B[K'); // go to start of line and clear line
1407+
_writeToStdOut(AnsiTerminal.clearAndReturnCode);
14081408
} else {
14091409
_clear(_currentLineLength);
14101410
}

packages/flutter_tools/lib/src/base/terminal.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ class AnsiTerminal implements Terminal {
197197
// Clear the entire line, cursor position does not change.
198198
static const clearEntireLineCode = '\u001b[2K';
199199

200+
// Move cursor to column 0 and erase from cursor to end of line (\x1B[K = \x1B[0K).
201+
// Clears the entire current line regardless of cursor position.
202+
static const clearAndReturnCode = '\r\x1B[K';
203+
200204
static const _colorMap = <TerminalColor, String>{
201205
TerminalColor.red: red,
202206
TerminalColor.green: green,

0 commit comments

Comments
 (0)