Unverified Commit 22cef489 authored by Liam Appelbe's avatar Liam Appelbe Committed by GitHub

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
parent 9dbc09de
...@@ -598,39 +598,39 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase { ...@@ -598,39 +598,39 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase {
inputs = StreamQueue<String>(nonClosingKeystrokes.stream); inputs = StreamQueue<String>(nonClosingKeystrokes.stream);
final String id = await (askForString( final String id = (await askForString(
'id', 'id',
description: description:
'Please enter the id you want to device to have. Must contain only ' 'Please enter the id you want to device to have. Must contain only '
'alphanumeric or underscore characters.', 'alphanumeric or underscore characters.',
example: 'pi', example: 'pi',
validator: (String s) async => RegExp(r'^\w+$').hasMatch(s), validator: (String s) async => RegExp(r'^\w+$').hasMatch(s),
) as FutureOr<String>); ))!;
final String label = await (askForString( final String label = (await askForString(
'label', 'label',
description: description:
'Please enter the label of the device, which is a slightly more verbose ' 'Please enter the label of the device, which is a slightly more verbose '
'name for the device.', 'name for the device.',
example: 'Raspberry Pi', example: 'Raspberry Pi',
) as FutureOr<String>); ))!;
final String sdkNameAndVersion = await (askForString( final String sdkNameAndVersion = (await askForString(
'SDK name and version', 'SDK name and version',
example: 'Raspberry Pi 4 Model B+', example: 'Raspberry Pi 4 Model B+',
) as FutureOr<String>); ))!;
final bool enabled = await askForBool( final bool enabled = await askForBool(
'enabled', 'enabled',
description: 'Should the device be enabled?', description: 'Should the device be enabled?',
); );
final String targetStr = await (askForString( final String targetStr = (await askForString(
'target', 'target',
description: 'Please enter the hostname or IPv4/v6 address of the device.', description: 'Please enter the hostname or IPv4/v6 address of the device.',
example: 'raspberrypi', example: 'raspberrypi',
validator: (String s) async => _isValidHostname(s) || _isValidIpAddr(s) validator: (String s) async => _isValidHostname(s) || _isValidIpAddr(s)
) as FutureOr<String>); ))!;
final InternetAddress? targetIp = InternetAddress.tryParse(targetStr); final InternetAddress? targetIp = InternetAddress.tryParse(targetStr);
final bool useIp = targetIp != null; final bool useIp = targetIp != null;
...@@ -639,20 +639,20 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase { ...@@ -639,20 +639,20 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase {
? InternetAddress.loopbackIPv6 ? InternetAddress.loopbackIPv6
: InternetAddress.loopbackIPv4; : InternetAddress.loopbackIPv4;
final String username = await (askForString( final String username = (await askForString(
'username', 'username',
description: 'Please enter the username used for ssh-ing into the remote device.', description: 'Please enter the username used for ssh-ing into the remote device.',
example: 'pi', example: 'pi',
defaultsTo: 'no username', defaultsTo: 'no username',
) as FutureOr<String>); ))!;
final String remoteRunDebugCommand = await (askForString( final String remoteRunDebugCommand = (await askForString(
'run command', 'run command',
description: description:
'Please enter the command executed on the remote device for starting ' 'Please enter the command executed on the remote device for starting '
r'the app. "/tmp/${appName}" is the path to the asset bundle.', r'the app. "/tmp/${appName}" is the path to the asset bundle.',
example: r'flutter-pi /tmp/${appName}' example: r'flutter-pi /tmp/${appName}'
) as FutureOr<String>); ))!;
final bool usePortForwarding = await askForBool( final bool usePortForwarding = await askForBool(
'use port forwarding', 'use port forwarding',
...@@ -663,12 +663,12 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase { ...@@ -663,12 +663,12 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase {
'not using port forwarding.', 'not using port forwarding.',
); );
final String screenshotCommand = await (askForString( final String screenshotCommand = (await askForString(
'screenshot command', 'screenshot command',
description: 'Enter the command executed on the remote device for taking a screenshot.', 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'", example: r"fbgrab /tmp/screenshot.png && cat /tmp/screenshot.png | base64 | tr -d ' \n\t'",
defaultsTo: 'no screenshotting support', defaultsTo: 'no screenshotting support',
) as FutureOr<String>); ))!;
// SSH expects IPv6 addresses to use the bracket syntax like URIs do too, // 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. // 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. ...@@ -820,8 +820,8 @@ Delete a device from the config file.
Future<FlutterCommandResult> runCommand() async { Future<FlutterCommandResult> runCommand() async {
checkFeatureEnabled(); checkFeatureEnabled();
final String id = globalResults!['device-id'] as String; final String? id = globalResults!['device-id'] as String?;
if (!customDevicesConfig.contains(id)) { if (id == null || !customDevicesConfig.contains(id)) {
throwToolExit('Couldn\'t find device with id "$id" in config at "${customDevicesConfig.configPath}"'); throwToolExit('Couldn\'t find device with id "$id" in config at "${customDevicesConfig.configPath}"');
} }
......
...@@ -1590,7 +1590,7 @@ class DebounceOperationQueue<T, K> { ...@@ -1590,7 +1590,7 @@ class DebounceOperationQueue<T, K> {
final Map<K, Future<T>> _operationQueue = <K, Future<T>>{}; final Map<K, Future<T>> _operationQueue = <K, Future<T>>{};
Future<void>? _inProgressAction; Future<void>? _inProgressAction;
Future<T>? queueAndDebounce( Future<T> queueAndDebounce(
K operationType, K operationType,
Duration debounceDuration, Duration debounceDuration,
Future<T> Function() action, Future<T> Function() action,
...@@ -1599,7 +1599,7 @@ class DebounceOperationQueue<T, K> { ...@@ -1599,7 +1599,7 @@ class DebounceOperationQueue<T, K> {
// debounce timer and return its future. // debounce timer and return its future.
if (_operationQueue[operationType] != null) { if (_operationQueue[operationType] != null) {
_debounceTimers[operationType]?.reset(); _debounceTimers[operationType]?.reset();
return _operationQueue[operationType]; return _operationQueue[operationType]!;
} }
// Otherwise, put one in the queue with a timer. // Otherwise, put one in the queue with a timer.
......
...@@ -2,8 +2,6 @@ ...@@ -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 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
...@@ -23,7 +21,7 @@ import '../../src/test_build_system.dart'; ...@@ -23,7 +21,7 @@ import '../../src/test_build_system.dart';
import '../../src/test_flutter_command_runner.dart'; import '../../src/test_flutter_command_runner.dart';
void main() { void main() {
FileSystem fileSystem; late FileSystem fileSystem;
final Platform fakePlatform = FakePlatform( final Platform fakePlatform = FakePlatform(
environment: <String, String>{ environment: <String, String>{
'FLUTTER_ROOT': '/', 'FLUTTER_ROOT': '/',
...@@ -243,7 +241,7 @@ class TestWebBuildCommand extends FlutterCommand { ...@@ -243,7 +241,7 @@ class TestWebBuildCommand extends FlutterCommand {
final String description = 'Build a test executable app.'; final String description = 'Build a test executable app.';
@override @override
Future<FlutterCommandResult> runCommand() async => null; Future<FlutterCommandResult> runCommand() async => FlutterCommandResult.fail();
@override @override
bool get shouldRunPub => false; bool get shouldRunPub => false;
......
...@@ -2,8 +2,6 @@ ...@@ -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 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:file_testing/file_testing.dart'; import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
...@@ -43,10 +41,9 @@ final Platform notWindowsPlatform = FakePlatform( ...@@ -43,10 +41,9 @@ final Platform notWindowsPlatform = FakePlatform(
); );
void main() { void main() {
FileSystem fileSystem; late FileSystem fileSystem;
late ProcessManager processManager;
ProcessManager processManager; late TestUsage usage;
TestUsage usage;
setUpAll(() { setUpAll(() {
Cache.disableLocking(); Cache.disableLocking();
...@@ -75,7 +72,7 @@ void main() { ...@@ -75,7 +72,7 @@ void main() {
// Returns the command matching the build_windows call to generate CMake // Returns the command matching the build_windows call to generate CMake
// files. // files.
FakeCommand cmakeGenerationCommand({ FakeCommand cmakeGenerationCommand({
void Function() onRun, void Function()? onRun,
String generator = _defaultGenerator, String generator = _defaultGenerator,
}) { }) {
return FakeCommand( return FakeCommand(
...@@ -95,7 +92,7 @@ void main() { ...@@ -95,7 +92,7 @@ void main() {
// Returns the command matching the build_windows call to build. // Returns the command matching the build_windows call to build.
FakeCommand buildCommand(String buildMode, { FakeCommand buildCommand(String buildMode, {
bool verbose = false, bool verbose = false,
void Function() onRun, void Function()? onRun,
String stdout = '', String stdout = '',
}) { }) {
return FakeCommand( return FakeCommand(
...@@ -974,7 +971,7 @@ class FakeVisualStudio extends Fake implements VisualStudio { ...@@ -974,7 +971,7 @@ class FakeVisualStudio extends Fake implements VisualStudio {
}); });
@override @override
final String cmakePath; final String? cmakePath;
@override @override
final String cmakeGenerator; final String cmakeGenerator;
......
...@@ -2,8 +2,6 @@ ...@@ -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 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
...@@ -28,13 +26,13 @@ class FakePub extends Fake implements Pub { ...@@ -28,13 +26,13 @@ class FakePub extends Fake implements Pub {
@override @override
Future<void> get({ Future<void> get({
PubContext context, PubContext? context,
String directory, String? directory,
bool skipIfAbsent = false, bool skipIfAbsent = false,
bool upgrade = false, bool upgrade = false,
bool offline = false, bool offline = false,
bool generateSyntheticPackage = false, bool generateSyntheticPackage = false,
String flutterRootOverride, String? flutterRootOverride,
bool checkUpToDate = false, bool checkUpToDate = false,
bool shouldSkipThirdPartyGenerator = true, bool shouldSkipThirdPartyGenerator = true,
bool printProgress = true, bool printProgress = true,
...@@ -50,8 +48,8 @@ class FakePub extends Fake implements Pub { ...@@ -50,8 +48,8 @@ class FakePub extends Fake implements Pub {
void main() { void main() {
group('usageValues', () { group('usageValues', () {
Testbed testbed; late Testbed testbed;
FakePub fakePub; late FakePub fakePub;
setUpAll(() { setUpAll(() {
Cache.disableLocking(); Cache.disableLocking();
......
...@@ -2,8 +2,6 @@ ...@@ -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 'dart:typed_data'; import 'dart:typed_data';
...@@ -23,7 +21,6 @@ import 'package:flutter_tools/src/commands/custom_devices.dart'; ...@@ -23,7 +21,6 @@ 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_device_config.dart';
import 'package:flutter_tools/src/custom_devices/custom_devices_config.dart'; import 'package:flutter_tools/src/custom_devices/custom_devices_config.dart';
import 'package:flutter_tools/src/runner/flutter_command_runner.dart'; import 'package:flutter_tools/src/runner/flutter_command_runner.dart';
import 'package:meta/meta.dart';
import '../../src/common.dart'; import '../../src/common.dart';
import '../../src/context.dart'; import '../../src/context.dart';
...@@ -171,7 +168,7 @@ final Platform windowsPlatform = FakePlatform( ...@@ -171,7 +168,7 @@ final Platform windowsPlatform = FakePlatform(
); );
class FakeTerminal implements Terminal { class FakeTerminal implements Terminal {
factory FakeTerminal({Platform platform}) { factory FakeTerminal({required Platform platform}) {
return FakeTerminal._private( return FakeTerminal._private(
stdio: FakeStdio(), stdio: FakeStdio(),
platform: platform platform: platform
...@@ -179,8 +176,8 @@ class FakeTerminal implements Terminal { ...@@ -179,8 +176,8 @@ class FakeTerminal implements Terminal {
} }
FakeTerminal._private({ FakeTerminal._private({
this.stdio, required this.stdio,
Platform platform required Platform platform
}) : }) :
terminal = AnsiTerminal( terminal = AnsiTerminal(
stdio: stdio, stdio: stdio,
...@@ -215,9 +212,9 @@ class FakeTerminal implements Terminal { ...@@ -215,9 +212,9 @@ class FakeTerminal implements Terminal {
@override @override
Future<String> promptForCharInput( Future<String> promptForCharInput(
List<String> acceptedCharacters, { List<String> acceptedCharacters, {
Logger logger, required Logger logger,
String prompt, String? prompt,
int defaultChoiceIndex, int? defaultChoiceIndex,
bool displayAcceptedCharacters = true bool displayAcceptedCharacters = true
}) => terminal.promptForCharInput( }) => terminal.promptForCharInput(
acceptedCharacters, acceptedCharacters,
...@@ -253,10 +250,10 @@ class FakeTerminal implements Terminal { ...@@ -253,10 +250,10 @@ class FakeTerminal implements Terminal {
class FakeCommandRunner extends FlutterCommandRunner { class FakeCommandRunner extends FlutterCommandRunner {
FakeCommandRunner({ FakeCommandRunner({
@required Platform platform, required Platform platform,
@required FileSystem fileSystem, required FileSystem fileSystem,
@required Logger logger, required Logger logger,
UserMessages userMessages UserMessages? userMessages
}) : _platform = platform, }) : _platform = platform,
_fileSystem = fileSystem, _fileSystem = fileSystem,
_logger = logger, _logger = logger,
...@@ -285,7 +282,7 @@ class FakeCommandRunner extends FlutterCommandRunner { ...@@ -285,7 +282,7 @@ class FakeCommandRunner extends FlutterCommandRunner {
userMessages: _userMessages, userMessages: _userMessages,
); );
// For compatibility with tests that set this to a relative path. // For compatibility with tests that set this to a relative path.
Cache.flutterRoot = _fileSystem.path.normalize(_fileSystem.path.absolute(Cache.flutterRoot)); Cache.flutterRoot = _fileSystem.path.normalize(_fileSystem.path.absolute(Cache.flutterRoot!));
return super.runCommand(topLevelResults); return super.runCommand(topLevelResults);
} }
); );
...@@ -295,13 +292,13 @@ class FakeCommandRunner extends FlutterCommandRunner { ...@@ -295,13 +292,13 @@ class FakeCommandRunner extends FlutterCommandRunner {
/// May take platform, logger, processManager and fileSystem from context if /// May take platform, logger, processManager and fileSystem from context if
/// not explicitly specified. /// not explicitly specified.
CustomDevicesCommand createCustomDevicesCommand({ CustomDevicesCommand createCustomDevicesCommand({
CustomDevicesConfig Function(FileSystem, Logger) config, CustomDevicesConfig Function(FileSystem, Logger)? config,
Terminal Function(Platform) terminal, Terminal Function(Platform)? terminal,
Platform platform, Platform? platform,
FileSystem fileSystem, FileSystem? fileSystem,
ProcessManager processManager, ProcessManager? processManager,
Logger logger, Logger? logger,
PrintFn usagePrintFn, PrintFn? usagePrintFn,
bool featureEnabled = false bool featureEnabled = false
}) { }) {
platform ??= FakePlatform(); platform ??= FakePlatform();
...@@ -340,13 +337,13 @@ CustomDevicesCommand createCustomDevicesCommand({ ...@@ -340,13 +337,13 @@ CustomDevicesCommand createCustomDevicesCommand({
/// May take platform, logger, processManager and fileSystem from context if /// May take platform, logger, processManager and fileSystem from context if
/// not explicitly specified. /// not explicitly specified.
CommandRunner<void> createCustomDevicesCommandRunner({ CommandRunner<void> createCustomDevicesCommandRunner({
CustomDevicesConfig Function(FileSystem, Logger) config, CustomDevicesConfig Function(FileSystem, Logger)? config,
Terminal Function(Platform) terminal, Terminal Function(Platform)? terminal,
Platform platform, Platform? platform,
FileSystem fileSystem, FileSystem? fileSystem,
ProcessManager processManager, ProcessManager? processManager,
Logger logger, Logger? logger,
PrintFn usagePrintFn, PrintFn? usagePrintFn,
bool featureEnabled = false, bool featureEnabled = false,
}) { }) {
platform ??= FakePlatform(); platform ??= FakePlatform();
...@@ -372,17 +369,17 @@ CommandRunner<void> createCustomDevicesCommandRunner({ ...@@ -372,17 +369,17 @@ CommandRunner<void> createCustomDevicesCommandRunner({
} }
FakeTerminal createFakeTerminalForAddingSshDevice({ FakeTerminal createFakeTerminalForAddingSshDevice({
@required Platform platform, required Platform platform,
@required String id, required String id,
@required String label, required String label,
@required String sdkNameAndVersion, required String sdkNameAndVersion,
@required String enabled, required String enabled,
@required String hostname, required String hostname,
@required String username, required String username,
@required String runDebug, required String runDebug,
@required String usePortForwarding, required String usePortForwarding,
@required String screenshot, required String screenshot,
@required String apply required String apply
}) { }) {
return FakeTerminal(platform: platform) return FakeTerminal(platform: platform)
..simulateStdin(id) ..simulateStdin(id)
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
// 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:convert'; import 'dart:convert';
import 'package:flutter_tools/src/android/android_sdk.dart'; import 'package:flutter_tools/src/android/android_sdk.dart';
import 'package:flutter_tools/src/artifacts.dart'; import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/base/user_messages.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/devices.dart'; import 'package:flutter_tools/src/commands/devices.dart';
import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/device.dart';
...@@ -24,7 +24,7 @@ void main() { ...@@ -24,7 +24,7 @@ void main() {
Cache.disableLocking(); Cache.disableLocking();
}); });
Cache cache; late Cache cache;
setUp(() { setUp(() {
cache = Cache.test(processManager: FakeProcessManager.any()); cache = Cache.test(processManager: FakeProcessManager.any());
...@@ -52,7 +52,7 @@ void main() { ...@@ -52,7 +52,7 @@ void main() {
testUsingContext("get devices' platform types", () async { testUsingContext("get devices' platform types", () async {
final List<String> platformTypes = Device.devicesPlatformTypes( final List<String> platformTypes = Device.devicesPlatformTypes(
await globals.deviceManager.getAllConnectedDevices(), await globals.deviceManager!.getAllConnectedDevices(),
); );
expect(platformTypes, <String>['android', 'web']); expect(platformTypes, <String>['android', 'web']);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
...@@ -133,14 +133,14 @@ webby (mobile) • webby • web-javascript • Web SDK (1.2.4) (emulato ...@@ -133,14 +133,14 @@ webby (mobile) • webby • web-javascript • Web SDK (1.2.4) (emulato
} }
class _FakeDeviceManager extends DeviceManager { class _FakeDeviceManager extends DeviceManager {
_FakeDeviceManager(); _FakeDeviceManager() : super(logger: testLogger, terminal: Terminal.test(), userMessages: userMessages);
@override @override
Future<List<Device>> getAllConnectedDevices() => Future<List<Device>> getAllConnectedDevices() =>
Future<List<Device>>.value(fakeDevices.map((FakeDeviceJsonData d) => d.dev).toList()); Future<List<Device>>.value(fakeDevices.map((FakeDeviceJsonData d) => d.dev).toList());
@override @override
Future<List<Device>> refreshAllConnectedDevices({Duration timeout}) => Future<List<Device>> refreshAllConnectedDevices({Duration? timeout}) =>
getAllConnectedDevices(); getAllConnectedDevices();
@override @override
...@@ -153,11 +153,13 @@ class _FakeDeviceManager extends DeviceManager { ...@@ -153,11 +153,13 @@ class _FakeDeviceManager extends DeviceManager {
} }
class NoDevicesManager extends DeviceManager { class NoDevicesManager extends DeviceManager {
NoDevicesManager() : super(logger: testLogger, terminal: Terminal.test(), userMessages: userMessages);
@override @override
Future<List<Device>> getAllConnectedDevices() async => <Device>[]; Future<List<Device>> getAllConnectedDevices() async => <Device>[];
@override @override
Future<List<Device>> refreshAllConnectedDevices({Duration timeout}) => Future<List<Device>> refreshAllConnectedDevices({Duration? timeout}) =>
getAllConnectedDevices(); getAllConnectedDevices();
@override @override
......
...@@ -2,8 +2,6 @@ ...@@ -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 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/io.dart';
...@@ -20,11 +18,11 @@ import '../../src/fakes.dart'; ...@@ -20,11 +18,11 @@ import '../../src/fakes.dart';
import '../../src/test_flutter_command_runner.dart'; import '../../src/test_flutter_command_runner.dart';
void main() { void main() {
FileSystem fileSystem; late FileSystem fileSystem;
BufferLogger bufferLogger; late BufferLogger bufferLogger;
FakeTerminal terminal; late FakeTerminal terminal;
ProcessManager processManager; late ProcessManager processManager;
FakeStdio stdio; late FakeStdio stdio;
setUpAll(() { setUpAll(() {
Cache.disableLocking(); Cache.disableLocking();
...@@ -224,11 +222,11 @@ class FakeTerminal extends Fake implements Terminal { ...@@ -224,11 +222,11 @@ class FakeTerminal extends Fake implements Terminal {
_selected = selected; _selected = selected;
} }
List<String> _characters; List<String>? _characters;
String _selected; late String _selected;
@override @override
Future<String> promptForCharInput(List<String> acceptedCharacters, {Logger logger, String prompt, int defaultChoiceIndex, bool displayAcceptedCharacters = true}) async { Future<String> promptForCharInput(List<String> acceptedCharacters, {Logger? logger, String? prompt, int? defaultChoiceIndex, bool displayAcceptedCharacters = true}) async {
expect(acceptedCharacters, _characters); expect(acceptedCharacters, _characters);
return _selected; return _selected;
} }
......
...@@ -2,8 +2,6 @@ ...@@ -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 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:flutter_tools/src/application_package.dart'; import 'package:flutter_tools/src/application_package.dart';
import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/common.dart';
...@@ -25,10 +23,10 @@ import '../../src/context.dart'; ...@@ -25,10 +23,10 @@ import '../../src/context.dart';
import '../../src/test_flutter_command_runner.dart'; import '../../src/test_flutter_command_runner.dart';
void main() { void main() {
FileSystem fileSystem; late FileSystem fileSystem;
BufferLogger logger; late BufferLogger logger;
Platform platform; late Platform platform;
FakeDeviceManager fakeDeviceManager; late FakeDeviceManager fakeDeviceManager;
setUp(() { setUp(() {
fileSystem = MemoryFileSystem.test(); fileSystem = MemoryFileSystem.test();
...@@ -254,15 +252,15 @@ void main() { ...@@ -254,15 +252,15 @@ void main() {
class ThrowingScreenshotDevice extends ScreenshotDevice { class ThrowingScreenshotDevice extends ScreenshotDevice {
@override @override
Future<LaunchResult> startApp( Future<LaunchResult> startApp(
ApplicationPackage package, { ApplicationPackage? package, {
String mainPath, String? mainPath,
String route, String? route,
DebuggingOptions debuggingOptions, DebuggingOptions? debuggingOptions,
Map<String, dynamic> platformArgs, Map<String, dynamic>? platformArgs,
bool prebuiltApplication = false, bool prebuiltApplication = false,
bool usesTerminalUi = true, bool usesTerminalUi = true,
bool ipv6 = false, bool ipv6 = false,
String userIdentifier, String? userIdentifier,
}) async { }) async {
throwToolExit('cannot start app'); throwToolExit('cannot start app');
} }
...@@ -289,15 +287,15 @@ class ScreenshotDevice extends Fake implements Device { ...@@ -289,15 +287,15 @@ class ScreenshotDevice extends Fake implements Device {
@override @override
Future<LaunchResult> startApp( Future<LaunchResult> startApp(
ApplicationPackage package, { ApplicationPackage? package, {
String mainPath, String? mainPath,
String route, String? route,
DebuggingOptions debuggingOptions, DebuggingOptions? debuggingOptions,
Map<String, dynamic> platformArgs, Map<String, dynamic>? platformArgs,
bool prebuiltApplication = false, bool prebuiltApplication = false,
bool usesTerminalUi = true, bool usesTerminalUi = true,
bool ipv6 = false, bool ipv6 = false,
String userIdentifier, String? userIdentifier,
}) async => LaunchResult.succeeded(); }) async => LaunchResult.succeeded();
@override @override
...@@ -307,13 +305,13 @@ class ScreenshotDevice extends Fake implements Device { ...@@ -307,13 +305,13 @@ class ScreenshotDevice extends Fake implements Device {
class FakePub extends Fake implements Pub { class FakePub extends Fake implements Pub {
@override @override
Future<void> get({ Future<void> get({
PubContext context, PubContext? context,
String directory, String? directory,
bool skipIfAbsent = false, bool skipIfAbsent = false,
bool upgrade = false, bool upgrade = false,
bool offline = false, bool offline = false,
bool generateSyntheticPackage = false, bool generateSyntheticPackage = false,
String flutterRootOverride, String? flutterRootOverride,
bool checkUpToDate = false, bool checkUpToDate = false,
bool shouldSkipThirdPartyGenerator = true, bool shouldSkipThirdPartyGenerator = true,
bool printProgress = true, bool printProgress = true,
...@@ -324,13 +322,13 @@ class FakeDeviceManager extends Fake implements DeviceManager { ...@@ -324,13 +322,13 @@ class FakeDeviceManager extends Fake implements DeviceManager {
List<Device> devices = <Device>[]; List<Device> devices = <Device>[];
@override @override
String specifiedDeviceId; String? specifiedDeviceId;
@override @override
Future<List<Device>> getDevices() async => devices; Future<List<Device>> getDevices() async => devices;
@override @override
Future<List<Device>> findTargetDevices(FlutterProject flutterProject, {Duration timeout}) async => devices; Future<List<Device>> findTargetDevices(FlutterProject? flutterProject, {Duration? timeout}) async => devices;
} }
class FailingFakeFlutterDriverFactory extends Fake implements FlutterDriverFactory { class FailingFakeFlutterDriverFactory extends Fake implements FlutterDriverFactory {
...@@ -348,13 +346,13 @@ class FailingFakeDriverService extends Fake implements DriverService { ...@@ -348,13 +346,13 @@ class FailingFakeDriverService extends Fake implements DriverService {
List<String> arguments, List<String> arguments,
Map<String, String> environment, Map<String, String> environment,
PackageConfig packageConfig, { PackageConfig packageConfig, {
bool headless, bool? headless,
String chromeBinary, String? chromeBinary,
String browserName, String? browserName,
bool androidEmulator, bool? androidEmulator,
int driverPort, int? driverPort,
List<String> webBrowserFlags, List<String>? webBrowserFlags,
List<String> browserDimension, List<String>? browserDimension,
String profileMemory, String? profileMemory,
}) async => 1; }) async => 1;
} }
...@@ -2,8 +2,6 @@ ...@@ -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 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:flutter_tools/src/artifacts.dart'; import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
...@@ -18,10 +16,10 @@ import '../../src/fake_process_manager.dart'; ...@@ -18,10 +16,10 @@ import '../../src/fake_process_manager.dart';
import '../../src/test_flutter_command_runner.dart'; import '../../src/test_flutter_command_runner.dart';
void main() { void main() {
FileSystem fileSystem; late FileSystem fileSystem;
BufferLogger logger; late BufferLogger logger;
Artifacts artifacts; late Artifacts artifacts;
FakeProcessManager processManager; late FakeProcessManager processManager;
setUpAll(() { setUpAll(() {
Cache.disableLocking(); Cache.disableLocking();
......
...@@ -2,8 +2,6 @@ ...@@ -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 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
...@@ -17,12 +15,12 @@ import '../../src/test_flutter_command_runner.dart'; ...@@ -17,12 +15,12 @@ import '../../src/test_flutter_command_runner.dart';
void main() { void main() {
group('ide_config', () { group('ide_config', () {
Directory tempDir; late Directory tempDir;
Directory templateDir; late Directory templateDir;
Directory intellijDir; late Directory intellijDir;
Directory toolsDir; late Directory toolsDir;
Map<String, String> getFilesystemContents([ Directory root ]) { Map<String, String> getFilesystemContents([ Directory? root ]) {
final String tempPath = tempDir.absolute.path; final String tempPath = tempDir.absolute.path;
final List<String> paths = final List<String> paths =
(root ?? tempDir).listSync(recursive: true).map((FileSystemEntity entity) { (root ?? tempDir).listSync(recursive: true).map((FileSystemEntity entity) {
...@@ -67,7 +65,7 @@ void main() { ...@@ -67,7 +65,7 @@ void main() {
if (manifest[key] != 'dir') { if (manifest[key] != 'dir') {
tempDir.childFile(key) tempDir.childFile(key)
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsStringSync(manifest[key]); ..writeAsStringSync(manifest[key]!);
} }
} }
} }
...@@ -78,7 +76,7 @@ void main() { ...@@ -78,7 +76,7 @@ void main() {
} }
Future<void> updateIdeConfig({ Future<void> updateIdeConfig({
Directory dir, Directory? dir,
List<String> args = const <String>[], List<String> args = const <String>[],
Map<String, String> expectedContents = const <String, String>{}, Map<String, String> expectedContents = const <String, String>{},
List<String> unexpectedPaths = const <String>[], List<String> unexpectedPaths = const <String>[],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment