Null safety migration of packages/flutter_tools/test/commands.shard/hermetic, part 2/3 (#110708)

* Migrate packages/flutter_tools/test/commands.shard/hermetic, part 2/3

* Fix tests

* Fix analysis

* Chris's comments
This commit is contained in:
Liam Appelbe
2022-09-06 10:39:18 -07:00
committed by GitHub
parent 9dbc09de1f
commit 22cef4898a
12 changed files with 219 additions and 237 deletions

View File

@@ -598,39 +598,39 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase {
inputs = StreamQueue<String>(nonClosingKeystrokes.stream);
final String id = await (askForString(
final String id = (await askForString(
'id',
description:
'Please enter the id you want to device to have. Must contain only '
'alphanumeric or underscore characters.',
example: 'pi',
validator: (String s) async => RegExp(r'^\w+$').hasMatch(s),
) as FutureOr<String>);
))!;
final String label = await (askForString(
final String label = (await askForString(
'label',
description:
'Please enter the label of the device, which is a slightly more verbose '
'name for the device.',
example: 'Raspberry Pi',
) as FutureOr<String>);
))!;
final String sdkNameAndVersion = await (askForString(
final String sdkNameAndVersion = (await askForString(
'SDK name and version',
example: 'Raspberry Pi 4 Model B+',
) as FutureOr<String>);
))!;
final bool enabled = await askForBool(
'enabled',
description: 'Should the device be enabled?',
);
final String targetStr = await (askForString(
final String targetStr = (await askForString(
'target',
description: 'Please enter the hostname or IPv4/v6 address of the device.',
example: 'raspberrypi',
validator: (String s) async => _isValidHostname(s) || _isValidIpAddr(s)
) as FutureOr<String>);
))!;
final InternetAddress? targetIp = InternetAddress.tryParse(targetStr);
final bool useIp = targetIp != null;
@@ -639,20 +639,20 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase {
? InternetAddress.loopbackIPv6
: InternetAddress.loopbackIPv4;
final String username = await (askForString(
final String username = (await askForString(
'username',
description: 'Please enter the username used for ssh-ing into the remote device.',
example: 'pi',
defaultsTo: 'no username',
) as FutureOr<String>);
))!;
final String remoteRunDebugCommand = await (askForString(
final String remoteRunDebugCommand = (await askForString(
'run command',
description:
'Please enter the command executed on the remote device for starting '
r'the app. "/tmp/${appName}" is the path to the asset bundle.',
example: r'flutter-pi /tmp/${appName}'
) as FutureOr<String>);
))!;
final bool usePortForwarding = await askForBool(
'use port forwarding',
@@ -663,12 +663,12 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase {
'not using port forwarding.',
);
final String screenshotCommand = await (askForString(
final String screenshotCommand = (await askForString(
'screenshot command',
description: 'Enter the command executed on the remote device for taking a screenshot.',
example: r"fbgrab /tmp/screenshot.png && cat /tmp/screenshot.png | base64 | tr -d ' \n\t'",
defaultsTo: 'no screenshotting support',
) as FutureOr<String>);
))!;
// SSH expects IPv6 addresses to use the bracket syntax like URIs do too,
// but the IPv6 the user enters is a raw IPv6 address, so we need to wrap it.
@@ -820,8 +820,8 @@ Delete a device from the config file.
Future<FlutterCommandResult> runCommand() async {
checkFeatureEnabled();
final String id = globalResults!['device-id'] as String;
if (!customDevicesConfig.contains(id)) {
final String? id = globalResults!['device-id'] as String?;
if (id == null || !customDevicesConfig.contains(id)) {
throwToolExit('Couldn\'t find device with id "$id" in config at "${customDevicesConfig.configPath}"');
}

View File

@@ -1590,7 +1590,7 @@ class DebounceOperationQueue<T, K> {
final Map<K, Future<T>> _operationQueue = <K, Future<T>>{};
Future<void>? _inProgressAction;
Future<T>? queueAndDebounce(
Future<T> queueAndDebounce(
K operationType,
Duration debounceDuration,
Future<T> Function() action,
@@ -1599,7 +1599,7 @@ class DebounceOperationQueue<T, K> {
// debounce timer and return its future.
if (_operationQueue[operationType] != null) {
_debounceTimers[operationType]?.reset();
return _operationQueue[operationType];
return _operationQueue[operationType]!;
}
// Otherwise, put one in the queue with a timer.