Skip to content

Commit ae1a719

Browse files
authored
fix FLUTTER_ANSI_TERMINAL check (flutter#8544)
* fix FLUTTER_ANSI_TERMINAL check should have been included in the previous PR :( * review comments
1 parent c54cc96 commit ae1a719

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

bin/flutter.ps1

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ If (Test-Path Env:\FLUTTER_ANSI_TERMINAL) { Remove-Item Env:\FLUTTER_ANSI_TERMIN
1818
$stdout = [Win32.NativeMethods]::GetStdHandle(-11) # STD_OUTPUT_HANDLE
1919
If ($stdout -ne -1) {
2020
$mode = 0
21-
$result = [Win32.NativeMethods]::GetConsoleMode($stdout, [ref]$mode)
22-
If ($result) {
21+
If ([Win32.NativeMethods]::GetConsoleMode($stdout, [ref]$mode)) {
2322
$mode = $mode -bor 4 # ENABLE_VIRTUAL_TERMINAL_PROCESSING
24-
$env:FLUTTER_ANSI_TERMINAL = [Win32.NativeMethods]::SetConsoleMode($stdout, $mode)
23+
If ([Win32.NativeMethods]::SetConsoleMode($stdout, $mode)) {
24+
$env:FLUTTER_ANSI_TERMINAL = "true"
25+
}
2526
}
2627
}
2728

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ class AnsiTerminal {
245245
AnsiTerminal() {
246246
String term = platform.environment['TERM'];
247247
// FLUTTER_ANSI_TERMINAL is a work-around for https://github.com/dart-lang/sdk/issues/28614
248-
String flutterAnsiTerm = platform.environment['FLUTTER_ANSI_TERMINAL'];
249-
supportsColor = (term != null && term != 'dumb') || (flutterAnsiTerm != null);
248+
bool flutterAnsiTerm = platform.environment.containsKey('FLUTTER_ANSI_TERMINAL');
249+
supportsColor = (term != null && term != 'dumb') || flutterAnsiTerm;
250250
}
251251

252252
static const String KEY_F1 = '\u001BOP';

0 commit comments

Comments
 (0)