Reduce animations further when --no-cli-animations is set. (#133598)
This commit is contained in:
@@ -124,13 +124,16 @@ Future<void> main(List<String> args) async {
|
||||
windows: globals.platform.isWindows,
|
||||
);
|
||||
},
|
||||
Terminal: () {
|
||||
AnsiTerminal: () {
|
||||
return AnsiTerminal(
|
||||
stdio: globals.stdio,
|
||||
platform: globals.platform,
|
||||
now: DateTime.now(),
|
||||
isCliAnimationEnabled: featureFlags.isCliAnimationEnabled,
|
||||
// So that we don't animate anything before calling applyFeatureFlags, default
|
||||
// the animations to disabled in real apps.
|
||||
defaultCliAnimationEnabled: false,
|
||||
);
|
||||
// runner.run calls "terminal.applyFeatureFlags()"
|
||||
},
|
||||
PreRunValidator: () => PreRunValidator(fileSystem: globals.fs),
|
||||
},
|
||||
|
||||
@@ -18,6 +18,7 @@ import 'src/base/logger.dart';
|
||||
import 'src/base/process.dart';
|
||||
import 'src/context_runner.dart';
|
||||
import 'src/doctor.dart';
|
||||
import 'src/features.dart';
|
||||
import 'src/globals.dart' as globals;
|
||||
import 'src/reporting/crash_reporting.dart';
|
||||
import 'src/reporting/reporting.dart';
|
||||
@@ -44,6 +45,8 @@ Future<int> run(
|
||||
}
|
||||
|
||||
return runInContext<int>(() async {
|
||||
globals.terminal.applyFeatureFlags(featureFlags);
|
||||
|
||||
reportCrashes ??= !await globals.isRunningOnBot;
|
||||
final FlutterCommandRunner runner = FlutterCommandRunner(verboseHelp: verboseHelp);
|
||||
commands().forEach(runner.addCommand);
|
||||
|
||||
@@ -7,6 +7,9 @@ import 'dart:collection';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
// TODO(ianh): We should remove AppContext's mechanism and replace it with
|
||||
// passing dependencies directly in constructors, methods, etc.
|
||||
|
||||
/// Generates an [AppContext] value.
|
||||
///
|
||||
/// Generators are allowed to return `null`, in which case the context will
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import '../convert.dart';
|
||||
import '../features.dart';
|
||||
import 'io.dart' as io;
|
||||
import 'logger.dart';
|
||||
import 'platform.dart';
|
||||
@@ -69,6 +70,7 @@ class OutputPreferences {
|
||||
}
|
||||
|
||||
/// The command line terminal, if available.
|
||||
// TODO(ianh): merge this with AnsiTerminal, the abstraction isn't giving us anything.
|
||||
abstract class Terminal {
|
||||
/// Create a new test [Terminal].
|
||||
///
|
||||
@@ -81,9 +83,12 @@ abstract class Terminal {
|
||||
/// to perform animations.
|
||||
bool get supportsColor;
|
||||
|
||||
/// Whether to show animations on this terminal.
|
||||
/// Whether animations should be used in the output.
|
||||
bool get isCliAnimationEnabled;
|
||||
|
||||
/// Configures isCliAnimationEnabled based on a [FeatureFlags] object.
|
||||
void applyFeatureFlags(FeatureFlags flags);
|
||||
|
||||
/// Whether the current terminal can display emoji.
|
||||
bool get supportsEmoji;
|
||||
|
||||
@@ -158,11 +163,12 @@ class AnsiTerminal implements Terminal {
|
||||
required io.Stdio stdio,
|
||||
required Platform platform,
|
||||
DateTime? now, // Time used to determine preferredStyle. Defaults to 0001-01-01 00:00.
|
||||
this.isCliAnimationEnabled = true,
|
||||
bool defaultCliAnimationEnabled = true,
|
||||
})
|
||||
: _stdio = stdio,
|
||||
_platform = platform,
|
||||
_now = now ?? DateTime(1);
|
||||
_now = now ?? DateTime(1),
|
||||
_isCliAnimationEnabled = defaultCliAnimationEnabled;
|
||||
|
||||
final io.Stdio _stdio;
|
||||
final Platform _platform;
|
||||
@@ -207,7 +213,14 @@ class AnsiTerminal implements Terminal {
|
||||
bool get supportsColor => _platform.stdoutSupportsAnsi;
|
||||
|
||||
@override
|
||||
final bool isCliAnimationEnabled;
|
||||
bool get isCliAnimationEnabled => _isCliAnimationEnabled;
|
||||
|
||||
bool _isCliAnimationEnabled;
|
||||
|
||||
@override
|
||||
void applyFeatureFlags(FeatureFlags flags) {
|
||||
_isCliAnimationEnabled = flags.isCliAnimationEnabled;
|
||||
}
|
||||
|
||||
// Assume unicode emojis are supported when not on Windows.
|
||||
// If we are on Windows, unicode emojis are supported in Windows Terminal,
|
||||
@@ -419,7 +432,14 @@ class _TestTerminal implements Terminal {
|
||||
final bool supportsColor;
|
||||
|
||||
@override
|
||||
bool get isCliAnimationEnabled => supportsColor;
|
||||
bool get isCliAnimationEnabled => supportsColor && _isCliAnimationEnabled;
|
||||
|
||||
bool _isCliAnimationEnabled = true;
|
||||
|
||||
@override
|
||||
void applyFeatureFlags(FeatureFlags flags) {
|
||||
_isCliAnimationEnabled = flags.isCliAnimationEnabled;
|
||||
}
|
||||
|
||||
@override
|
||||
final bool supportsEmoji;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:process/process.dart';
|
||||
@@ -84,6 +82,8 @@ Future<T> runInContext<T>(
|
||||
return runner();
|
||||
}
|
||||
|
||||
// TODO(ianh): We should split this into two, one for tests (which should be
|
||||
// in test/), and one for production (which should be in executable.dart).
|
||||
return context.run<T>(
|
||||
name: 'global fallbacks',
|
||||
body: runnerWrapper,
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
import 'base/context.dart';
|
||||
|
||||
/// The current [FeatureFlags] implementation.
|
||||
///
|
||||
/// If not injected, a default implementation is provided.
|
||||
FeatureFlags get featureFlags => context.get<FeatureFlags>()!;
|
||||
|
||||
/// The interface used to determine if a particular [Feature] is enabled.
|
||||
|
||||
@@ -49,6 +49,9 @@ import 'runner/flutter_command.dart';
|
||||
import 'runner/local_engine.dart';
|
||||
import 'version.dart';
|
||||
|
||||
// TODO(ianh): We should remove all the global variables and replace them with
|
||||
// arguments (to constructors, methods, etc, as appropriate).
|
||||
|
||||
Artifacts? get artifacts => context.get<Artifacts>();
|
||||
BuildSystem get buildSystem => context.get<BuildSystem>()!;
|
||||
Cache get cache => context.get<Cache>()!;
|
||||
|
||||
@@ -20,6 +20,7 @@ import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/custom_devices.dart';
|
||||
import 'package:flutter_tools/src/custom_devices/custom_device_config.dart';
|
||||
import 'package:flutter_tools/src/custom_devices/custom_devices_config.dart';
|
||||
import 'package:flutter_tools/src/features.dart';
|
||||
import 'package:flutter_tools/src/runner/flutter_command_runner.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
@@ -241,6 +242,11 @@ class FakeTerminal implements Terminal {
|
||||
@override
|
||||
bool get isCliAnimationEnabled => terminal.isCliAnimationEnabled;
|
||||
|
||||
@override
|
||||
void applyFeatureFlags(FeatureFlags flags) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@override
|
||||
bool get supportsEmoji => terminal.supportsEmoji;
|
||||
|
||||
|
||||
@@ -1292,7 +1292,7 @@ void main() {
|
||||
terminal: AnsiTerminal(
|
||||
stdio: fakeStdio,
|
||||
platform: _kNoAnsiPlatform,
|
||||
isCliAnimationEnabled: false,
|
||||
defaultCliAnimationEnabled: false,
|
||||
),
|
||||
stdio: fakeStdio,
|
||||
stopwatchFactory: FakeStopwatchFactory(stopwatch: FakeStopwatch()),
|
||||
|
||||
Reference in New Issue
Block a user