Migrate channel, clean and a few other commands to null safety (#92950)
This commit is contained in:
parent
a8f67ee37f
commit
cdbd0a92e3
@ -6,7 +6,7 @@
|
|||||||
/// where the tool should exit with a clear message to the user
|
/// where the tool should exit with a clear message to the user
|
||||||
/// and no stack trace unless the --verbose option is specified.
|
/// and no stack trace unless the --verbose option is specified.
|
||||||
/// For example: network errors.
|
/// For example: network errors.
|
||||||
Never throwToolExit(String message, { int? exitCode }) {
|
Never throwToolExit(String? message, { int? exitCode }) {
|
||||||
throw ToolExit(message, exitCode: exitCode);
|
throw ToolExit(message, exitCode: exitCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import '../base/common.dart';
|
import '../base/common.dart';
|
||||||
import '../cache.dart';
|
import '../cache.dart';
|
||||||
import '../globals.dart' as globals;
|
import '../globals.dart' as globals;
|
||||||
@ -16,7 +14,6 @@ class ChannelCommand extends FlutterCommand {
|
|||||||
'all',
|
'all',
|
||||||
abbr: 'a',
|
abbr: 'a',
|
||||||
help: 'Include all the available branches (including local branches) when listing channels.',
|
help: 'Include all the available branches (including local branches) when listing channels.',
|
||||||
defaultsTo: false,
|
|
||||||
hide: !verboseHelp,
|
hide: !verboseHelp,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -31,29 +28,30 @@ class ChannelCommand extends FlutterCommand {
|
|||||||
final String category = FlutterCommandCategory.sdk;
|
final String category = FlutterCommandCategory.sdk;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get invocation => '${runner.executableName} $name [<channel-name>]';
|
String get invocation => '${runner?.executableName} $name [<channel-name>]';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Set<DevelopmentArtifact>> get requiredArtifacts async => const <DevelopmentArtifact>{};
|
Future<Set<DevelopmentArtifact>> get requiredArtifacts async => const <DevelopmentArtifact>{};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<FlutterCommandResult> runCommand() async {
|
Future<FlutterCommandResult> runCommand() async {
|
||||||
switch (argResults.rest.length) {
|
final List<String> rest = argResults?.rest ?? <String>[];
|
||||||
|
switch (rest.length) {
|
||||||
case 0:
|
case 0:
|
||||||
await _listChannels(
|
await _listChannels(
|
||||||
showAll: boolArg('all'),
|
showAll: boolArg('all'),
|
||||||
verbose: globalResults['verbose'] as bool,
|
verbose: globalResults?['verbose'] == true,
|
||||||
);
|
);
|
||||||
return FlutterCommandResult.success();
|
return FlutterCommandResult.success();
|
||||||
case 1:
|
case 1:
|
||||||
await _switchChannel(argResults.rest[0]);
|
await _switchChannel(rest[0]);
|
||||||
return FlutterCommandResult.success();
|
return FlutterCommandResult.success();
|
||||||
default:
|
default:
|
||||||
throw ToolExit('Too many arguments.\n$usage');
|
throw ToolExit('Too many arguments.\n$usage');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _listChannels({ bool showAll, bool verbose }) async {
|
Future<void> _listChannels({ required bool showAll, required bool verbose }) async {
|
||||||
// Beware: currentBranch could contain PII. See getBranchName().
|
// Beware: currentBranch could contain PII. See getBranchName().
|
||||||
final String currentChannel = globals.flutterVersion.channel;
|
final String currentChannel = globals.flutterVersion.channel;
|
||||||
final String currentBranch = globals.flutterVersion.getBranchName();
|
final String currentBranch = globals.flutterVersion.getBranchName();
|
||||||
|
@ -2,10 +2,9 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
|
import '../../src/macos/xcode.dart';
|
||||||
import '../base/file_system.dart';
|
import '../base/file_system.dart';
|
||||||
import '../base/logger.dart';
|
import '../base/logger.dart';
|
||||||
import '../build_info.dart';
|
import '../build_info.dart';
|
||||||
@ -40,7 +39,8 @@ class CleanCommand extends FlutterCommand {
|
|||||||
// Clean Xcode to remove intermediate DerivedData artifacts.
|
// Clean Xcode to remove intermediate DerivedData artifacts.
|
||||||
// Do this before removing ephemeral directory, which would delete the xcworkspace.
|
// Do this before removing ephemeral directory, which would delete the xcworkspace.
|
||||||
final FlutterProject flutterProject = FlutterProject.current();
|
final FlutterProject flutterProject = FlutterProject.current();
|
||||||
if (globals.xcode.isInstalledAndMeetsVersionCheck) {
|
final Xcode? xcode = globals.xcode;
|
||||||
|
if (xcode != null && xcode.isInstalledAndMeetsVersionCheck) {
|
||||||
await _cleanXcode(flutterProject.ios);
|
await _cleanXcode(flutterProject.ios);
|
||||||
await _cleanXcode(flutterProject.macos);
|
await _cleanXcode(flutterProject.macos);
|
||||||
}
|
}
|
||||||
@ -78,15 +78,16 @@ class CleanCommand extends FlutterCommand {
|
|||||||
'Cleaning Xcode workspace...',
|
'Cleaning Xcode workspace...',
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
|
final XcodeProjectInterpreter xcodeProjectInterpreter = globals.xcodeProjectInterpreter!;
|
||||||
final Directory xcodeWorkspace = xcodeProject.xcodeWorkspace;
|
final Directory xcodeWorkspace = xcodeProject.xcodeWorkspace;
|
||||||
final XcodeProjectInfo projectInfo = await globals.xcodeProjectInterpreter.getInfo(xcodeWorkspace.parent.path);
|
final XcodeProjectInfo projectInfo = await xcodeProjectInterpreter.getInfo(xcodeWorkspace.parent.path);
|
||||||
for (final String scheme in projectInfo.schemes) {
|
for (final String scheme in projectInfo.schemes) {
|
||||||
await globals.xcodeProjectInterpreter.cleanWorkspace(xcodeWorkspace.path, scheme, verbose: _verbose);
|
await xcodeProjectInterpreter.cleanWorkspace(xcodeWorkspace.path, scheme, verbose: _verbose);
|
||||||
}
|
}
|
||||||
} on Exception catch (error) {
|
} on Exception catch (error) {
|
||||||
globals.printTrace('Could not clean Xcode workspace: $error');
|
globals.printTrace('Could not clean Xcode workspace: $error');
|
||||||
} finally {
|
} finally {
|
||||||
xcodeStatus?.stop();
|
xcodeStatus.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
import '../../src/android/android_sdk.dart';
|
||||||
|
import '../../src/android/android_studio.dart';
|
||||||
import '../base/common.dart';
|
import '../base/common.dart';
|
||||||
import '../convert.dart';
|
import '../convert.dart';
|
||||||
import '../features.dart';
|
import '../features.dart';
|
||||||
@ -14,7 +14,6 @@ import '../runner/flutter_command.dart';
|
|||||||
class ConfigCommand extends FlutterCommand {
|
class ConfigCommand extends FlutterCommand {
|
||||||
ConfigCommand({ bool verboseHelp = false }) {
|
ConfigCommand({ bool verboseHelp = false }) {
|
||||||
argParser.addFlag('analytics',
|
argParser.addFlag('analytics',
|
||||||
negatable: true,
|
|
||||||
help: 'Enable or disable reporting anonymously tool usage statistics and crash reports.');
|
help: 'Enable or disable reporting anonymously tool usage statistics and crash reports.');
|
||||||
argParser.addFlag('clear-ios-signing-cert',
|
argParser.addFlag('clear-ios-signing-cert',
|
||||||
negatable: false,
|
negatable: false,
|
||||||
@ -28,13 +27,13 @@ class ConfigCommand extends FlutterCommand {
|
|||||||
hide: !verboseHelp,
|
hide: !verboseHelp,
|
||||||
help: 'Print config values as json.');
|
help: 'Print config values as json.');
|
||||||
for (final Feature feature in allFeatures) {
|
for (final Feature feature in allFeatures) {
|
||||||
if (feature.configSetting == null) {
|
final String? configSetting = feature.configSetting;
|
||||||
|
if (configSetting == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
argParser.addFlag(
|
argParser.addFlag(
|
||||||
feature.configSetting,
|
configSetting,
|
||||||
help: feature.generateHelpMessage(),
|
help: feature.generateHelpMessage(),
|
||||||
negatable: true,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
argParser.addFlag(
|
argParser.addFlag(
|
||||||
@ -70,15 +69,16 @@ class ConfigCommand extends FlutterCommand {
|
|||||||
final Map<String, Feature> featuresByName = <String, Feature>{};
|
final Map<String, Feature> featuresByName = <String, Feature>{};
|
||||||
final String channel = globals.flutterVersion.channel;
|
final String channel = globals.flutterVersion.channel;
|
||||||
for (final Feature feature in allFeatures) {
|
for (final Feature feature in allFeatures) {
|
||||||
if (feature.configSetting != null) {
|
final String? configSetting = feature.configSetting;
|
||||||
featuresByName[feature.configSetting] = feature;
|
if (configSetting != null) {
|
||||||
|
featuresByName[configSetting] = feature;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String values = globals.config.keys
|
String values = globals.config.keys
|
||||||
.map<String>((String key) {
|
.map<String>((String key) {
|
||||||
String configFooter = '';
|
String configFooter = '';
|
||||||
if (featuresByName.containsKey(key)) {
|
if (featuresByName.containsKey(key)) {
|
||||||
final FeatureChannelSetting setting = featuresByName[key].getSettingForChannel(channel);
|
final FeatureChannelSetting setting = featuresByName[key]!.getSettingForChannel(channel);
|
||||||
if (!setting.available) {
|
if (!setting.available) {
|
||||||
configFooter = '(Unavailable)';
|
configFooter = '(Unavailable)';
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ class ConfigCommand extends FlutterCommand {
|
|||||||
|
|
||||||
/// Return null to disable analytics recording of the `config` command.
|
/// Return null to disable analytics recording of the `config` command.
|
||||||
@override
|
@override
|
||||||
Future<String> get usagePath async => null;
|
Future<String?> get usagePath async => null;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<FlutterCommandResult> runCommand() async {
|
Future<FlutterCommandResult> runCommand() async {
|
||||||
@ -108,14 +108,15 @@ class ConfigCommand extends FlutterCommand {
|
|||||||
|
|
||||||
if (boolArg('clear-features')) {
|
if (boolArg('clear-features')) {
|
||||||
for (final Feature feature in allFeatures) {
|
for (final Feature feature in allFeatures) {
|
||||||
if (feature.configSetting != null) {
|
final String? configSetting = feature.configSetting;
|
||||||
globals.config.removeValue(feature.configSetting);
|
if (configSetting != null) {
|
||||||
|
globals.config.removeValue(configSetting);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return FlutterCommandResult.success();
|
return FlutterCommandResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argResults.wasParsed('analytics')) {
|
if (argResults?.wasParsed('analytics') == true) {
|
||||||
final bool value = boolArg('analytics');
|
final bool value = boolArg('analytics');
|
||||||
// The tool sends the analytics event *before* toggling the flag
|
// The tool sends the analytics event *before* toggling the flag
|
||||||
// intentionally to be sure that opt-out events are sent correctly.
|
// intentionally to be sure that opt-out events are sent correctly.
|
||||||
@ -130,20 +131,20 @@ class ConfigCommand extends FlutterCommand {
|
|||||||
globals.printStatus('Analytics reporting ${value ? 'enabled' : 'disabled'}.');
|
globals.printStatus('Analytics reporting ${value ? 'enabled' : 'disabled'}.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argResults.wasParsed('android-sdk')) {
|
if (argResults?.wasParsed('android-sdk') == true) {
|
||||||
_updateConfig('android-sdk', stringArg('android-sdk'));
|
_updateConfig('android-sdk', stringArg('android-sdk')!);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argResults.wasParsed('android-studio-dir')) {
|
if (argResults?.wasParsed('android-studio-dir') == true) {
|
||||||
_updateConfig('android-studio-dir', stringArg('android-studio-dir'));
|
_updateConfig('android-studio-dir', stringArg('android-studio-dir')!);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argResults.wasParsed('clear-ios-signing-cert')) {
|
if (argResults?.wasParsed('clear-ios-signing-cert') == true) {
|
||||||
_updateConfig('ios-signing-cert', '');
|
_updateConfig('ios-signing-cert', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argResults.wasParsed('build-dir')) {
|
if (argResults?.wasParsed('build-dir') == true) {
|
||||||
final String buildDir = stringArg('build-dir');
|
final String buildDir = stringArg('build-dir')!;
|
||||||
if (globals.fs.path.isAbsolute(buildDir)) {
|
if (globals.fs.path.isAbsolute(buildDir)) {
|
||||||
throwToolExit('build-dir should be a relative path');
|
throwToolExit('build-dir should be a relative path');
|
||||||
}
|
}
|
||||||
@ -151,17 +152,18 @@ class ConfigCommand extends FlutterCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (final Feature feature in allFeatures) {
|
for (final Feature feature in allFeatures) {
|
||||||
if (feature.configSetting == null) {
|
final String? configSetting = feature.configSetting;
|
||||||
|
if (configSetting == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (argResults.wasParsed(feature.configSetting)) {
|
if (argResults?.wasParsed(configSetting) == true) {
|
||||||
final bool keyValue = boolArg(feature.configSetting);
|
final bool keyValue = boolArg(configSetting);
|
||||||
globals.config.setValue(feature.configSetting, keyValue);
|
globals.config.setValue(configSetting, keyValue);
|
||||||
globals.printStatus('Setting "${feature.configSetting}" value to "$keyValue".');
|
globals.printStatus('Setting "$configSetting" value to "$keyValue".');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argResults.arguments.isEmpty) {
|
if (argResults == null || argResults!.arguments.isEmpty) {
|
||||||
globals.printStatus(usage);
|
globals.printStatus(usage);
|
||||||
} else {
|
} else {
|
||||||
globals.printStatus('\nYou may need to restart any open editors for them to read new settings.');
|
globals.printStatus('\nYou may need to restart any open editors for them to read new settings.');
|
||||||
@ -172,17 +174,19 @@ class ConfigCommand extends FlutterCommand {
|
|||||||
|
|
||||||
Future<void> handleMachine() async {
|
Future<void> handleMachine() async {
|
||||||
// Get all the current values.
|
// Get all the current values.
|
||||||
final Map<String, dynamic> results = <String, dynamic>{};
|
final Map<String, Object?> results = <String, Object?>{};
|
||||||
for (final String key in globals.config.keys) {
|
for (final String key in globals.config.keys) {
|
||||||
results[key] = globals.config.getValue(key);
|
results[key] = globals.config.getValue(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure we send any calculated ones, if overrides don't exist.
|
// Ensure we send any calculated ones, if overrides don't exist.
|
||||||
if (results['android-studio-dir'] == null && globals.androidStudio != null) {
|
final AndroidStudio? androidStudio = globals.androidStudio;
|
||||||
results['android-studio-dir'] = globals.androidStudio.directory;
|
if (results['android-studio-dir'] == null && androidStudio != null) {
|
||||||
|
results['android-studio-dir'] = androidStudio.directory;
|
||||||
}
|
}
|
||||||
if (results['android-sdk'] == null && globals.androidSdk != null) {
|
final AndroidSdk? androidSdk = globals.androidSdk;
|
||||||
results['android-sdk'] = globals.androidSdk.directory.path;
|
if (results['android-sdk'] == null && androidSdk != null) {
|
||||||
|
results['android-sdk'] = androidSdk.directory.path;
|
||||||
}
|
}
|
||||||
|
|
||||||
globals.printStatus(const JsonEncoder.withIndent(' ').convert(results));
|
globals.printStatus(const JsonEncoder.withIndent(' ').convert(results));
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import '../debug_adapters/server.dart';
|
import '../debug_adapters/server.dart';
|
||||||
@ -31,7 +29,6 @@ class DebugAdapterCommand extends FlutterCommand {
|
|||||||
argParser
|
argParser
|
||||||
.addFlag(
|
.addFlag(
|
||||||
'test',
|
'test',
|
||||||
defaultsTo: false,
|
|
||||||
help: 'Whether to use the "flutter test" debug adapter to run tests'
|
help: 'Whether to use the "flutter test" debug adapter to run tests'
|
||||||
' and emit custom events for test progress/results.',
|
' and emit custom events for test progress/results.',
|
||||||
);
|
);
|
||||||
@ -59,9 +56,9 @@ class DebugAdapterCommand extends FlutterCommand {
|
|||||||
globals.stdio.stdout.nonBlocking,
|
globals.stdio.stdout.nonBlocking,
|
||||||
fileSystem: globals.fs,
|
fileSystem: globals.fs,
|
||||||
platform: globals.platform,
|
platform: globals.platform,
|
||||||
ipv6: ipv6,
|
ipv6: ipv6 == true,
|
||||||
enableDds: enableDds,
|
enableDds: enableDds,
|
||||||
test: boolArg('test') ?? false,
|
test: boolArg('test'),
|
||||||
);
|
);
|
||||||
|
|
||||||
await server.channel.closed;
|
await server.channel.closed;
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import '../base/common.dart';
|
import '../base/common.dart';
|
||||||
import '../base/utils.dart';
|
import '../base/utils.dart';
|
||||||
import '../convert.dart';
|
import '../convert.dart';
|
||||||
@ -20,7 +18,6 @@ class DevicesCommand extends FlutterCommand {
|
|||||||
argParser.addOption(
|
argParser.addOption(
|
||||||
'timeout',
|
'timeout',
|
||||||
abbr: 't',
|
abbr: 't',
|
||||||
defaultsTo: null,
|
|
||||||
help: '(deprecated) This option has been replaced by "--${FlutterOptions.kDeviceTimeout}".',
|
help: '(deprecated) This option has been replaced by "--${FlutterOptions.kDeviceTimeout}".',
|
||||||
hide: !verboseHelp,
|
hide: !verboseHelp,
|
||||||
);
|
);
|
||||||
@ -37,9 +34,9 @@ class DevicesCommand extends FlutterCommand {
|
|||||||
final String category = FlutterCommandCategory.tools;
|
final String category = FlutterCommandCategory.tools;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Duration get deviceDiscoveryTimeout {
|
Duration? get deviceDiscoveryTimeout {
|
||||||
if (argResults['timeout'] != null) {
|
if (argResults?['timeout'] != null) {
|
||||||
final int timeoutSeconds = int.tryParse(stringArg('timeout'));
|
final int? timeoutSeconds = int.tryParse(stringArg('timeout')!);
|
||||||
if (timeoutSeconds == null) {
|
if (timeoutSeconds == null) {
|
||||||
throwToolExit('Could not parse -t/--timeout argument. It must be an integer.');
|
throwToolExit('Could not parse -t/--timeout argument. It must be an integer.');
|
||||||
}
|
}
|
||||||
@ -50,7 +47,7 @@ class DevicesCommand extends FlutterCommand {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> validateCommand() {
|
Future<void> validateCommand() {
|
||||||
if (argResults['timeout'] != null) {
|
if (argResults?['timeout'] != null) {
|
||||||
globals.printError('${globals.logger.terminal.warningMark} The "--timeout" argument is deprecated; use "--${FlutterOptions.kDeviceTimeout}" instead.');
|
globals.printError('${globals.logger.terminal.warningMark} The "--timeout" argument is deprecated; use "--${FlutterOptions.kDeviceTimeout}" instead.');
|
||||||
}
|
}
|
||||||
return super.validateCommand();
|
return super.validateCommand();
|
||||||
@ -58,14 +55,14 @@ class DevicesCommand extends FlutterCommand {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<FlutterCommandResult> runCommand() async {
|
Future<FlutterCommandResult> runCommand() async {
|
||||||
if (!globals.doctor.canListAnything) {
|
if (globals.doctor?.canListAnything != true) {
|
||||||
throwToolExit(
|
throwToolExit(
|
||||||
"Unable to locate a development device; please run 'flutter doctor' for "
|
"Unable to locate a development device; please run 'flutter doctor' for "
|
||||||
'information about installing additional components.',
|
'information about installing additional components.',
|
||||||
exitCode: 1);
|
exitCode: 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Device> devices = await globals.deviceManager.refreshAllConnectedDevices(timeout: deviceDiscoveryTimeout);
|
final List<Device> devices = await globals.deviceManager?.refreshAllConnectedDevices(timeout: deviceDiscoveryTimeout) ?? <Device>[];
|
||||||
|
|
||||||
if (boolArg('machine')) {
|
if (boolArg('machine')) {
|
||||||
await printDevicesAsJson(devices);
|
await printDevicesAsJson(devices);
|
||||||
@ -93,7 +90,7 @@ class DevicesCommand extends FlutterCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _printDiagnostics() async {
|
Future<void> _printDiagnostics() async {
|
||||||
final List<String> diagnostics = await globals.deviceManager.getDeviceDiagnostics();
|
final List<String> diagnostics = await globals.deviceManager?.getDeviceDiagnostics() ?? <String>[];
|
||||||
if (diagnostics.isNotEmpty) {
|
if (diagnostics.isNotEmpty) {
|
||||||
globals.printStatus('');
|
globals.printStatus('');
|
||||||
for (final String diagnostic in diagnostics) {
|
for (final String diagnostic in diagnostics) {
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import '../base/common.dart';
|
import '../base/common.dart';
|
||||||
@ -34,10 +32,10 @@ class LogsCommand extends FlutterCommand {
|
|||||||
@override
|
@override
|
||||||
Future<Set<DevelopmentArtifact>> get requiredArtifacts async => const <DevelopmentArtifact>{};
|
Future<Set<DevelopmentArtifact>> get requiredArtifacts async => const <DevelopmentArtifact>{};
|
||||||
|
|
||||||
Device device;
|
Device? device;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<FlutterCommandResult> verifyThenRunCommand(String commandPath) async {
|
Future<FlutterCommandResult> verifyThenRunCommand(String? commandPath) async {
|
||||||
device = await findTargetDevice(includeUnsupportedDevices: true);
|
device = await findTargetDevice(includeUnsupportedDevices: true);
|
||||||
if (device == null) {
|
if (device == null) {
|
||||||
throwToolExit(null);
|
throwToolExit(null);
|
||||||
@ -47,11 +45,12 @@ class LogsCommand extends FlutterCommand {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<FlutterCommandResult> runCommand() async {
|
Future<FlutterCommandResult> runCommand() async {
|
||||||
|
final Device cachedDevice = device!;
|
||||||
if (boolArg('clear')) {
|
if (boolArg('clear')) {
|
||||||
device.clearLogs();
|
cachedDevice.clearLogs();
|
||||||
}
|
}
|
||||||
|
|
||||||
final DeviceLogReader logReader = await device.getLogReader();
|
final DeviceLogReader logReader = await cachedDevice.getLogReader();
|
||||||
|
|
||||||
globals.printStatus('Showing $logReader logs:');
|
globals.printStatus('Showing $logReader logs:');
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import '../runner/flutter_command.dart';
|
import '../runner/flutter_command.dart';
|
||||||
|
|
||||||
class MakeHostAppEditableCommand extends FlutterCommand {
|
class MakeHostAppEditableCommand extends FlutterCommand {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user