Unverified Commit db829c1e authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] migrate more unit tests to null safety (#106153)

parent 2af82503
...@@ -210,10 +210,10 @@ DevFSContent? processSkSLBundle(String? bundlePath, { ...@@ -210,10 +210,10 @@ DevFSContent? processSkSLBundle(String? bundlePath, {
} }
// Step 2: validate top level bundle structure. // Step 2: validate top level bundle structure.
Map<String, Object>? bundle; Map<String, Object?>? bundle;
try { try {
final Object? rawBundle = json.decode(skSLBundleFile.readAsStringSync()); final Object? rawBundle = json.decode(skSLBundleFile.readAsStringSync());
if (rawBundle is Map<String, Object>) { if (rawBundle is Map<String, Object?>) {
bundle = rawBundle; bundle = rawBundle;
} else { } else {
logger.printError('"$bundle" was not a JSON object: $rawBundle'); logger.printError('"$bundle" was not a JSON object: $rawBundle');
......
...@@ -389,10 +389,10 @@ class Cache { ...@@ -389,10 +389,10 @@ class Cache {
throw Exception('Could not find file at $versionFilePath'); throw Exception('Could not find file at $versionFilePath');
} }
final dynamic data = jsonDecode(versionFile.readAsStringSync()); final dynamic data = jsonDecode(versionFile.readAsStringSync());
if (data is! Map<String, Object>) { if (data is! Map<String, Object?>) {
throw Exception("Expected object of type 'Map<String, Object>' but got one of type '${data.runtimeType}'"); throw Exception("Expected object of type 'Map<String, Object?>' but got one of type '${data.runtimeType}'");
} }
final dynamic version = data['version']; final Object? version = data['version'];
if (version == null) { if (version == null) {
throw Exception('Could not parse DevTools version from $version'); throw Exception('Could not parse DevTools version from $version');
} }
......
...@@ -668,11 +668,11 @@ abstract class CreateBase extends FlutterCommand { ...@@ -668,11 +668,11 @@ abstract class CreateBase extends FlutterCommand {
'templates', 'templates',
'template_manifest.json', 'template_manifest.json',
); );
final Map<String, Object> manifest = json.decode( final Map<String, Object?> manifest = json.decode(
globals.fs.file(manifestPath).readAsStringSync(), globals.fs.file(manifestPath).readAsStringSync(),
) as Map<String, Object>; ) as Map<String, Object?>;
return Set<Uri>.from( return Set<Uri>.from(
(manifest['files']! as List<Object>).cast<String>().map<Uri>( (manifest['files']! as List<Object?>).cast<String>().map<Uri>(
(String path) => (String path) =>
Uri.file(globals.fs.path.join(flutterToolsAbsolutePath, path))), Uri.file(globals.fs.path.join(flutterToolsAbsolutePath, path))),
); );
......
...@@ -86,8 +86,8 @@ abstract class MacOSApp extends ApplicationPackage { ...@@ -86,8 +86,8 @@ abstract class MacOSApp extends ApplicationPackage {
return null; return null;
} }
final Map<String, dynamic> propertyValues = globals.plistParser.parseFile(plistPath); final Map<String, dynamic> propertyValues = globals.plistParser.parseFile(plistPath);
final String id = propertyValues[PlistParser.kCFBundleIdentifierKey] as String; final String? id = propertyValues[PlistParser.kCFBundleIdentifierKey] as String?;
final String executableName = propertyValues[PlistParser.kCFBundleExecutable] as String; final String? executableName = propertyValues[PlistParser.kCFBundleExecutable] as String?;
if (id == null) { if (id == null) {
globals.printError('Invalid prebuilt macOS app. Info.plist does not contain bundle identifier'); globals.printError('Invalid prebuilt macOS app. Info.plist does not contain bundle identifier');
return null; return null;
......
...@@ -1534,7 +1534,7 @@ abstract class FlutterCommand extends Command<void> { ...@@ -1534,7 +1534,7 @@ abstract class FlutterCommand extends Command<void> {
if (!argParser.options.containsKey(name)) { if (!argParser.options.containsKey(name)) {
return null; return null;
} }
return argResults![name] as String; return argResults![name] as String?;
} }
/// Gets the parsed command-line option named [name] as an `int`. /// Gets the parsed command-line option named [name] as an `int`.
......
...@@ -117,7 +117,7 @@ class CoverageCollector extends TestWatcher { ...@@ -117,7 +117,7 @@ class CoverageCollector extends TestWatcher {
); );
final Future<void> collectionComplete = testDevice.observatoryUri final Future<void> collectionComplete = testDevice.observatoryUri
.then((Uri observatoryUri) { .then((Uri? observatoryUri) {
_logMessage('collecting coverage data from $testDevice at $observatoryUri...'); _logMessage('collecting coverage data from $testDevice at $observatoryUri...');
return collect(observatoryUri, libraryNames) return collect(observatoryUri, libraryNames)
.then<void>((Map<String, dynamic> result) { .then<void>((Map<String, dynamic> result) {
......
...@@ -494,7 +494,7 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -494,7 +494,7 @@ class FlutterPlatform extends PlatformPlugin {
await Future.any<void>(<Future<void>>[ await Future.any<void>(<Future<void>>[
testDevice.finished, testDevice.finished,
() async { () async {
final Uri processObservatoryUri = await testDevice.observatoryUri; final Uri? processObservatoryUri = await testDevice.observatoryUri;
if (processObservatoryUri != null) { if (processObservatoryUri != null) {
globals.printTrace('test $ourTestCount: Observatory uri is available at $processObservatoryUri'); globals.printTrace('test $ourTestCount: Observatory uri is available at $processObservatoryUri');
} else { } else {
......
...@@ -47,8 +47,7 @@ class FlutterTesterTestDevice extends TestDevice { ...@@ -47,8 +47,7 @@ class FlutterTesterTestDevice extends TestDevice {
}) : assert(shellPath != null), // Please provide the path to the shell in the SKY_SHELL environment variable. }) : assert(shellPath != null), // Please provide the path to the shell in the SKY_SHELL environment variable.
assert(!debuggingOptions.startPaused || enableObservatory), assert(!debuggingOptions.startPaused || enableObservatory),
_gotProcessObservatoryUri = enableObservatory _gotProcessObservatoryUri = enableObservatory
// ignore: null_argument_to_non_null_type ? Completer<Uri?>() : (Completer<Uri?>()..complete()),
? Completer<Uri>() : (Completer<Uri>()..complete()),
_operatingSystemUtils = OperatingSystemUtils( _operatingSystemUtils = OperatingSystemUtils(
fileSystem: fileSystem, fileSystem: fileSystem,
logger: logger, logger: logger,
...@@ -73,7 +72,7 @@ class FlutterTesterTestDevice extends TestDevice { ...@@ -73,7 +72,7 @@ class FlutterTesterTestDevice extends TestDevice {
final CompileExpression? compileExpression; final CompileExpression? compileExpression;
final FontConfigManager fontConfigManager; final FontConfigManager fontConfigManager;
final Completer<Uri> _gotProcessObservatoryUri; final Completer<Uri?> _gotProcessObservatoryUri;
final Completer<int> _exitCode = Completer<int>(); final Completer<int> _exitCode = Completer<int>();
Process? _process; Process? _process;
...@@ -209,7 +208,7 @@ class FlutterTesterTestDevice extends TestDevice { ...@@ -209,7 +208,7 @@ class FlutterTesterTestDevice extends TestDevice {
} }
@override @override
Future<Uri> get observatoryUri { Future<Uri?> get observatoryUri {
assert(_gotProcessObservatoryUri != null); assert(_gotProcessObservatoryUri != null);
return _gotProcessObservatoryUri.future; return _gotProcessObservatoryUri.future;
} }
......
...@@ -79,7 +79,7 @@ class TestCompiler { ...@@ -79,7 +79,7 @@ class TestCompiler {
late File outputDill; late File outputDill;
Future<String?> compile(Uri mainDart) { Future<String?> compile(Uri mainDart) {
final Completer<String> completer = Completer<String>(); final Completer<String?> completer = Completer<String?>();
if (compilerController.isClosed) { if (compilerController.isClosed) {
return Future<String?>.value(); return Future<String?>.value();
} }
...@@ -175,7 +175,7 @@ class TestCompiler { ...@@ -175,7 +175,7 @@ class TestCompiler {
// compiler to avoid reusing compiler that might have gotten into // compiler to avoid reusing compiler that might have gotten into
// a weird state. // a weird state.
if (outputPath == null || compilerOutput!.errorCount > 0) { if (outputPath == null || compilerOutput!.errorCount > 0) {
request.result.complete(null); request.result.complete();
await _shutdown(); await _shutdown();
} else { } else {
if (shouldCopyDillFile) { if (shouldCopyDillFile) {
......
...@@ -22,7 +22,7 @@ abstract class TestDevice { ...@@ -22,7 +22,7 @@ abstract class TestDevice {
Future<StreamChannel<String>> start(String entrypointPath); Future<StreamChannel<String>> start(String entrypointPath);
/// Should complete with null if the observatory is not enabled. /// Should complete with null if the observatory is not enabled.
Future<Uri> get observatoryUri; Future<Uri?> get observatoryUri;
/// Terminates the test device. /// Terminates the test device.
Future<void> kill(); Future<void> kill();
......
...@@ -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/android/android_workflow.dart'; import 'package:flutter_tools/src/android/android_workflow.dart';
...@@ -37,8 +35,8 @@ void main() { ...@@ -37,8 +35,8 @@ void main() {
}); });
group('analytics', () { group('analytics', () {
Directory tempDir; late Directory tempDir;
Config testConfig; late Config testConfig;
setUp(() { setUp(() {
Cache.flutterRoot = '../..'; Cache.flutterRoot = '../..';
...@@ -108,7 +106,7 @@ void main() { ...@@ -108,7 +106,7 @@ void main() {
}); });
testUsingContext('Usage records one feature in experiment setting', () async { testUsingContext('Usage records one feature in experiment setting', () async {
testConfig.setValue(flutterWebFeature.configSetting, true); testConfig.setValue(flutterWebFeature.configSetting!, true);
final Usage usage = Usage(runningOnBot: true); final Usage usage = Usage(runningOnBot: true);
usage.sendCommand('test'); usage.sendCommand('test');
...@@ -126,9 +124,9 @@ void main() { ...@@ -126,9 +124,9 @@ void main() {
}); });
testUsingContext('Usage records multiple features in experiment setting', () async { testUsingContext('Usage records multiple features in experiment setting', () async {
testConfig.setValue(flutterWebFeature.configSetting, true); testConfig.setValue(flutterWebFeature.configSetting!, true);
testConfig.setValue(flutterLinuxDesktopFeature.configSetting, true); testConfig.setValue(flutterLinuxDesktopFeature.configSetting!, true);
testConfig.setValue(flutterMacOSDesktopFeature.configSetting, true); testConfig.setValue(flutterMacOSDesktopFeature.configSetting!, true);
final Usage usage = Usage(runningOnBot: true); final Usage usage = Usage(runningOnBot: true);
usage.sendCommand('test'); usage.sendCommand('test');
...@@ -150,11 +148,11 @@ void main() { ...@@ -150,11 +148,11 @@ void main() {
}); });
group('analytics with fakes', () { group('analytics with fakes', () {
MemoryFileSystem memoryFileSystem; late MemoryFileSystem memoryFileSystem;
FakeStdio fakeStdio; late FakeStdio fakeStdio;
TestUsage testUsage; late TestUsage testUsage;
FakeClock fakeClock; late FakeClock fakeClock;
FakeDoctor doctor; late FakeDoctor doctor;
setUp(() { setUp(() {
memoryFileSystem = MemoryFileSystem.test(); memoryFileSystem = MemoryFileSystem.test();
...@@ -211,7 +209,7 @@ void main() { ...@@ -211,7 +209,7 @@ void main() {
testUsingContext('compound command usage path', () async { testUsingContext('compound command usage path', () async {
final BuildCommand buildCommand = BuildCommand(); final BuildCommand buildCommand = BuildCommand();
final FlutterCommand buildApkCommand = buildCommand.subcommands['apk'] as FlutterCommand; final FlutterCommand buildApkCommand = buildCommand.subcommands['apk']! as FlutterCommand;
expect(await buildApkCommand.usagePath, 'build/apk'); expect(await buildApkCommand.usagePath, 'build/apk');
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
...@@ -280,7 +278,7 @@ void main() { ...@@ -280,7 +278,7 @@ void main() {
}); });
group('analytics bots', () { group('analytics bots', () {
Directory tempDir; late Directory tempDir;
setUp(() { setUp(() {
tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_analytics_bots_test.'); tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_analytics_bots_test.');
...@@ -341,8 +339,8 @@ Analytics throwingAnalyticsIOFactory( ...@@ -341,8 +339,8 @@ Analytics throwingAnalyticsIOFactory(
String trackingId, String trackingId,
String applicationName, String applicationName,
String applicationVersion, { String applicationVersion, {
String analyticsUrl, String? analyticsUrl,
Directory documentDirectory, Directory? documentDirectory,
}) { }) {
throw const FileSystemException('Could not create file'); throw const FileSystemException('Could not create file');
} }
...@@ -368,9 +366,9 @@ class FakeDoctor extends Fake implements Doctor { ...@@ -368,9 +366,9 @@ class FakeDoctor extends Fake implements Doctor {
bool androidLicenses = false, bool androidLicenses = false,
bool verbose = true, bool verbose = true,
bool showColor = true, bool showColor = true,
AndroidLicenseValidator androidLicenseValidator, AndroidLicenseValidator? androidLicenseValidator,
bool showPii = true, bool showPii = true,
List<ValidatorTask> startedValidatorTasks, List<ValidatorTask>? startedValidatorTasks,
bool sendEvent = true, bool sendEvent = true,
}) async { }) async {
return diagnoseSucceeds; return diagnoseSucceeds;
......
...@@ -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:archive/archive.dart'; import 'package:archive/archive.dart';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:file_testing/file_testing.dart'; import 'package:file_testing/file_testing.dart';
...@@ -27,10 +25,10 @@ import '../../src/fake_process_manager.dart'; ...@@ -27,10 +25,10 @@ import '../../src/fake_process_manager.dart';
void main() { void main() {
group('gradle build', () { group('gradle build', () {
BufferLogger logger; late BufferLogger logger;
TestUsage testUsage; late TestUsage testUsage;
FileSystem fileSystem; late FileSystem fileSystem;
FakeProcessManager processManager; late FakeProcessManager processManager;
setUp(() { setUp(() {
processManager = FakeProcessManager.empty(); processManager = FakeProcessManager.empty();
...@@ -99,10 +97,10 @@ void main() { ...@@ -99,10 +97,10 @@ void main() {
return line.contains('Some gradle message'); return line.contains('Some gradle message');
}, },
handler: ({ handler: ({
String line, String? line,
FlutterProject project, FlutterProject? project,
bool usesAndroidX, bool? usesAndroidX,
bool multidexEnabled bool? multidexEnabled
}) async { }) async {
handlerCalled = true; handlerCalled = true;
return GradleBuildStatus.exit; return GradleBuildStatus.exit;
...@@ -263,10 +261,10 @@ void main() { ...@@ -263,10 +261,10 @@ void main() {
return false; return false;
}, },
handler: ({ handler: ({
String line, String? line,
FlutterProject project, FlutterProject? project,
bool usesAndroidX, bool? usesAndroidX,
bool multidexEnabled bool? multidexEnabled
}) async { }) async {
return GradleBuildStatus.retry; return GradleBuildStatus.retry;
}, },
...@@ -351,10 +349,10 @@ void main() { ...@@ -351,10 +349,10 @@ void main() {
return line.contains('Some gradle message'); return line.contains('Some gradle message');
}, },
handler: ({ handler: ({
String line, String? line,
FlutterProject project, FlutterProject? project,
bool usesAndroidX, bool? usesAndroidX,
bool multidexEnabled bool? multidexEnabled
}) async { }) async {
handlerCalled = true; handlerCalled = true;
return GradleBuildStatus.exit; return GradleBuildStatus.exit;
...@@ -517,10 +515,10 @@ void main() { ...@@ -517,10 +515,10 @@ void main() {
return line.contains('Some gradle message'); return line.contains('Some gradle message');
}, },
handler: ({ handler: ({
String line, String? line,
FlutterProject project, FlutterProject? project,
bool usesAndroidX, bool? usesAndroidX,
bool multidexEnabled bool? multidexEnabled
}) async { }) async {
return GradleBuildStatus.retry; return GradleBuildStatus.retry;
}, },
...@@ -595,7 +593,7 @@ void main() { ...@@ -595,7 +593,7 @@ void main() {
.childDirectory('flutter-apk') .childDirectory('flutter-apk')
.childFile('app-release.apk') .childFile('app-release.apk')
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsBytesSync(ZipEncoder().encode(archive)); ..writeAsBytesSync(ZipEncoder().encode(archive)!);
fileSystem.file('foo/snapshot.arm64-v8a.json') fileSystem.file('foo/snapshot.arm64-v8a.json')
..createSync(recursive: true) ..createSync(recursive: true)
......
...@@ -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/android/android_studio_validator.dart'; import 'package:flutter_tools/src/android/android_studio_validator.dart';
import 'package:flutter_tools/src/base/config.dart'; import 'package:flutter_tools/src/base/config.dart';
...@@ -24,8 +22,8 @@ final Platform linuxPlatform = FakePlatform( ...@@ -24,8 +22,8 @@ final Platform linuxPlatform = FakePlatform(
); );
void main() { void main() {
FileSystem fileSystem; late FileSystem fileSystem;
FakeProcessManager fakeProcessManager; late FakeProcessManager fakeProcessManager;
setUp(() { setUp(() {
fileSystem = MemoryFileSystem.test(); fileSystem = MemoryFileSystem.test();
......
...@@ -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/android/deferred_components_prebuild_validator.dart'; import 'package:flutter_tools/src/android/deferred_components_prebuild_validator.dart';
import 'package:flutter_tools/src/android/deferred_components_validator.dart'; import 'package:flutter_tools/src/android/deferred_components_validator.dart';
...@@ -16,11 +14,11 @@ import '../../src/common.dart'; ...@@ -16,11 +14,11 @@ import '../../src/common.dart';
import '../../src/context.dart'; import '../../src/context.dart';
void main() { void main() {
FileSystem fileSystem; late FileSystem fileSystem;
BufferLogger logger; late BufferLogger logger;
Directory projectDir; late Directory projectDir;
Platform platform; late Platform platform;
Directory flutterRootDir; late Directory flutterRootDir;
setUp(() { setUp(() {
fileSystem = MemoryFileSystem.test(); fileSystem = MemoryFileSystem.test();
......
...@@ -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/android/android_sdk.dart'; import 'package:flutter_tools/src/android/android_sdk.dart';
import 'package:flutter_tools/src/android/gradle.dart'; import 'package:flutter_tools/src/android/gradle.dart';
...@@ -33,7 +31,7 @@ void main() { ...@@ -33,7 +31,7 @@ void main() {
Cache.flutterRoot = getFlutterRoot(); Cache.flutterRoot = getFlutterRoot();
group('build artifacts', () { group('build artifacts', () {
FileSystem fileSystem; late FileSystem fileSystem;
setUp(() { setUp(() {
fileSystem = MemoryFileSystem.test(); fileSystem = MemoryFileSystem.test();
...@@ -194,8 +192,8 @@ void main() { ...@@ -194,8 +192,8 @@ void main() {
}); });
group('Gradle local.properties', () { group('Gradle local.properties', () {
Artifacts localEngineArtifacts; late Artifacts localEngineArtifacts;
FileSystem fs; late FileSystem fs;
setUp(() { setUp(() {
fs = MemoryFileSystem.test(); fs = MemoryFileSystem.test();
...@@ -211,7 +209,7 @@ void main() { ...@@ -211,7 +209,7 @@ void main() {
}); });
} }
String propertyFor(String key, File file) { String? propertyFor(String key, File file) {
final Iterable<String> result = file.readAsLinesSync() final Iterable<String> result = file.readAsLinesSync()
.where((String line) => line.startsWith('$key=')) .where((String line) => line.startsWith('$key='))
.map((String line) => line.split('=')[1]); .map((String line) => line.split('=')[1]);
...@@ -219,10 +217,10 @@ void main() { ...@@ -219,10 +217,10 @@ void main() {
} }
Future<void> checkBuildVersion({ Future<void> checkBuildVersion({
String manifest, required String manifest,
BuildInfo buildInfo, BuildInfo? buildInfo,
String expectedBuildName, String? expectedBuildName,
String expectedBuildNumber, String? expectedBuildNumber,
}) async { }) async {
final File manifestFile = globals.fs.file('path/to/project/pubspec.yaml'); final File manifestFile = globals.fs.file('path/to/project/pubspec.yaml');
manifestFile.createSync(recursive: true); manifestFile.createSync(recursive: true);
...@@ -457,7 +455,7 @@ flutter: ...@@ -457,7 +455,7 @@ flutter:
}); });
group('isAppUsingAndroidX', () { group('isAppUsingAndroidX', () {
FileSystem fs; late FileSystem fs;
setUp(() { setUp(() {
fs = MemoryFileSystem.test(); fs = MemoryFileSystem.test();
...@@ -503,8 +501,8 @@ flutter: ...@@ -503,8 +501,8 @@ flutter:
}); });
group('printHowToConsumeAar', () { group('printHowToConsumeAar', () {
BufferLogger logger; late BufferLogger logger;
FileSystem fileSystem; late FileSystem fileSystem;
setUp(() { setUp(() {
logger = BufferLogger.test(); logger = BufferLogger.test();
...@@ -694,8 +692,8 @@ flutter: ...@@ -694,8 +692,8 @@ flutter:
// If this test fails, you probably edited templates/app/android.tmpl. // If this test fails, you probably edited templates/app/android.tmpl.
// That's fine, but you now need to add a copy of that file to gradle/settings.gradle.legacy_versions, separated // That's fine, but you now need to add a copy of that file to gradle/settings.gradle.legacy_versions, separated
// from the previous versions by a line that just says ";EOF". // from the previous versions by a line that just says ";EOF".
final File templateSettingsDotGradle = globals.fs.file(globals.fs.path.join(Cache.flutterRoot, 'packages', 'flutter_tools', 'templates', 'app', 'android.tmpl', 'settings.gradle')); final File templateSettingsDotGradle = globals.fs.file(globals.fs.path.join(Cache.flutterRoot!, 'packages', 'flutter_tools', 'templates', 'app', 'android.tmpl', 'settings.gradle'));
final File legacySettingsDotGradleFiles = globals.fs.file(globals.fs.path.join(Cache.flutterRoot, 'packages','flutter_tools', 'gradle', 'settings.gradle.legacy_versions')); final File legacySettingsDotGradleFiles = globals.fs.file(globals.fs.path.join(Cache.flutterRoot!, 'packages','flutter_tools', 'gradle', 'settings.gradle.legacy_versions'));
expect( expect(
legacySettingsDotGradleFiles.readAsStringSync().split(';EOF').map<String>((String body) => body.trim()), legacySettingsDotGradleFiles.readAsStringSync().split(';EOF').map<String>((String body) => body.trim()),
contains(templateSettingsDotGradle.readAsStringSync().trim()), contains(templateSettingsDotGradle.readAsStringSync().trim()),
......
...@@ -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/android/multidex.dart'; import 'package:flutter_tools/src/android/multidex.dart';
......
...@@ -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:convert'; import 'dart:convert';
import 'package:file/file.dart'; import 'package:file/file.dart';
...@@ -24,9 +22,9 @@ void main() { ...@@ -24,9 +22,9 @@ void main() {
// fixed we fix them here. // fixed we fix them here.
// TODO(dantup): Remove this function once the above issue is fixed and // TODO(dantup): Remove this function once the above issue is fixed and
// rolls into Flutter. // rolls into Flutter.
return path?.replaceAll('/', globals.fs.path.separator); return path.replaceAll('/', globals.fs.path.separator);
} }
void writePubspecFile(String path, String name, { String fontsSection }) { void writePubspecFile(String path, String name, { String? fontsSection }) {
if (fontsSection == null) { if (fontsSection == null) {
fontsSection = ''; fontsSection = '';
} else { } else {
...@@ -61,14 +59,14 @@ $fontsSection ...@@ -61,14 +59,14 @@ $fontsSection
String expectedAssetManifest, String expectedAssetManifest,
) async { ) async {
final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'); await bundle.build(packagesPath: '.packages');
for (final String packageName in packages) { for (final String packageName in packages) {
for (final String packageFont in packageFonts) { for (final String packageFont in packageFonts) {
final String entryKey = 'packages/$packageName/$packageFont'; final String entryKey = 'packages/$packageName/$packageFont';
expect(bundle.entries.containsKey(entryKey), true); expect(bundle.entries.containsKey(entryKey), true);
expect( expect(
utf8.decode(await bundle.entries[entryKey].contentsAsBytes()), utf8.decode(await bundle.entries[entryKey]!.contentsAsBytes()),
packageFont, packageFont,
); );
} }
...@@ -76,14 +74,14 @@ $fontsSection ...@@ -76,14 +74,14 @@ $fontsSection
for (final String localFont in localFonts) { for (final String localFont in localFonts) {
expect(bundle.entries.containsKey(localFont), true); expect(bundle.entries.containsKey(localFont), true);
expect( expect(
utf8.decode(await bundle.entries[localFont].contentsAsBytes()), utf8.decode(await bundle.entries[localFont]!.contentsAsBytes()),
localFont, localFont,
); );
} }
} }
expect( expect(
json.decode(utf8.decode(await bundle.entries['FontManifest.json'].contentsAsBytes())), json.decode(utf8.decode(await bundle.entries['FontManifest.json']!.contentsAsBytes())),
json.decode(expectedAssetManifest), json.decode(expectedAssetManifest),
); );
} }
...@@ -95,7 +93,7 @@ $fontsSection ...@@ -95,7 +93,7 @@ $fontsSection
} }
group('AssetBundle fonts from packages', () { group('AssetBundle fonts from packages', () {
FileSystem testFileSystem; FileSystem? testFileSystem;
setUp(() async { setUp(() async {
testFileSystem = MemoryFileSystem( testFileSystem = MemoryFileSystem(
...@@ -103,7 +101,7 @@ $fontsSection ...@@ -103,7 +101,7 @@ $fontsSection
? FileSystemStyle.windows ? FileSystemStyle.windows
: FileSystemStyle.posix, : FileSystemStyle.posix,
); );
testFileSystem.currentDirectory = testFileSystem.systemTempDirectory.createTempSync('flutter_asset_bundle_test.'); testFileSystem!.currentDirectory = testFileSystem!.systemTempDirectory.createTempSync('flutter_asset_bundle_test.');
}); });
testUsingContext('App includes neither font manifest nor fonts when no defines fonts', () async { testUsingContext('App includes neither font manifest nor fonts when no defines fonts', () async {
...@@ -112,7 +110,7 @@ $fontsSection ...@@ -112,7 +110,7 @@ $fontsSection
writePubspecFile('p/p/pubspec.yaml', 'test_package'); writePubspecFile('p/p/pubspec.yaml', 'test_package');
final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'); await bundle.build(packagesPath: '.packages');
expect(bundle.entries.length, 3); // LICENSE, AssetManifest, FontManifest expect(bundle.entries.length, 3); // LICENSE, AssetManifest, FontManifest
expect(bundle.entries.containsKey('FontManifest.json'), isTrue); expect(bundle.entries.containsKey('FontManifest.json'), isTrue);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
......
...@@ -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:convert'; import 'dart:convert';
import 'package:file/file.dart'; import 'package:file/file.dart';
...@@ -24,9 +22,9 @@ void main() { ...@@ -24,9 +22,9 @@ void main() {
// fixed we fix them here. // fixed we fix them here.
// TODO(dantup): Remove this function once the above issue is fixed and // TODO(dantup): Remove this function once the above issue is fixed and
// rolls into Flutter. // rolls into Flutter.
return path?.replaceAll('/', globals.fs.path.separator); return path.replaceAll('/', globals.fs.path.separator);
} }
void writePubspecFile(String path, String name, { List<String> assets }) { void writePubspecFile(String path, String name, { List<String>? assets }) {
String assetsSection; String assetsSection;
if (assets == null) { if (assets == null) {
assetsSection = ''; assetsSection = '';
...@@ -65,11 +63,11 @@ $assetsSection ...@@ -65,11 +63,11 @@ $assetsSection
Future<void> buildAndVerifyAssets( Future<void> buildAndVerifyAssets(
List<String> assets, List<String> assets,
List<String> packages, List<String> packages,
String expectedAssetManifest, { String? expectedAssetManifest, {
bool expectExists = true, bool expectExists = true,
}) async { }) async {
final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'); await bundle.build(packagesPath: '.packages');
for (final String packageName in packages) { for (final String packageName in packages) {
for (final String asset in assets) { for (final String asset in assets) {
...@@ -78,7 +76,7 @@ $assetsSection ...@@ -78,7 +76,7 @@ $assetsSection
reason: 'Cannot find key on bundle: $entryKey'); reason: 'Cannot find key on bundle: $entryKey');
if (expectExists) { if (expectExists) {
expect( expect(
utf8.decode(await bundle.entries[entryKey].contentsAsBytes()), utf8.decode(await bundle.entries[entryKey]!.contentsAsBytes()),
asset, asset,
); );
} }
...@@ -87,7 +85,7 @@ $assetsSection ...@@ -87,7 +85,7 @@ $assetsSection
if (expectExists) { if (expectExists) {
expect( expect(
utf8.decode(await bundle.entries['AssetManifest.json'].contentsAsBytes()), utf8.decode(await bundle.entries['AssetManifest.json']!.contentsAsBytes()),
expectedAssetManifest, expectedAssetManifest,
); );
} }
...@@ -103,7 +101,7 @@ $assetsSection ...@@ -103,7 +101,7 @@ $assetsSection
} }
} }
FileSystem testFileSystem; late FileSystem testFileSystem;
setUp(() async { setUp(() async {
testFileSystem = MemoryFileSystem( testFileSystem = MemoryFileSystem(
...@@ -121,15 +119,15 @@ $assetsSection ...@@ -121,15 +119,15 @@ $assetsSection
writePubspecFile('p/p/pubspec.yaml', 'test_package'); writePubspecFile('p/p/pubspec.yaml', 'test_package');
final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'); await bundle.build(packagesPath: '.packages');
expect(bundle.entries.length, 3); // LICENSE, AssetManifest, FontManifest expect(bundle.entries.length, 3); // LICENSE, AssetManifest, FontManifest
const String expectedAssetManifest = '{}'; const String expectedAssetManifest = '{}';
expect( expect(
utf8.decode(await bundle.entries['AssetManifest.json'].contentsAsBytes()), utf8.decode(await bundle.entries['AssetManifest.json']!.contentsAsBytes()),
expectedAssetManifest, expectedAssetManifest,
); );
expect( expect(
utf8.decode(await bundle.entries['FontManifest.json'].contentsAsBytes()), utf8.decode(await bundle.entries['FontManifest.json']!.contentsAsBytes()),
'[]', '[]',
); );
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
...@@ -146,15 +144,15 @@ $assetsSection ...@@ -146,15 +144,15 @@ $assetsSection
writeAssets('p/p/', assets); writeAssets('p/p/', assets);
final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'); await bundle.build(packagesPath: '.packages');
expect(bundle.entries.length, 3); // LICENSE, AssetManifest, FontManifest expect(bundle.entries.length, 3); // LICENSE, AssetManifest, FontManifest
const String expectedAssetManifest = '{}'; const String expectedAssetManifest = '{}';
expect( expect(
utf8.decode(await bundle.entries['AssetManifest.json'].contentsAsBytes()), utf8.decode(await bundle.entries['AssetManifest.json']!.contentsAsBytes()),
expectedAssetManifest, expectedAssetManifest,
); );
expect( expect(
utf8.decode(await bundle.entries['FontManifest.json'].contentsAsBytes()), utf8.decode(await bundle.entries['FontManifest.json']!.contentsAsBytes()),
'[]', '[]',
); );
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
...@@ -540,7 +538,7 @@ $assetsSection ...@@ -540,7 +538,7 @@ $assetsSection
writeAssets('p/p/', assetsOnDisk); writeAssets('p/p/', assetsOnDisk);
final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'); await bundle.build(packagesPath: '.packages');
expect(bundle.entries['AssetManifest.json'], isNull, expect(bundle.entries['AssetManifest.json'], isNull,
reason: 'Invalid pubspec.yaml should not generate AssetManifest.json' ); reason: 'Invalid pubspec.yaml should not generate AssetManifest.json' );
......
...@@ -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:convert'; import 'dart:convert';
import 'package:file/file.dart'; import 'package:file/file.dart';
...@@ -24,11 +22,11 @@ void main() { ...@@ -24,11 +22,11 @@ void main() {
// fixed we fix them here. // fixed we fix them here.
// TODO(dantup): Remove this function once the above issue is fixed and // TODO(dantup): Remove this function once the above issue is fixed and
// rolls into Flutter. // rolls into Flutter.
return path?.replaceAll('/', globals.fs.path.separator); return path.replaceAll('/', globals.fs.path.separator);
} }
group('AssetBundle asset variants', () { group('AssetBundle asset variants', () {
FileSystem testFileSystem; late FileSystem testFileSystem;
setUp(() async { setUp(() async {
testFileSystem = MemoryFileSystem( testFileSystem = MemoryFileSystem(
style: globals.platform.isWindows style: globals.platform.isWindows
...@@ -67,24 +65,24 @@ flutter: ...@@ -67,24 +65,24 @@ flutter:
} }
AssetBundle bundle = AssetBundleFactory.instance.createBundle(); AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'); await bundle.build(packagesPath: '.packages');
// The main asset file, /a/b/c/foo, and its variants exist. // The main asset file, /a/b/c/foo, and its variants exist.
for (final String asset in assets) { for (final String asset in assets) {
expect(bundle.entries.containsKey(asset), true); expect(bundle.entries.containsKey(asset), true);
expect(utf8.decode(await bundle.entries[asset].contentsAsBytes()), asset); expect(utf8.decode(await bundle.entries[asset]!.contentsAsBytes()), asset);
} }
globals.fs.file(fixPath('a/b/c/foo')).deleteSync(); globals.fs.file(fixPath('a/b/c/foo')).deleteSync();
bundle = AssetBundleFactory.instance.createBundle(); bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'); await bundle.build(packagesPath: '.packages');
// Now the main asset file, /a/b/c/foo, does not exist. This is OK because // Now the main asset file, /a/b/c/foo, does not exist. This is OK because
// the /a/b/c/*/foo variants do exist. // the /a/b/c/*/foo variants do exist.
expect(bundle.entries.containsKey('a/b/c/foo'), false); expect(bundle.entries.containsKey('a/b/c/foo'), false);
for (final String asset in assets.skip(1)) { for (final String asset in assets.skip(1)) {
expect(bundle.entries.containsKey(asset), true); expect(bundle.entries.containsKey(asset), true);
expect(utf8.decode(await bundle.entries[asset].contentsAsBytes()), asset); expect(utf8.decode(await bundle.entries[asset]!.contentsAsBytes()), asset);
} }
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => testFileSystem, FileSystem: () => testFileSystem,
......
...@@ -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:flutter_tools/src/asset.dart'; import 'package:flutter_tools/src/asset.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';
...@@ -86,5 +84,5 @@ void main() { ...@@ -86,5 +84,5 @@ void main() {
} }
Future<String> getValueAsString(String key, AssetBundle asset) async { Future<String> getValueAsString(String key, AssetBundle asset) async {
return String.fromCharCodes(await asset.entries[key].contentsAsBytes()); return String.fromCharCodes(await asset.entries[key]!.contentsAsBytes());
} }
...@@ -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: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';
import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/platform.dart';
...@@ -21,9 +19,9 @@ final Platform windowsPlatform = FakePlatform( ...@@ -21,9 +19,9 @@ final Platform windowsPlatform = FakePlatform(
); );
void main() { void main() {
Testbed testbed; late Testbed testbed;
SourceVisitor visitor; late SourceVisitor visitor;
Environment environment; late Environment environment;
setUp(() { setUp(() {
testbed = Testbed(setup: () { testbed = Testbed(setup: () {
...@@ -33,7 +31,7 @@ void main() { ...@@ -33,7 +31,7 @@ void main() {
environment = Environment.test( environment = Environment.test(
globals.fs.currentDirectory, globals.fs.currentDirectory,
outputDir: outputs, outputDir: outputs,
artifacts: globals.artifacts, // using real artifacts artifacts: globals.artifacts!, // using real artifacts
processManager: FakeProcessManager.any(), processManager: FakeProcessManager.any(),
fileSystem: globals.fs, fileSystem: globals.fs,
// engineVersion being null simulates a local engine. // engineVersion being null simulates a local engine.
......
...@@ -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/artifacts.dart'; import 'package:flutter_tools/src/artifacts.dart';
...@@ -21,10 +19,10 @@ import '../../../src/context.dart'; ...@@ -21,10 +19,10 @@ import '../../../src/context.dart';
import '../../../src/fake_process_manager.dart'; import '../../../src/fake_process_manager.dart';
void main() { void main() {
FakeProcessManager processManager; late FakeProcessManager processManager;
FileSystem fileSystem; late FileSystem fileSystem;
Artifacts artifacts; late Artifacts artifacts;
Logger logger; late Logger logger;
setUp(() { setUp(() {
logger = BufferLogger.test(); logger = BufferLogger.test();
......
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
// 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:collection/collection.dart' show IterableExtension;
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/artifacts.dart'; import 'package:flutter_tools/src/artifacts.dart';
...@@ -21,8 +20,8 @@ import '../../../src/common.dart'; ...@@ -21,8 +20,8 @@ import '../../../src/common.dart';
import '../../../src/context.dart'; import '../../../src/context.dart';
void main() { void main() {
Environment environment; late Environment environment;
FileSystem fileSystem; late FileSystem fileSystem;
setUp(() { setUp(() {
fileSystem = MemoryFileSystem.test(); fileSystem = MemoryFileSystem.test();
...@@ -75,7 +74,7 @@ flutter: ...@@ -75,7 +74,7 @@ flutter:
final Depfile dependencies = depfileService.parse(depfile); final Depfile dependencies = depfileService.parse(depfile);
expect( expect(
dependencies.inputs.firstWhere((File file) => file.path == '/bar/LICENSE', orElse: () => null), dependencies.inputs.firstWhereOrNull((File file) => file.path == '/bar/LICENSE'),
isNotNull, isNotNull,
); );
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
...@@ -124,7 +123,6 @@ flutter: ...@@ -124,7 +123,6 @@ flutter:
targetPlatform: TargetPlatform.android, targetPlatform: TargetPlatform.android,
fileSystem: MemoryFileSystem.test(), fileSystem: MemoryFileSystem.test(),
logger: BufferLogger.test(), logger: BufferLogger.test(),
engineVersion: null,
), isNull); ), isNull);
}); });
...@@ -136,7 +134,6 @@ flutter: ...@@ -136,7 +134,6 @@ flutter:
targetPlatform: TargetPlatform.android, targetPlatform: TargetPlatform.android,
fileSystem: MemoryFileSystem.test(), fileSystem: MemoryFileSystem.test(),
logger: BufferLogger.test(), logger: BufferLogger.test(),
engineVersion: null,
), throwsException); ), throwsException);
}); });
...@@ -152,7 +149,6 @@ flutter: ...@@ -152,7 +149,6 @@ flutter:
targetPlatform: TargetPlatform.android, targetPlatform: TargetPlatform.android,
fileSystem: fileSystem, fileSystem: fileSystem,
logger: logger, logger: logger,
engineVersion: null,
), throwsException); ), throwsException);
expect(logger.errorText, contains('was not a JSON object')); expect(logger.errorText, contains('was not a JSON object'));
}); });
...@@ -169,7 +165,6 @@ flutter: ...@@ -169,7 +165,6 @@ flutter:
targetPlatform: TargetPlatform.android, targetPlatform: TargetPlatform.android,
fileSystem: fileSystem, fileSystem: fileSystem,
logger: logger, logger: logger,
engineVersion: null,
), throwsException); ), throwsException);
expect(logger.errorText, contains('was not a JSON object')); expect(logger.errorText, contains('was not a JSON object'));
}); });
...@@ -214,7 +209,7 @@ flutter: ...@@ -214,7 +209,7 @@ flutter:
fileSystem: fileSystem, fileSystem: fileSystem,
logger: logger, logger: logger,
engineVersion: '2', engineVersion: '2',
); )!;
expect(await content.contentsAsBytes(), utf8.encode('{"data":{}}')); expect(await content.contentsAsBytes(), utf8.encode('{"data":{}}'));
expect(logger.errorText, contains('This may lead to less efficient shader caching')); expect(logger.errorText, contains('This may lead to less efficient shader caching'));
...@@ -238,7 +233,7 @@ flutter: ...@@ -238,7 +233,7 @@ flutter:
fileSystem: fileSystem, fileSystem: fileSystem,
logger: logger, logger: logger,
engineVersion: '2', engineVersion: '2',
); )!;
expect(await content.contentsAsBytes(), utf8.encode('{"data":{}}')); expect(await content.contentsAsBytes(), utf8.encode('{"data":{}}'));
expect(logger.errorText, isEmpty); expect(logger.errorText, isEmpty);
......
...@@ -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';
...@@ -26,12 +24,12 @@ const String kAssemblyAot = '--snapshot_kind=app-aot-assembly'; ...@@ -26,12 +24,12 @@ const String kAssemblyAot = '--snapshot_kind=app-aot-assembly';
final Platform macPlatform = FakePlatform(operatingSystem: 'macos', environment: <String, String>{}); final Platform macPlatform = FakePlatform(operatingSystem: 'macos', environment: <String, String>{});
void main() { void main() {
FakeProcessManager processManager; late FakeProcessManager processManager;
Environment androidEnvironment; late Environment androidEnvironment;
Environment iosEnvironment; late Environment iosEnvironment;
Artifacts artifacts; late Artifacts artifacts;
FileSystem fileSystem; late FileSystem fileSystem;
Logger logger; late Logger logger;
setUp(() { setUp(() {
processManager = FakeProcessManager.empty(); processManager = FakeProcessManager.empty();
......
...@@ -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
// TODO(gspencergoog): Remove this tag once this test's state leaks/test // TODO(gspencergoog): Remove this tag once this test's state leaks/test
// dependencies have been fixed. // dependencies have been fixed.
// https://github.com/flutter/flutter/issues/85160 // https://github.com/flutter/flutter/issues/85160
......
...@@ -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';
...@@ -19,8 +17,8 @@ import '../../../src/context.dart'; ...@@ -19,8 +17,8 @@ import '../../../src/context.dart';
// These tests perform a simple check to verify if the check/task was executed at all. // These tests perform a simple check to verify if the check/task was executed at all.
// Detailed per-check tests are in android/deferred_components_setup_validator_test.dart. // Detailed per-check tests are in android/deferred_components_setup_validator_test.dart.
void main() { void main() {
FileSystem fileSystem; late FileSystem fileSystem;
BufferLogger logger; late BufferLogger logger;
setUp(() { setUp(() {
logger = BufferLogger.test(); logger = BufferLogger.test();
...@@ -55,9 +53,9 @@ void main() { ...@@ -55,9 +53,9 @@ void main() {
await validatorTarget.build(environment); await validatorTarget.build(environment);
// We check the inputs to determine if the task was executed. // We check the inputs to determine if the task was executed.
expect(validatorTarget.validator.inputs.length, 3); expect(validatorTarget.validator!.inputs.length, 3);
expect(validatorTarget.validator.inputs[0].path, 'project/pubspec.yaml'); expect(validatorTarget.validator!.inputs[0].path, 'project/pubspec.yaml');
expect(validatorTarget.validator.inputs[1].path, 'project/android/app/src/main/AndroidManifest.xml'); expect(validatorTarget.validator!.inputs[1].path, 'project/android/app/src/main/AndroidManifest.xml');
}); });
testUsingContext('checkAgainstLoadingUnitsCache checks runs', () async { testUsingContext('checkAgainstLoadingUnitsCache checks runs', () async {
...@@ -88,8 +86,8 @@ void main() { ...@@ -88,8 +86,8 @@ void main() {
await validatorTarget.build(environment); await validatorTarget.build(environment);
// We check the inputs to determine if the task was executed. // We check the inputs to determine if the task was executed.
expect(validatorTarget.validator.inputs.length, 3); expect(validatorTarget.validator!.inputs.length, 3);
expect(validatorTarget.validator.inputs[2].path, 'project/deferred_components_loading_units.yaml'); expect(validatorTarget.validator!.inputs[2].path, 'project/deferred_components_loading_units.yaml');
}); });
testUsingContext('writeLoadingUnitsCache task runs', () async { testUsingContext('writeLoadingUnitsCache task runs', () async {
...@@ -120,7 +118,7 @@ void main() { ...@@ -120,7 +118,7 @@ void main() {
await validatorTarget.build(environment); await validatorTarget.build(environment);
// We check the inputs to determine if the task was executed. // We check the inputs to determine if the task was executed.
expect(validatorTarget.validator.outputs.length, 1); expect(validatorTarget.validator!.outputs.length, 1);
expect(validatorTarget.validator.outputs[0].path, 'project/deferred_components_loading_units.yaml'); expect(validatorTarget.validator!.outputs[0].path, 'project/deferred_components_loading_units.yaml');
}); });
} }
...@@ -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/artifacts.dart'; import 'package:flutter_tools/src/artifacts.dart';
...@@ -39,11 +37,11 @@ const List<String> _kSharedConfig = <String>[ ...@@ -39,11 +37,11 @@ const List<String> _kSharedConfig = <String>[
]; ];
void main() { void main() {
Environment environment; late Environment environment;
FileSystem fileSystem; late FileSystem fileSystem;
FakeProcessManager processManager; late FakeProcessManager processManager;
Artifacts artifacts; late Artifacts artifacts;
BufferLogger logger; late BufferLogger logger;
setUp(() { setUp(() {
fileSystem = MemoryFileSystem.test(); fileSystem = MemoryFileSystem.test();
...@@ -323,13 +321,13 @@ void main() { ...@@ -323,13 +321,13 @@ void main() {
}); });
group('copies Flutter.framework', () { group('copies Flutter.framework', () {
Directory outputDir; late Directory outputDir;
File binary; late File binary;
FakeCommand copyPhysicalFrameworkCommand; late FakeCommand copyPhysicalFrameworkCommand;
FakeCommand lipoCommandNonFatResult; late FakeCommand lipoCommandNonFatResult;
FakeCommand lipoVerifyArm64Command; late FakeCommand lipoVerifyArm64Command;
FakeCommand bitcodeStripCommand; late FakeCommand bitcodeStripCommand;
FakeCommand adHocCodesignCommand; late FakeCommand adHocCodesignCommand;
setUp(() { setUp(() {
final FileSystem fileSystem = MemoryFileSystem.test(); final FileSystem fileSystem = MemoryFileSystem.test();
......
...@@ -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/artifacts.dart'; import 'package:flutter_tools/src/artifacts.dart';
...@@ -90,7 +88,8 @@ void main() { ...@@ -90,7 +88,8 @@ void main() {
}); });
// Only required for the test below that still depends on the context. // Only required for the test below that still depends on the context.
FileSystem fileSystem; late FileSystem fileSystem;
setUp(() { setUp(() {
fileSystem = MemoryFileSystem.test(); fileSystem = MemoryFileSystem.test();
}); });
......
...@@ -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/artifacts.dart'; import 'package:flutter_tools/src/artifacts.dart';
...@@ -19,16 +17,16 @@ import '../../../src/context.dart'; ...@@ -19,16 +17,16 @@ import '../../../src/context.dart';
import '../../../src/fake_process_manager.dart'; import '../../../src/fake_process_manager.dart';
void main() { void main() {
Environment environment; late Environment environment;
FileSystem fileSystem; late FileSystem fileSystem;
Artifacts artifacts; late Artifacts artifacts;
FakeProcessManager processManager; late FakeProcessManager processManager;
File binary; late File binary;
BufferLogger logger; late BufferLogger logger;
FakeCommand copyFrameworkCommand; late FakeCommand copyFrameworkCommand;
FakeCommand lipoInfoNonFatCommand; late FakeCommand lipoInfoNonFatCommand;
FakeCommand lipoInfoFatCommand; late FakeCommand lipoInfoFatCommand;
FakeCommand lipoVerifyX86_64Command; late FakeCommand lipoVerifyX86_64Command;
setUp(() { setUp(() {
processManager = FakeProcessManager.empty(); processManager = FakeProcessManager.empty();
......
...@@ -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_testing/file_testing.dart'; import 'package:file_testing/file_testing.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';
...@@ -30,9 +28,9 @@ const List<String> kDart2jsLinuxArgs = <String>[ ...@@ -30,9 +28,9 @@ const List<String> kDart2jsLinuxArgs = <String>[
]; ];
void main() { void main() {
Testbed testbed; late Testbed testbed;
Environment environment; late Environment environment;
FakeProcessManager processManager; late FakeProcessManager processManager;
final Platform linux = FakePlatform( final Platform linux = FakePlatform(
environment: <String, String>{}, environment: <String, String>{},
); );
...@@ -40,7 +38,7 @@ void main() { ...@@ -40,7 +38,7 @@ void main() {
operatingSystem: 'windows', operatingSystem: 'windows',
environment: <String, String>{}, environment: <String, String>{},
); );
DepfileService depfileService; late DepfileService depfileService;
setUp(() { setUp(() {
testbed = Testbed(setup: () { testbed = Testbed(setup: () {
......
...@@ -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/artifacts.dart'; import 'package:flutter_tools/src/artifacts.dart';
...@@ -120,7 +118,7 @@ void main() { ...@@ -120,7 +118,7 @@ void main() {
}); });
// AssetBundleFactory still uses context injection // AssetBundleFactory still uses context injection
FileSystem fileSystem; late FileSystem fileSystem;
setUp(() { setUp(() {
fileSystem = MemoryFileSystem.test(style: FileSystemStyle.windows); fileSystem = MemoryFileSystem.test(style: FileSystemStyle.windows);
......
...@@ -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/base/config.dart'; import 'package:flutter_tools/src/base/config.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
...@@ -71,7 +69,7 @@ void main() { ...@@ -71,7 +69,7 @@ void main() {
final String mainPath = globals.fs.path.join('lib', 'main.dart'); final String mainPath = globals.fs.path.join('lib', 'main.dart');
const String assetDirPath = 'example'; const String assetDirPath = 'example';
const String depfilePath = 'example.d'; const String depfilePath = 'example.d';
Environment env; Environment? env;
final BuildSystem buildSystem = TestBuildSystem.all( final BuildSystem buildSystem = TestBuildSystem.all(
BuildResult(success: true), BuildResult(success: true),
(Target target, Environment environment) { (Target target, Environment environment) {
...@@ -104,17 +102,17 @@ void main() { ...@@ -104,17 +102,17 @@ void main() {
); );
expect(env, isNotNull); expect(env, isNotNull);
expect(env.defines[kBuildMode], 'debug'); expect(env!.defines[kBuildMode], 'debug');
expect(env.defines[kTargetPlatform], 'ios'); expect(env!.defines[kTargetPlatform], 'ios');
expect(env.defines[kTargetFile], mainPath); expect(env!.defines[kTargetFile], mainPath);
expect(env.defines[kTrackWidgetCreation], 'true'); expect(env!.defines[kTrackWidgetCreation], 'true');
expect(env.defines[kExtraFrontEndOptions], 'test1,test2'); expect(env!.defines[kExtraFrontEndOptions], 'test1,test2');
expect(env.defines[kExtraGenSnapshotOptions], 'test3,test4'); expect(env!.defines[kExtraGenSnapshotOptions], 'test3,test4');
expect(env.defines[kFileSystemRoots], 'test5,test6'); expect(env!.defines[kFileSystemRoots], 'test5,test6');
expect(env.defines[kFileSystemScheme], 'test7'); expect(env!.defines[kFileSystemScheme], 'test7');
expect(env.defines[kDartDefines], encodeDartDefines(<String>['test8', 'test9'])); expect(env!.defines[kDartDefines], encodeDartDefines(<String>['test8', 'test9']));
expect(env.defines[kIconTreeShakerFlag], 'true'); expect(env!.defines[kIconTreeShakerFlag], 'true');
expect(env.defines[kDeferredComponents], 'false'); expect(env!.defines[kDeferredComponents], 'false');
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem.test(), FileSystem: () => MemoryFileSystem.test(),
ProcessManager: () => FakeProcessManager.any(), ProcessManager: () => FakeProcessManager.any(),
......
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
// 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:collection/collection.dart' show IterableExtension;
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:file_testing/file_testing.dart'; import 'package:file_testing/file_testing.dart';
...@@ -17,7 +16,6 @@ import 'package:flutter_tools/src/cache.dart'; ...@@ -17,7 +16,6 @@ import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/dart/pub.dart'; import 'package:flutter_tools/src/dart/pub.dart';
import 'package:flutter_tools/src/flutter_cache.dart'; import 'package:flutter_tools/src/flutter_cache.dart';
import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:meta/meta.dart';
import 'package:test/fake.dart'; import 'package:test/fake.dart';
import '../src/common.dart'; import '../src/common.dart';
...@@ -41,7 +39,7 @@ const FakeCommand unameCommandForArm64 = FakeCommand( ...@@ -41,7 +39,7 @@ const FakeCommand unameCommandForArm64 = FakeCommand(
); );
void main() { void main() {
FakeProcessManager fakeProcessManager; late FakeProcessManager fakeProcessManager;
setUp(() { setUp(() {
fakeProcessManager = FakeProcessManager.empty(); fakeProcessManager = FakeProcessManager.empty();
...@@ -79,7 +77,7 @@ void main() { ...@@ -79,7 +77,7 @@ void main() {
}); });
testWithoutContext('should not throw when lock is acquired', () async { testWithoutContext('should not throw when lock is acquired', () async {
final String oldRoot = Cache.flutterRoot; final String? oldRoot = Cache.flutterRoot;
Cache.flutterRoot = ''; Cache.flutterRoot = '';
try { try {
final FileSystem fileSystem = MemoryFileSystem.test(); final FileSystem fileSystem = MemoryFileSystem.test();
...@@ -365,7 +363,7 @@ void main() { ...@@ -365,7 +363,7 @@ void main() {
final Directory dir = fileSystem.systemTempDirectory final Directory dir = fileSystem.systemTempDirectory
.listSync(recursive: true) .listSync(recursive: true)
.whereType<Directory>() .whereType<Directory>()
.singleWhere((Directory directory) => directory.basename == 'bin_dir', orElse: () => null); .singleWhereOrNull((Directory directory) => directory.basename == 'bin_dir')!;
expect(dir, isNotNull); expect(dir, isNotNull);
expect(dir.path, artifactDir.childDirectory('bin_dir').path); expect(dir.path, artifactDir.childDirectory('bin_dir').path);
...@@ -458,6 +456,7 @@ void main() { ...@@ -458,6 +456,7 @@ void main() {
testWithoutContext('FlutterRunnerDebugSymbols downloads Flutter runner debug symbols', () async { testWithoutContext('FlutterRunnerDebugSymbols downloads Flutter runner debug symbols', () async {
final FileSystem fileSystem = MemoryFileSystem.test(); final FileSystem fileSystem = MemoryFileSystem.test();
final Cache cache = FakeSecondaryCache() final Cache cache = FakeSecondaryCache()
..artifactDirectory = fileSystem.currentDirectory
..version = '123456'; ..version = '123456';
final FakeVersionedPackageResolver packageResolver = FakeVersionedPackageResolver(); final FakeVersionedPackageResolver packageResolver = FakeVersionedPackageResolver();
...@@ -974,9 +973,9 @@ void main() { ...@@ -974,9 +973,9 @@ void main() {
}); });
group('AndroidMavenArtifacts', () { group('AndroidMavenArtifacts', () {
MemoryFileSystem memoryFileSystem; MemoryFileSystem? memoryFileSystem;
Cache cache; Cache? cache;
FakeAndroidSdk fakeAndroidSdk; FakeAndroidSdk? fakeAndroidSdk;
setUp(() { setUp(() {
memoryFileSystem = MemoryFileSystem.test(); memoryFileSystem = MemoryFileSystem.test();
...@@ -988,25 +987,25 @@ void main() { ...@@ -988,25 +987,25 @@ void main() {
}); });
testWithoutContext('AndroidMavenArtifacts has a specified development artifact', () async { testWithoutContext('AndroidMavenArtifacts has a specified development artifact', () async {
final AndroidMavenArtifacts mavenArtifacts = AndroidMavenArtifacts(cache, platform: FakePlatform()); final AndroidMavenArtifacts mavenArtifacts = AndroidMavenArtifacts(cache!, platform: FakePlatform());
expect(mavenArtifacts.developmentArtifact, DevelopmentArtifact.androidMaven); expect(mavenArtifacts.developmentArtifact, DevelopmentArtifact.androidMaven);
}); });
testUsingContext('AndroidMavenArtifacts can invoke Gradle resolve dependencies if Android SDK is present', () async { testUsingContext('AndroidMavenArtifacts can invoke Gradle resolve dependencies if Android SDK is present', () async {
final String oldRoot = Cache.flutterRoot; final String? oldRoot = Cache.flutterRoot;
Cache.flutterRoot = ''; Cache.flutterRoot = '';
try { try {
final AndroidMavenArtifacts mavenArtifacts = AndroidMavenArtifacts(cache, platform: FakePlatform()); final AndroidMavenArtifacts mavenArtifacts = AndroidMavenArtifacts(cache!, platform: FakePlatform());
expect(await mavenArtifacts.isUpToDate(memoryFileSystem), isFalse); expect(await mavenArtifacts.isUpToDate(memoryFileSystem!), isFalse);
final Directory gradleWrapperDir = cache.getArtifactDirectory('gradle_wrapper')..createSync(recursive: true); final Directory gradleWrapperDir = cache!.getArtifactDirectory('gradle_wrapper')..createSync(recursive: true);
gradleWrapperDir.childFile('gradlew').writeAsStringSync('irrelevant'); gradleWrapperDir.childFile('gradlew').writeAsStringSync('irrelevant');
gradleWrapperDir.childFile('gradlew.bat').writeAsStringSync('irrelevant'); gradleWrapperDir.childFile('gradlew.bat').writeAsStringSync('irrelevant');
await mavenArtifacts.update(FakeArtifactUpdater(), BufferLogger.test(), memoryFileSystem, FakeOperatingSystemUtils()); await mavenArtifacts.update(FakeArtifactUpdater(), BufferLogger.test(), memoryFileSystem!, FakeOperatingSystemUtils());
expect(await mavenArtifacts.isUpToDate(memoryFileSystem), isFalse); expect(await mavenArtifacts.isUpToDate(memoryFileSystem!), isFalse);
expect(fakeAndroidSdk.reinitialized, true); expect(fakeAndroidSdk!.reinitialized, true);
} finally { } finally {
Cache.flutterRoot = oldRoot; Cache.flutterRoot = oldRoot;
} }
...@@ -1028,12 +1027,12 @@ void main() { ...@@ -1028,12 +1027,12 @@ void main() {
}); });
testUsingContext('AndroidMavenArtifacts is a no-op if the Android SDK is absent', () async { testUsingContext('AndroidMavenArtifacts is a no-op if the Android SDK is absent', () async {
final AndroidMavenArtifacts mavenArtifacts = AndroidMavenArtifacts(cache, platform: FakePlatform()); final AndroidMavenArtifacts mavenArtifacts = AndroidMavenArtifacts(cache!, platform: FakePlatform());
expect(await mavenArtifacts.isUpToDate(memoryFileSystem), isFalse); expect(await mavenArtifacts.isUpToDate(memoryFileSystem!), isFalse);
await mavenArtifacts.update(FakeArtifactUpdater(), BufferLogger.test(), memoryFileSystem, FakeOperatingSystemUtils()); await mavenArtifacts.update(FakeArtifactUpdater(), BufferLogger.test(), memoryFileSystem!, FakeOperatingSystemUtils());
expect(await mavenArtifacts.isUpToDate(memoryFileSystem), isFalse); expect(await mavenArtifacts.isUpToDate(memoryFileSystem!), isFalse);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Cache: () => cache, Cache: () => cache,
FileSystem: () => memoryFileSystem, FileSystem: () => memoryFileSystem,
...@@ -1046,8 +1045,8 @@ void main() { ...@@ -1046,8 +1045,8 @@ void main() {
class FakeCachedArtifact extends EngineCachedArtifact { class FakeCachedArtifact extends EngineCachedArtifact {
FakeCachedArtifact({ FakeCachedArtifact({
String stampName = 'STAMP', String stampName = 'STAMP',
@required Cache cache, required Cache cache,
DevelopmentArtifact requiredArtifacts, required DevelopmentArtifact requiredArtifacts,
this.binaryDirs = const <List<String>>[], this.binaryDirs = const <List<String>>[],
this.licenseDirs = const <String>[], this.licenseDirs = const <String>[],
this.packageDirs = const <String>[], this.packageDirs = const <String>[],
...@@ -1081,7 +1080,7 @@ class FakeSimpleArtifact extends CachedArtifact { ...@@ -1081,7 +1080,7 @@ class FakeSimpleArtifact extends CachedArtifact {
class FakeSecondaryCachedArtifact extends Fake implements CachedArtifact { class FakeSecondaryCachedArtifact extends Fake implements CachedArtifact {
bool upToDate = false; bool upToDate = false;
bool didUpdate = false; bool didUpdate = false;
Exception updateException; Exception? updateException;
@override @override
Future<bool> isUpToDate(FileSystem fileSystem) async => upToDate; Future<bool> isUpToDate(FileSystem fileSystem) async => upToDate;
...@@ -1089,7 +1088,7 @@ class FakeSecondaryCachedArtifact extends Fake implements CachedArtifact { ...@@ -1089,7 +1088,7 @@ class FakeSecondaryCachedArtifact extends Fake implements CachedArtifact {
@override @override
Future<void> update(ArtifactUpdater artifactUpdater, Logger logger, FileSystem fileSystem, OperatingSystemUtils operatingSystemUtils, {bool offline = false}) async { Future<void> update(ArtifactUpdater artifactUpdater, Logger logger, FileSystem fileSystem, OperatingSystemUtils operatingSystemUtils, {bool offline = false}) async {
if (updateException != null) { if (updateException != null) {
throw updateException; throw updateException!;
} }
didUpdate = true; didUpdate = true;
} }
...@@ -1107,10 +1106,10 @@ class FakeIosUsbArtifacts extends Fake implements IosUsbArtifacts { ...@@ -1107,10 +1106,10 @@ class FakeIosUsbArtifacts extends Fake implements IosUsbArtifacts {
} }
class FakeSecondaryCache extends Fake implements Cache { class FakeSecondaryCache extends Fake implements Cache {
Directory downloadDir; Directory? downloadDir;
Directory artifactDirectory; late Directory artifactDirectory;
String version; String? version;
void Function(String artifactName, String version) onSetStamp; late void Function(String artifactName, String version) onSetStamp;
@override @override
String get storageBaseUrl => 'https://storage.googleapis.com'; String get storageBaseUrl => 'https://storage.googleapis.com';
...@@ -1132,7 +1131,7 @@ class FakeSecondaryCache extends Fake implements Cache { ...@@ -1132,7 +1131,7 @@ class FakeSecondaryCache extends Fake implements Cache {
} }
@override @override
String getVersionFor(String artifactName) => version; String? getVersionFor(String artifactName) => version;
@override @override
void setStampFor(String artifactName, String version) { void setStampFor(String artifactName, String version) {
...@@ -1155,13 +1154,13 @@ class FakePub extends Fake implements Pub { ...@@ -1155,13 +1154,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,
...@@ -1172,19 +1171,15 @@ class FakePub extends Fake implements Pub { ...@@ -1172,19 +1171,15 @@ class FakePub extends Fake implements Pub {
class FakeCache extends Cache { class FakeCache extends Cache {
FakeCache({ FakeCache({
@required Logger logger, required super.logger,
@required FileSystem fileSystem, required super.fileSystem,
@required Platform platform, required super.platform,
@required OperatingSystemUtils osUtils, required super.osUtils,
}) : super( }) : super(
logger: logger,
fileSystem: fileSystem,
platform: platform,
osUtils: osUtils,
artifacts: <ArtifactSet>[], artifacts: <ArtifactSet>[],
); );
File stampFile; late File stampFile;
@override @override
File getStampFileFor(String artifactName) { File getStampFileFor(String artifactName) {
...@@ -1202,8 +1197,8 @@ class FakeAndroidSdk extends Fake implements AndroidSdk { ...@@ -1202,8 +1197,8 @@ class FakeAndroidSdk extends Fake implements AndroidSdk {
} }
class FakeArtifactUpdater extends Fake implements ArtifactUpdater { class FakeArtifactUpdater extends Fake implements ArtifactUpdater {
void Function(String, Uri, Directory) onDownloadZipArchive; void Function(String, Uri, Directory)? onDownloadZipArchive;
void Function(String, Uri, Directory) onDownloadZipTarball; void Function(String, Uri, Directory)? onDownloadZipTarball;
@override @override
Future<void> downloadZippedTarball(String message, Uri url, Directory location) async { Future<void> downloadZippedTarball(String message, Uri url, Directory location) async {
......
...@@ -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
// TODO(gspencergoog): Remove this tag once this test's state leaks/test // TODO(gspencergoog): Remove this tag once this test's state leaks/test
// dependencies have been fixed. // dependencies have been fixed.
// https://github.com/flutter/flutter/issues/85160 // https://github.com/flutter/flutter/issues/85160
...@@ -24,7 +22,7 @@ import '../src/test_flutter_command_runner.dart'; ...@@ -24,7 +22,7 @@ import '../src/test_flutter_command_runner.dart';
void main() { void main() {
group('channel', () { group('channel', () {
FakeProcessManager fakeProcessManager; late FakeProcessManager fakeProcessManager;
setUp(() { setUp(() {
fakeProcessManager = FakeProcessManager.empty(); fakeProcessManager = FakeProcessManager.empty();
...@@ -159,7 +157,7 @@ void main() { ...@@ -159,7 +157,7 @@ void main() {
final Iterable<String> rows = testLogger.statusText final Iterable<String> rows = testLogger.statusText
.split('\n') .split('\n')
.map((String line) => line.trim()) .map((String line) => line.trim())
.where((String line) => line?.isNotEmpty == true) .where((String line) => line.isNotEmpty == true)
.skip(1); // remove `Flutter channels:` line .skip(1); // remove `Flutter channels:` line
expect(rows, <String>['beta', 'stable', 'Currently not on an official channel.']); expect(rows, <String>['beta', 'stable', 'Currently not on an official channel.']);
...@@ -190,7 +188,7 @@ void main() { ...@@ -190,7 +188,7 @@ void main() {
final Iterable<String> rows = testLogger.statusText final Iterable<String> rows = testLogger.statusText
.split('\n') .split('\n')
.map((String line) => line.trim()) .map((String line) => line.trim())
.where((String line) => line?.isNotEmpty == true) .where((String line) => line.isNotEmpty == true)
.skip(1); // remove `Flutter channels:` line .skip(1); // remove `Flutter channels:` line
expect(rows, <String>['beta', 'stable', 'Currently not on an official channel.']); expect(rows, <String>['beta', 'stable', 'Currently not on an official channel.']);
......
...@@ -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';
...@@ -17,11 +15,11 @@ const String _kTestFlutterRoot = '/flutter'; ...@@ -17,11 +15,11 @@ const String _kTestFlutterRoot = '/flutter';
const String _kTestWindowsFlutterRoot = r'C:\flutter'; const String _kTestWindowsFlutterRoot = r'C:\flutter';
void main() { void main() {
FileSystem fileSystem; late FileSystem fileSystem;
late ProcessManager processManager;
ProcessManager processManager;
setUp(() { setUp(() {
processManager = FakeProcessManager.any();
fileSystem = MemoryFileSystem.test(); fileSystem = MemoryFileSystem.test();
}); });
...@@ -33,7 +31,7 @@ void main() { ...@@ -33,7 +31,7 @@ void main() {
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsStringSync('set(BINARY_NAME "hello")'); ..writeAsStringSync('set(BINARY_NAME "hello")');
final String name = getCmakeExecutableName(cmakeProject); final String? name = getCmakeExecutableName(cmakeProject);
expect(name, 'hello'); expect(name, 'hello');
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
...@@ -45,7 +43,7 @@ void main() { ...@@ -45,7 +43,7 @@ void main() {
final FlutterProject project = FlutterProject.fromDirectoryTest(fileSystem.currentDirectory); final FlutterProject project = FlutterProject.fromDirectoryTest(fileSystem.currentDirectory);
final CmakeBasedProject cmakeProject = _FakeProject.fromFlutter(project); final CmakeBasedProject cmakeProject = _FakeProject.fromFlutter(project);
final String name = getCmakeExecutableName(cmakeProject); final String? name = getCmakeExecutableName(cmakeProject);
expect(name, isNull); expect(name, isNull);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
......
...@@ -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/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/io.dart';
...@@ -15,7 +13,6 @@ import 'package:flutter_tools/src/resident_runner.dart'; ...@@ -15,7 +13,6 @@ import 'package:flutter_tools/src/resident_runner.dart';
import 'package:flutter_tools/src/run_cold.dart'; import 'package:flutter_tools/src/run_cold.dart';
import 'package:flutter_tools/src/tracing.dart'; import 'package:flutter_tools/src/tracing.dart';
import 'package:flutter_tools/src/vmservice.dart'; import 'package:flutter_tools/src/vmservice.dart';
import 'package:meta/meta.dart';
import 'package:test/fake.dart'; import 'package:test/fake.dart';
import 'package:vm_service/vm_service.dart'; import 'package:vm_service/vm_service.dart';
...@@ -68,8 +65,9 @@ void main() { ...@@ -68,8 +65,9 @@ void main() {
}); });
group('cold run', () { group('cold run', () {
MemoryFileSystem memoryFileSystem; late MemoryFileSystem memoryFileSystem;
FakePlatform fakePlatform; late FakePlatform fakePlatform;
setUp(() { setUp(() {
memoryFileSystem = MemoryFileSystem(); memoryFileSystem = MemoryFileSystem();
fakePlatform = FakePlatform(environment: <String, String>{}); fakePlatform = FakePlatform(environment: <String, String>{});
...@@ -159,7 +157,7 @@ class FakeFlutterDevice extends Fake implements FlutterDevice { ...@@ -159,7 +157,7 @@ class FakeFlutterDevice extends Fake implements FlutterDevice {
int runColdCode = 0; int runColdCode = 0;
@override @override
Future<int> runCold({ColdRunner coldRunner, String route}) async { Future<int> runCold({ColdRunner? coldRunner, String? route}) async {
return runColdCode; return runColdCode;
} }
...@@ -175,10 +173,10 @@ class FakeDevice extends Fake implements Device { ...@@ -175,10 +173,10 @@ class FakeDevice extends Fake implements Device {
bool isSupported() => true; bool isSupported() => true;
@override @override
bool supportsHotReload; bool supportsHotReload = false;
@override @override
bool supportsHotRestart; bool supportsHotRestart = false;
@override @override
Future<String> get sdkNameAndVersion async => 'Android 10'; Future<String> get sdkNameAndVersion async => 'Android 10';
...@@ -199,9 +197,9 @@ class FakeDevice extends Fake implements Device { ...@@ -199,9 +197,9 @@ class FakeDevice extends Fake implements Device {
class TestFlutterDevice extends FlutterDevice { class TestFlutterDevice extends FlutterDevice {
TestFlutterDevice({ TestFlutterDevice({
@required Device device, required Device device,
@required this.exception, required this.exception,
@required ResidentCompiler generator, required ResidentCompiler generator,
}) : assert(exception != null), }) : assert(exception != null),
super(device, buildInfo: BuildInfo.debug, generator: generator); super(device, buildInfo: BuildInfo.debug, generator: generator);
...@@ -210,17 +208,17 @@ class TestFlutterDevice extends FlutterDevice { ...@@ -210,17 +208,17 @@ class TestFlutterDevice extends FlutterDevice {
@override @override
Future<void> connect({ Future<void> connect({
ReloadSources reloadSources, ReloadSources? reloadSources,
Restart restart, Restart? restart,
CompileExpression compileExpression, CompileExpression? compileExpression,
GetSkSLMethod getSkSLMethod, GetSkSLMethod? getSkSLMethod,
PrintStructuredErrorLogMethod printStructuredErrorLogMethod, PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
bool enableDds = true, bool enableDds = true,
bool cacheStartupProfile = false, bool cacheStartupProfile = false,
bool disableServiceAuthCodes = false, bool disableServiceAuthCodes = false,
int hostVmServicePort, int? hostVmServicePort,
int ddsPort, int? ddsPort,
bool ipv6 = false, bool? ipv6 = false,
bool allowExistingDdsInstance = false, bool allowExistingDdsInstance = false,
}) async { }) async {
throw exception; throw exception;
...@@ -239,10 +237,10 @@ class FakeFlutterVmService extends Fake implements FlutterVmService { ...@@ -239,10 +237,10 @@ class FakeFlutterVmService extends Fake implements FlutterVmService {
} }
@override @override
Future<bool> flutterAlreadyPaintedFirstUsefulFrame({String isolateId}) async => true; Future<bool> flutterAlreadyPaintedFirstUsefulFrame({String? isolateId}) async => true;
@override @override
Future<Response> getTimeline() async { Future<Response?> getTimeline() async {
return Response.parse(<String, dynamic>{ return Response.parse(<String, dynamic>{
'traceEvents': <dynamic>[ 'traceEvents': <dynamic>[
<String, dynamic>{ <String, dynamic>{
......
...@@ -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:flutter_tools/src/test/coverage_collector.dart'; import 'package:flutter_tools/src/test/coverage_collector.dart';
import 'package:vm_service/vm_service.dart'; import 'package:vm_service/vm_service.dart';
...@@ -20,11 +18,11 @@ void main() { ...@@ -20,11 +18,11 @@ void main() {
), ),
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getVM', method: 'getVM',
jsonResponse: (VM.parse(<String, Object>{}) jsonResponse: (VM.parse(<String, Object>{})!
..isolates = <IsolateRef>[ ..isolates = <IsolateRef>[
IsolateRef.parse(<String, Object>{ IsolateRef.parse(<String, Object>{
'id': '1', 'id': '1',
}), })!,
] ]
).toJson(), ).toJson(),
), ),
...@@ -40,10 +38,10 @@ void main() { ...@@ -40,10 +38,10 @@ void main() {
], ],
); );
final Map<String, Object> result = await collect( final Map<String, Object?> result = await collect(
null, null,
<String>{'foo'}, <String>{'foo'},
connector: (Uri uri) async { connector: (Uri? uri) async {
return fakeVmServiceHost.vmService; return fakeVmServiceHost.vmService;
}, },
); );
...@@ -61,11 +59,11 @@ void main() { ...@@ -61,11 +59,11 @@ void main() {
), ),
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getVM', method: 'getVM',
jsonResponse: (VM.parse(<String, Object>{}) jsonResponse: (VM.parse(<String, Object>{})!
..isolates = <IsolateRef>[ ..isolates = <IsolateRef>[
IsolateRef.parse(<String, Object>{ IsolateRef.parse(<String, Object>{
'id': '1', 'id': '1',
}), })!,
] ]
).toJson(), ).toJson(),
), ),
...@@ -112,10 +110,10 @@ void main() { ...@@ -112,10 +110,10 @@ void main() {
], ],
); );
final Map<String, Object> result = await collect( final Map<String, Object?> result = await collect(
null, null,
<String>{'foo'}, <String>{'foo'},
connector: (Uri uri) async { connector: (Uri? uri) async {
return fakeVmServiceHost.vmService; return fakeVmServiceHost.vmService;
}, },
); );
...@@ -148,11 +146,11 @@ void main() { ...@@ -148,11 +146,11 @@ void main() {
), ),
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getVM', method: 'getVM',
jsonResponse: (VM.parse(<String, Object>{}) jsonResponse: (VM.parse(<String, Object>{})!
..isolates = <IsolateRef>[ ..isolates = <IsolateRef>[
IsolateRef.parse(<String, Object>{ IsolateRef.parse(<String, Object>{
'id': '1', 'id': '1',
}), })!,
] ]
).toJson(), ).toJson(),
), ),
...@@ -229,10 +227,10 @@ void main() { ...@@ -229,10 +227,10 @@ void main() {
], ],
); );
final Map<String, Object> result = await collect( final Map<String, Object?> result = await collect(
null, null,
null, null,
connector: (Uri uri) async { connector: (Uri? uri) async {
return fakeVmServiceHost.vmService; return fakeVmServiceHost.vmService;
}, },
); );
...@@ -276,11 +274,11 @@ void main() { ...@@ -276,11 +274,11 @@ void main() {
), ),
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getVM', method: 'getVM',
jsonResponse: (VM.parse(<String, Object>{}) jsonResponse: (VM.parse(<String, Object>{})!
..isolates = <IsolateRef>[ ..isolates = <IsolateRef>[
IsolateRef.parse(<String, Object>{ IsolateRef.parse(<String, Object>{
'id': '1', 'id': '1',
}), })!,
] ]
).toJson(), ).toJson(),
), ),
...@@ -317,10 +315,10 @@ void main() { ...@@ -317,10 +315,10 @@ void main() {
], ],
); );
final Map<String, Object> result = await collect( final Map<String, Object?> result = await collect(
null, null,
<String>{'foo'}, <String>{'foo'},
connector: (Uri uri) async { connector: (Uri? uri) async {
return fakeVmServiceHost.vmService; return fakeVmServiceHost.vmService;
}, },
); );
...@@ -353,11 +351,11 @@ void main() { ...@@ -353,11 +351,11 @@ void main() {
), ),
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'getVM', method: 'getVM',
jsonResponse: (VM.parse(<String, Object>{}) jsonResponse: (VM.parse(<String, Object>{})!
..isolates = <IsolateRef>[ ..isolates = <IsolateRef>[
IsolateRef.parse(<String, Object>{ IsolateRef.parse(<String, Object>{
'id': '1', 'id': '1',
}), })!,
] ]
).toJson(), ).toJson(),
), ),
...@@ -393,10 +391,10 @@ void main() { ...@@ -393,10 +391,10 @@ void main() {
], ],
); );
final Map<String, Object> result = await collect( final Map<String, Object?> result = await collect(
null, null,
null, null,
connector: (Uri uri) async { connector: (Uri? uri) async {
return fakeVmServiceHost.vmService; return fakeVmServiceHost.vmService;
}, },
); );
......
...@@ -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:flutter_tools/src/commands/create_base.dart'; import 'package:flutter_tools/src/commands/create_base.dart';
import '../src/common.dart'; import '../src/common.dart';
......
...@@ -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 'package:file/file.dart'; import 'package:file/file.dart';
...@@ -116,9 +114,7 @@ void main() { ...@@ -116,9 +114,7 @@ void main() {
final CustomDeviceConfig disabledTestConfig = testConfig.copyWith(enabled: false); final CustomDeviceConfig disabledTestConfig = testConfig.copyWith(enabled: false);
final CustomDeviceConfig testConfigNonForwarding = testConfig.copyWith( final CustomDeviceConfig testConfigNonForwarding = testConfig.copyWith(
explicitForwardPortCommand: true, explicitForwardPortCommand: true,
forwardPortCommand: null,
explicitForwardPortSuccessRegex: true, explicitForwardPortSuccessRegex: true,
forwardPortSuccessRegex: null,
); );
testUsingContext('CustomDevice defaults', testUsingContext('CustomDevice defaults',
...@@ -339,12 +335,12 @@ void main() { ...@@ -339,12 +335,12 @@ void main() {
final CustomDevicePortForwarder forwarder = CustomDevicePortForwarder( final CustomDevicePortForwarder forwarder = CustomDevicePortForwarder(
deviceName: 'testdevicename', deviceName: 'testdevicename',
forwardPortCommand: testConfig.forwardPortCommand, forwardPortCommand: testConfig.forwardPortCommand!,
forwardPortSuccessRegex: testConfig.forwardPortSuccessRegex, forwardPortSuccessRegex: testConfig.forwardPortSuccessRegex!,
logger: BufferLogger.test(), logger: BufferLogger.test(),
processManager: FakeProcessManager.list(<FakeCommand>[ processManager: FakeProcessManager.list(<FakeCommand>[
FakeCommand( FakeCommand(
command: testConfig.forwardPortCommand, command: testConfig.forwardPortCommand!,
stdout: testConfigForwardPortSuccessOutput, stdout: testConfigForwardPortSuccessOutput,
completer: forwardPortCommandCompleter, completer: forwardPortCommandCompleter,
), ),
...@@ -373,7 +369,7 @@ void main() { ...@@ -373,7 +369,7 @@ void main() {
stdout: 'The Dart VM service is listening on http://127.0.0.1:12345/abcd/\n', stdout: 'The Dart VM service is listening on http://127.0.0.1:12345/abcd/\n',
), ),
FakeCommand( FakeCommand(
command: testConfig.forwardPortCommand, command: testConfig.forwardPortCommand!,
completer: forwardPortCompleter, completer: forwardPortCompleter,
stdout: testConfigForwardPortSuccessOutput, stdout: testConfigForwardPortSuccessOutput,
), ),
...@@ -450,7 +446,7 @@ void main() { ...@@ -450,7 +446,7 @@ void main() {
command: testConfig.pingCommand, command: testConfig.pingCommand,
stdout: testConfigPingSuccessOutput stdout: testConfigPingSuccessOutput
), ),
FakeCommand(command: testConfig.postBuildCommand), FakeCommand(command: testConfig.postBuildCommand!),
FakeCommand(command: testConfig.uninstallCommand), FakeCommand(command: testConfig.uninstallCommand),
FakeCommand(command: testConfig.installCommand), FakeCommand(command: testConfig.installCommand),
FakeCommand( FakeCommand(
...@@ -459,7 +455,7 @@ void main() { ...@@ -459,7 +455,7 @@ void main() {
stdout: 'The Dart VM service is listening on http://127.0.0.1:12345/abcd/\n', stdout: 'The Dart VM service is listening on http://127.0.0.1:12345/abcd/\n',
), ),
FakeCommand( FakeCommand(
command: testConfig.forwardPortCommand, command: testConfig.forwardPortCommand!,
completer: forwardPortCompleter, completer: forwardPortCompleter,
stdout: testConfigForwardPortSuccessOutput, stdout: testConfigForwardPortSuccessOutput,
), ),
...@@ -524,7 +520,7 @@ void main() { ...@@ -524,7 +520,7 @@ void main() {
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[ final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand( FakeCommand(
command: testConfig.screenshotCommand, command: testConfig.screenshotCommand!,
onRun: () => screenshotCommandWasExecuted = true, onRun: () => screenshotCommandWasExecuted = true,
), ),
]); ]);
...@@ -550,7 +546,7 @@ void main() { ...@@ -550,7 +546,7 @@ void main() {
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[ final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand( FakeCommand(
command: testConfig.screenshotCommand, command: testConfig.screenshotCommand!,
onRun: () => screenshotCommandWasExecuted = true, onRun: () => screenshotCommandWasExecuted = true,
), ),
]); ]);
...@@ -560,8 +556,7 @@ void main() { ...@@ -560,8 +556,7 @@ void main() {
final CustomDevice device = CustomDevice( final CustomDevice device = CustomDevice(
config: testConfig.copyWith( config: testConfig.copyWith(
explicitScreenshotCommand: true, explicitScreenshotCommand: true
screenshotCommand: null
), ),
logger: BufferLogger.test(), logger: BufferLogger.test(),
processManager: processManager processManager: processManager
...@@ -640,14 +635,14 @@ class MyFakeStreamSubscription<T> extends Fake implements StreamSubscription<T> ...@@ -640,14 +635,14 @@ class MyFakeStreamSubscription<T> extends Fake implements StreamSubscription<T>
class FakeBundleBuilder extends Fake implements BundleBuilder { class FakeBundleBuilder extends Fake implements BundleBuilder {
@override @override
Future<void> build({ Future<void> build({
TargetPlatform platform, TargetPlatform? platform,
BuildInfo buildInfo, BuildInfo? buildInfo,
FlutterProject project, FlutterProject? project,
String mainPath, String? mainPath,
String manifestPath = defaultManifestPath, String manifestPath = defaultManifestPath,
String applicationKernelFilePath, String? applicationKernelFilePath,
String depfilePath, String? depfilePath,
String assetDirPath, String? assetDirPath,
@visibleForTesting BuildSystem buildSystem @visibleForTesting BuildSystem? buildSystem
}) async {} }) async {}
} }
...@@ -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/dart/package_map.dart'; import 'package:flutter_tools/src/dart/package_map.dart';
...@@ -22,9 +20,9 @@ import '../src/context.dart'; ...@@ -22,9 +20,9 @@ import '../src/context.dart';
void main() { void main() {
group('Dart plugin registrant', () { group('Dart plugin registrant', () {
FileSystem fs; late FileSystem fs;
FakeFlutterProject flutterProject; late FakeFlutterProject flutterProject;
FakeFlutterManifest flutterManifest; late FakeFlutterManifest flutterManifest;
setUp(() async { setUp(() async {
fs = MemoryFileSystem.test(); fs = MemoryFileSystem.test();
...@@ -1023,35 +1021,35 @@ class FakeFlutterProject extends Fake implements FlutterProject { ...@@ -1023,35 +1021,35 @@ class FakeFlutterProject extends Fake implements FlutterProject {
bool isModule = false; bool isModule = false;
@override @override
FlutterManifest manifest; late FlutterManifest manifest;
@override @override
Directory directory; late Directory directory;
@override @override
File flutterPluginsFile; late File flutterPluginsFile;
@override @override
File flutterPluginsDependenciesFile; late File flutterPluginsDependenciesFile;
@override @override
File dartPluginRegistrant; late File dartPluginRegistrant;
@override @override
IosProject ios; late IosProject ios;
@override @override
AndroidProject android; late AndroidProject android;
@override @override
WebProject web; late WebProject web;
@override @override
MacOSProject macos; late MacOSProject macos;
@override @override
LinuxProject linux; late LinuxProject linux;
@override @override
WindowsProject windows; late WindowsProject windows;
} }
...@@ -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:convert'; import 'dart:convert';
import 'dart:io' as io show ProcessSignal, Process; import 'dart:io' as io show ProcessSignal, Process;
...@@ -101,7 +99,6 @@ void main() { ...@@ -101,7 +99,6 @@ void main() {
final DateTime fiveSecondsAgo = file.statSync().modified.subtract(const Duration(seconds: 5)); final DateTime fiveSecondsAgo = file.statSync().modified.subtract(const Duration(seconds: 5));
expect(content.isModifiedAfter(fiveSecondsAgo), isTrue); expect(content.isModifiedAfter(fiveSecondsAgo), isTrue);
expect(content.isModifiedAfter(fiveSecondsAgo), isTrue); expect(content.isModifiedAfter(fiveSecondsAgo), isTrue);
expect(content.isModifiedAfter(null), isTrue);
file.writeAsBytesSync(<int>[2, 3, 4], flush: true); file.writeAsBytesSync(<int>[2, 3, 4], flush: true);
...@@ -186,7 +183,7 @@ void main() { ...@@ -186,7 +183,7 @@ void main() {
requests: <VmServiceExpectation>[createDevFSRequest], requests: <VmServiceExpectation>[createDevFSRequest],
httpAddress: Uri.parse('http://localhost'), httpAddress: Uri.parse('http://localhost'),
); );
residentCompiler.onRecompile = (Uri mainUri, List<Uri> invalidatedFiles) async { residentCompiler.onRecompile = (Uri mainUri, List<Uri>? invalidatedFiles) async {
fileSystem.file('lib/foo.dill') fileSystem.file('lib/foo.dill')
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsBytesSync(<int>[1, 2, 3, 4, 5]); ..writeAsBytesSync(<int>[1, 2, 3, 4, 5]);
...@@ -250,10 +247,10 @@ void main() { ...@@ -250,10 +247,10 @@ void main() {
); );
await devFS.create(); await devFS.create();
final DateTime previousCompile = devFS.lastCompiled; final DateTime? previousCompile = devFS.lastCompiled;
final FakeResidentCompiler residentCompiler = FakeResidentCompiler(); final FakeResidentCompiler residentCompiler = FakeResidentCompiler();
residentCompiler.onRecompile = (Uri mainUri, List<Uri> invalidatedFiles) async { residentCompiler.onRecompile = (Uri mainUri, List<Uri>? invalidatedFiles) async {
return const CompilerOutput('lib/foo.dill', 2, <Uri>[]); return const CompilerOutput('lib/foo.dill', 2, <Uri>[]);
}; };
...@@ -289,10 +286,10 @@ void main() { ...@@ -289,10 +286,10 @@ void main() {
); );
await devFS.create(); await devFS.create();
final DateTime previousCompile = devFS.lastCompiled; final DateTime? previousCompile = devFS.lastCompiled;
final FakeResidentCompiler residentCompiler = FakeResidentCompiler(); final FakeResidentCompiler residentCompiler = FakeResidentCompiler();
residentCompiler.onRecompile = (Uri mainUri, List<Uri> invalidatedFiles) async { residentCompiler.onRecompile = (Uri mainUri, List<Uri>? invalidatedFiles) async {
fileSystem.file('lib/foo.txt.dill').createSync(recursive: true); fileSystem.file('lib/foo.txt.dill').createSync(recursive: true);
return const CompilerOutput('lib/foo.txt.dill', 0, <Uri>[]); return const CompilerOutput('lib/foo.txt.dill', 0, <Uri>[]);
}; };
...@@ -330,10 +327,10 @@ void main() { ...@@ -330,10 +327,10 @@ void main() {
); );
await devFS.create(); await devFS.create();
final DateTime previousCompile = devFS.lastCompiled; final DateTime? previousCompile = devFS.lastCompiled;
final FakeResidentCompiler residentCompiler = FakeResidentCompiler(); final FakeResidentCompiler residentCompiler = FakeResidentCompiler();
residentCompiler.onRecompile = (Uri mainUri, List<Uri> invalidatedFiles) async { residentCompiler.onRecompile = (Uri mainUri, List<Uri>? invalidatedFiles) async {
fileSystem.file('lib/foo.txt.dill').createSync(recursive: true); fileSystem.file('lib/foo.txt.dill').createSync(recursive: true);
return const CompilerOutput('lib/foo.txt.dill', 0, <Uri>[]); return const CompilerOutput('lib/foo.txt.dill', 0, <Uri>[]);
}; };
...@@ -380,7 +377,7 @@ void main() { ...@@ -380,7 +377,7 @@ void main() {
await devFS.create(); await devFS.create();
final FakeResidentCompiler residentCompiler = FakeResidentCompiler(); final FakeResidentCompiler residentCompiler = FakeResidentCompiler();
residentCompiler.onRecompile = (Uri mainUri, List<Uri> invalidatedFiles) async { residentCompiler.onRecompile = (Uri mainUri, List<Uri>? invalidatedFiles) async {
fileSystem.file('example').createSync(); fileSystem.file('example').createSync();
return const CompilerOutput('lib/foo.txt.dill', 0, <Uri>[]); return const CompilerOutput('lib/foo.txt.dill', 0, <Uri>[]);
}; };
...@@ -456,7 +453,7 @@ void main() { ...@@ -456,7 +453,7 @@ void main() {
await devFS.create(); await devFS.create();
final FakeResidentCompiler residentCompiler = FakeResidentCompiler(); final FakeResidentCompiler residentCompiler = FakeResidentCompiler();
residentCompiler.onRecompile = (Uri mainUri, List<Uri> invalidatedFiles) async { residentCompiler.onRecompile = (Uri mainUri, List<Uri>? invalidatedFiles) async {
fileSystem.file('lib/foo.txt.dill').createSync(recursive: true); fileSystem.file('lib/foo.txt.dill').createSync(recursive: true);
return const CompilerOutput('lib/foo.txt.dill', 0, <Uri>[]); return const CompilerOutput('lib/foo.txt.dill', 0, <Uri>[]);
}; };
...@@ -506,7 +503,7 @@ void main() { ...@@ -506,7 +503,7 @@ void main() {
await Future<dynamic>.delayed(const Duration(milliseconds: 5)); await Future<dynamic>.delayed(const Duration(milliseconds: 5));
} }
String boundaryKey; String? boundaryKey;
while(processed < frontendServerStdIn.writes.length) { while(processed < frontendServerStdIn.writes.length) {
final List<int> data = frontendServerStdIn.writes[processed]; final List<int> data = frontendServerStdIn.writes[processed];
final String stringData = utf8.decode(data); final String stringData = utf8.decode(data);
...@@ -581,10 +578,10 @@ void main() { ...@@ -581,10 +578,10 @@ void main() {
} }
class FakeResidentCompiler extends Fake implements ResidentCompiler { class FakeResidentCompiler extends Fake implements ResidentCompiler {
Future<CompilerOutput> Function(Uri mainUri, List<Uri> invalidatedFiles) onRecompile; Future<CompilerOutput> Function(Uri mainUri, List<Uri>? invalidatedFiles)? onRecompile;
@override @override
Future<CompilerOutput> recompile(Uri mainUri, List<Uri> invalidatedFiles, {String outputPath, PackageConfig packageConfig, String projectRootPath, FileSystem fs, bool suppressErrors = false, bool checkDartPluginRegistry = false}) { Future<CompilerOutput> recompile(Uri mainUri, List<Uri>? invalidatedFiles, {String? outputPath, PackageConfig? packageConfig, String? projectRootPath, FileSystem? fs, bool suppressErrors = false, bool checkDartPluginRegistry = false}) {
return onRecompile?.call(mainUri, invalidatedFiles) return onRecompile?.call(mainUri, invalidatedFiles)
?? Future<CompilerOutput>.value(const CompilerOutput('', 1, <Uri>[])); ?? Future<CompilerOutput>.value(const CompilerOutput('', 1, <Uri>[]));
} }
...@@ -605,12 +602,12 @@ class LoggingLogger extends BufferLogger { ...@@ -605,12 +602,12 @@ class LoggingLogger extends BufferLogger {
List<String> messages = <String>[]; List<String> messages = <String>[];
@override @override
void printError(String message, {StackTrace stackTrace, bool emphasis, TerminalColor color, int indent, int hangingIndent, bool wrap}) { void printError(String message, {StackTrace? stackTrace, bool? emphasis, TerminalColor? color, int? indent, int? hangingIndent, bool? wrap}) {
messages.add(message); messages.add(message);
} }
@override @override
void printStatus(String message, {bool emphasis, TerminalColor color, bool newline, int indent, int hangingIndent, bool wrap}) { void printStatus(String message, {bool? emphasis, TerminalColor? color, bool? newline, int? indent, int? hangingIndent, bool? wrap}) {
messages.add(message); messages.add(message);
} }
...@@ -625,7 +622,7 @@ class FakeBundle extends AssetBundle { ...@@ -625,7 +622,7 @@ class FakeBundle extends AssetBundle {
List<File> get additionalDependencies => <File>[]; List<File> get additionalDependencies => <File>[];
@override @override
Future<int> build({String manifestPath = defaultManifestPath, String assetDirPath, String packagesPath, bool deferredComponentsEnabled = false, TargetPlatform targetPlatform}) async { Future<int> build({String manifestPath = defaultManifestPath, String? assetDirPath, String? packagesPath, bool deferredComponentsEnabled = false, TargetPlatform? targetPlatform}) async {
return 0; return 0;
} }
...@@ -657,7 +654,7 @@ class AnsweringFakeProcessManager implements ProcessManager { ...@@ -657,7 +654,7 @@ class AnsweringFakeProcessManager implements ProcessManager {
final IOSink stdin; final IOSink stdin;
@override @override
bool canRun(dynamic executable, {String workingDirectory}) { bool canRun(dynamic executable, {String? workingDirectory}) {
return true; return true;
} }
...@@ -667,17 +664,17 @@ class AnsweringFakeProcessManager implements ProcessManager { ...@@ -667,17 +664,17 @@ class AnsweringFakeProcessManager implements ProcessManager {
} }
@override @override
Future<ProcessResult> run(List<Object> command, {String workingDirectory, Map<String, String> environment, bool includeParentEnvironment = true, bool runInShell = false, Encoding stdoutEncoding = systemEncoding, Encoding stderrEncoding = systemEncoding}) async { Future<ProcessResult> run(List<Object> command, {String? workingDirectory, Map<String, String>? environment, bool includeParentEnvironment = true, bool runInShell = false, Encoding? stdoutEncoding = systemEncoding, Encoding? stderrEncoding = systemEncoding}) async {
throw UnimplementedError(); throw UnimplementedError();
} }
@override @override
ProcessResult runSync(List<Object> command, {String workingDirectory, Map<String, String> environment, bool includeParentEnvironment = true, bool runInShell = false, Encoding stdoutEncoding = systemEncoding, Encoding stderrEncoding = systemEncoding}) { ProcessResult runSync(List<Object> command, {String? workingDirectory, Map<String, String>? environment, bool includeParentEnvironment = true, bool runInShell = false, Encoding? stdoutEncoding = systemEncoding, Encoding? stderrEncoding = systemEncoding}) {
throw UnimplementedError(); throw UnimplementedError();
} }
@override @override
Future<Process> start(List<Object> command, {String workingDirectory, Map<String, String> environment, bool includeParentEnvironment = true, bool runInShell = false, ProcessStartMode mode = ProcessStartMode.normal}) async { Future<Process> start(List<Object> command, {String? workingDirectory, Map<String, String>? environment, bool includeParentEnvironment = true, bool runInShell = false, ProcessStartMode mode = ProcessStartMode.normal}) async {
return AnsweringFakeProcess(stdout, stderr, stdin); return AnsweringFakeProcess(stdout, stderr, stdin);
} }
} }
......
...@@ -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 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/io.dart';
...@@ -17,7 +15,7 @@ import '../src/fake_process_manager.dart'; ...@@ -17,7 +15,7 @@ import '../src/fake_process_manager.dart';
import '../src/fakes.dart'; import '../src/fakes.dart';
void main() { void main() {
BufferLogger logger; late BufferLogger logger;
Cache.flutterRoot = ''; Cache.flutterRoot = '';
...@@ -44,9 +42,9 @@ void main() { ...@@ -44,9 +42,9 @@ void main() {
]), ]),
); );
final DevToolsServerAddress address = await launcher.serve(); final DevToolsServerAddress? address = await launcher.serve();
expect(address.host, '127.0.0.1'); expect(address?.host, '127.0.0.1');
expect(address.port, 9100); expect(address?.port, 9100);
}); });
testWithoutContext('DevtoolsLauncher does not launch a new DevTools instance if one is already active', () async { testWithoutContext('DevtoolsLauncher does not launch a new DevTools instance if one is already active', () async {
...@@ -68,14 +66,14 @@ void main() { ...@@ -68,14 +66,14 @@ void main() {
]), ]),
); );
DevToolsServerAddress address = await launcher.serve(); DevToolsServerAddress? address = await launcher.serve();
expect(address.host, '127.0.0.1'); expect(address?.host, '127.0.0.1');
expect(address.port, 9100); expect(address?.port, 9100);
// Call `serve` again and verify that the already running server is returned. // Call `serve` again and verify that the already running server is returned.
address = await launcher.serve(); address = await launcher.serve();
expect(address.host, '127.0.0.1'); expect(address?.host, '127.0.0.1');
expect(address.port, 9100); expect(address?.port, 9100);
}); });
testWithoutContext('DevtoolsLauncher can launch devtools with a memory profile', () async { testWithoutContext('DevtoolsLauncher can launch devtools with a memory profile', () async {
......
...@@ -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/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/io.dart';
...@@ -17,12 +15,11 @@ import '../src/common.dart'; ...@@ -17,12 +15,11 @@ import '../src/common.dart';
import '../src/context.dart'; import '../src/context.dart';
void main() { void main() {
FileSystem fileSystem; late FileSystem fileSystem;
setUp(() { setUp(() {
fileSystem = MemoryFileSystem.test(); fileSystem = MemoryFileSystem.test();
fileSystem fileSystem.file('.dart_tool/package_config.json')
.file('.dart_tool/package_config.json')
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsStringSync('{"configVersion":2,"packages":[]}'); ..writeAsStringSync('{"configVersion":2,"packages":[]}');
}); });
...@@ -80,7 +77,7 @@ void main() { ...@@ -80,7 +77,7 @@ void main() {
), ),
), throwsAssertionError); ), throwsAssertionError);
FlutterPlatform capturedPlatform; FlutterPlatform? capturedPlatform;
final Map<String, String> expectedPrecompiledDillFiles = <String, String>{'Key': 'Value'}; final Map<String, String> expectedPrecompiledDillFiles = <String, String>{'Key': 'Value'};
final FlutterPlatform flutterPlatform = installHook( final FlutterPlatform flutterPlatform = installHook(
shellPath: 'abc', shellPath: 'abc',
......
...@@ -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 'package:dds/dds.dart'; import 'package:dds/dds.dart';
...@@ -16,7 +14,6 @@ import 'package:flutter_tools/src/build_info.dart'; ...@@ -16,7 +14,6 @@ import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/test/flutter_tester_device.dart'; import 'package:flutter_tools/src/test/flutter_tester_device.dart';
import 'package:flutter_tools/src/test/font_config_manager.dart'; import 'package:flutter_tools/src/test/font_config_manager.dart';
import 'package:meta/meta.dart';
import 'package:stream_channel/stream_channel.dart'; import 'package:stream_channel/stream_channel.dart';
import 'package:test/fake.dart'; import 'package:test/fake.dart';
...@@ -25,10 +22,10 @@ import '../src/context.dart'; ...@@ -25,10 +22,10 @@ import '../src/context.dart';
import '../src/fake_process_manager.dart'; import '../src/fake_process_manager.dart';
void main() { void main() {
FakePlatform platform; late FakePlatform platform;
FileSystem fileSystem; late FileSystem fileSystem;
FakeProcessManager processManager; late FakeProcessManager processManager;
FlutterTesterTestDevice device; late FlutterTesterTestDevice device;
setUp(() { setUp(() {
fileSystem = MemoryFileSystem.test(); fileSystem = MemoryFileSystem.test();
...@@ -265,17 +262,14 @@ void main() { ...@@ -265,17 +262,14 @@ void main() {
/// Uses a mock HttpServer. We don't want to bind random ports in our CI hosts. /// Uses a mock HttpServer. We don't want to bind random ports in our CI hosts.
class TestFlutterTesterDevice extends FlutterTesterTestDevice { class TestFlutterTesterDevice extends FlutterTesterTestDevice {
TestFlutterTesterDevice({ TestFlutterTesterDevice({
@required Platform platform, required super.platform,
@required FileSystem fileSystem, required super.fileSystem,
@required ProcessManager processManager, required super.processManager,
@required bool enableObservatory, required super.enableObservatory,
@required List<String> dartEntrypointArgs, required List<String> dartEntrypointArgs,
}) : super( }) : super(
id: 999, id: 999,
shellPath: '/', shellPath: '/',
platform: platform,
fileSystem: fileSystem,
processManager: processManager,
logger: BufferLogger.test(), logger: BufferLogger.test(),
debuggingOptions: DebuggingOptions.enabled( debuggingOptions: DebuggingOptions.enabled(
const BuildInfo( const BuildInfo(
...@@ -286,7 +280,6 @@ class TestFlutterTesterDevice extends FlutterTesterTestDevice { ...@@ -286,7 +280,6 @@ class TestFlutterTesterDevice extends FlutterTesterTestDevice {
hostVmServicePort: 1234, hostVmServicePort: 1234,
dartEntrypointArgs: dartEntrypointArgs, dartEntrypointArgs: dartEntrypointArgs,
), ),
enableObservatory: enableObservatory,
machine: false, machine: false,
host: InternetAddress.loopbackIPv6, host: InternetAddress.loopbackIPv6,
testAssetDirectory: null, testAssetDirectory: null,
...@@ -307,7 +300,7 @@ class TestFlutterTesterDevice extends FlutterTesterTestDevice { ...@@ -307,7 +300,7 @@ class TestFlutterTesterDevice extends FlutterTesterTestDevice {
} }
@override @override
Future<HttpServer> bind(InternetAddress host, int port) async => FakeHttpServer(); Future<HttpServer> bind(InternetAddress? host, int port) async => FakeHttpServer();
@override @override
Future<StreamChannel<String>> get remoteChannel async => StreamChannelController<String>().foreign; Future<StreamChannel<String>> get remoteChannel async => StreamChannelController<String>().foreign;
......
...@@ -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/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/fuchsia/fuchsia_pm.dart'; import 'package:flutter_tools/src/fuchsia/fuchsia_pm.dart';
...@@ -16,13 +14,12 @@ import '../../src/fake_process_manager.dart'; ...@@ -16,13 +14,12 @@ import '../../src/fake_process_manager.dart';
void main() { void main() {
group('FuchsiaPM', () { group('FuchsiaPM', () {
File pm; late File pm;
FakeProcessManager fakeProcessManager; late FakeProcessManager fakeProcessManager;
FakeFuchsiaArtifacts fakeFuchsiaArtifacts; late FakeFuchsiaArtifacts fakeFuchsiaArtifacts;
setUp(() { setUp(() {
pm = MemoryFileSystem.test().file('pm'); pm = MemoryFileSystem.test().file('pm');
fakeFuchsiaArtifacts = FakeFuchsiaArtifacts(pm); fakeFuchsiaArtifacts = FakeFuchsiaArtifacts(pm);
fakeProcessManager = FakeProcessManager.empty(); fakeProcessManager = FakeProcessManager.empty();
}); });
......
...@@ -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';
...@@ -16,8 +14,9 @@ import '../src/common.dart'; ...@@ -16,8 +14,9 @@ import '../src/common.dart';
import '../src/context.dart'; import '../src/context.dart';
void main() { void main() {
BufferLogger logger; late BufferLogger logger;
FileSystem fs; late FileSystem fs;
setUp(() { setUp(() {
logger = BufferLogger.test(); logger = BufferLogger.test();
fs = MemoryFileSystem.test(); fs = MemoryFileSystem.test();
...@@ -144,8 +143,8 @@ void main() { ...@@ -144,8 +143,8 @@ void main() {
}); });
group('new issue template URL', () { group('new issue template URL', () {
StackTrace stackTrace; late StackTrace stackTrace;
Error error; late Error error;
const String command = 'flutter test'; const String command = 'flutter test';
const String doctorText = ' [✓] Flutter (Channel report'; const String doctorText = ' [✓] Flutter (Channel report';
...@@ -220,7 +219,7 @@ project_type: app ...@@ -220,7 +219,7 @@ project_type: app
'''); ''');
final String actualURL = await creator.toolCrashIssueTemplateGitHubURL(command, error, stackTrace, doctorText); final String actualURL = await creator.toolCrashIssueTemplateGitHubURL(command, error, stackTrace, doctorText);
final String actualBody = Uri.parse(actualURL).queryParameters['body']; final String? actualBody = Uri.parse(actualURL).queryParameters['body'];
const String expectedBody = ''' const String expectedBody = '''
## Command ## Command
``` ```
......
...@@ -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:flutter_tools/src/application_package.dart'; import 'package:flutter_tools/src/application_package.dart';
import 'package:flutter_tools/src/base/io.dart' as io; import 'package:flutter_tools/src/base/io.dart' as io;
...@@ -64,8 +62,8 @@ final FakeVmServiceRequest listViewsRequest = FakeVmServiceRequest( ...@@ -64,8 +62,8 @@ final FakeVmServiceRequest listViewsRequest = FakeVmServiceRequest(
final Uri observatoryUri = Uri.parse('http://localhost:1234'); final Uri observatoryUri = Uri.parse('http://localhost:1234');
void main() { void main() {
FakeVmServiceHost fakeVmServiceHost; late FakeVmServiceHost fakeVmServiceHost;
TestDevice testDevice; late TestDevice testDevice;
setUp(() { setUp(() {
testDevice = IntegrationTestTestDevice( testDevice = IntegrationTestTestDevice(
...@@ -133,14 +131,14 @@ void main() { ...@@ -133,14 +131,14 @@ void main() {
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
ApplicationPackageFactory: () => FakeApplicationPackageFactory(), ApplicationPackageFactory: () => FakeApplicationPackageFactory(),
VMServiceConnector: () => (Uri httpUri, { VMServiceConnector: () => (Uri httpUri, {
ReloadSources reloadSources, ReloadSources? reloadSources,
Restart restart, Restart? restart,
CompileExpression compileExpression, CompileExpression? compileExpression,
GetSkSLMethod getSkSLMethod, GetSkSLMethod? getSkSLMethod,
PrintStructuredErrorLogMethod printStructuredErrorLogMethod, PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
io.CompressionOptions compression, io.CompressionOptions? compression,
Device device, Device? device,
Logger logger, Logger? logger,
}) async => fakeVmServiceHost.vmService, }) async => fakeVmServiceHost.vmService,
}); });
...@@ -152,14 +150,14 @@ void main() { ...@@ -152,14 +150,14 @@ void main() {
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
ApplicationPackageFactory: () => FakeApplicationPackageFactory(), ApplicationPackageFactory: () => FakeApplicationPackageFactory(),
VMServiceConnector: () => (Uri httpUri, { VMServiceConnector: () => (Uri httpUri, {
ReloadSources reloadSources, ReloadSources? reloadSources,
Restart restart, Restart? restart,
CompileExpression compileExpression, CompileExpression? compileExpression,
GetSkSLMethod getSkSLMethod, GetSkSLMethod? getSkSLMethod,
PrintStructuredErrorLogMethod printStructuredErrorLogMethod, PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
io.CompressionOptions compression, io.CompressionOptions? compression,
Device device, Device? device,
Logger logger, Logger? logger,
}) async => fakeVmServiceHost.vmService, }) async => fakeVmServiceHost.vmService,
}); });
...@@ -181,13 +179,13 @@ void main() { ...@@ -181,13 +179,13 @@ void main() {
expect(() => testDevice.start('entrypointPath'), throwsA(isA<TestDeviceException>())); expect(() => testDevice.start('entrypointPath'), throwsA(isA<TestDeviceException>()));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
VMServiceConnector: () => (Uri httpUri, { VMServiceConnector: () => (Uri httpUri, {
ReloadSources reloadSources, ReloadSources? reloadSources,
Restart restart, Restart? restart,
CompileExpression compileExpression, CompileExpression? compileExpression,
GetSkSLMethod getSkSLMethod, GetSkSLMethod? getSkSLMethod,
PrintStructuredErrorLogMethod printStructuredErrorLogMethod, PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
io.CompressionOptions compression, io.CompressionOptions? compression,
Device device, Device? device,
}) async => fakeVmServiceHost.vmService, }) async => fakeVmServiceHost.vmService,
}); });
...@@ -209,13 +207,13 @@ void main() { ...@@ -209,13 +207,13 @@ void main() {
expect(() => testDevice.start('entrypointPath'), throwsA(isA<TestDeviceException>())); expect(() => testDevice.start('entrypointPath'), throwsA(isA<TestDeviceException>()));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
VMServiceConnector: () => (Uri httpUri, { VMServiceConnector: () => (Uri httpUri, {
ReloadSources reloadSources, ReloadSources? reloadSources,
Restart restart, Restart? restart,
CompileExpression compileExpression, CompileExpression? compileExpression,
GetSkSLMethod getSkSLMethod, GetSkSLMethod? getSkSLMethod,
PrintStructuredErrorLogMethod printStructuredErrorLogMethod, PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
io.CompressionOptions compression, io.CompressionOptions? compression,
Device device, Device? device,
}) async => fakeVmServiceHost.vmService, }) async => fakeVmServiceHost.vmService,
}); });
...@@ -226,14 +224,14 @@ void main() { ...@@ -226,14 +224,14 @@ void main() {
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
ApplicationPackageFactory: () => FakeApplicationPackageFactory(), ApplicationPackageFactory: () => FakeApplicationPackageFactory(),
VMServiceConnector: () => (Uri httpUri, { VMServiceConnector: () => (Uri httpUri, {
ReloadSources reloadSources, ReloadSources? reloadSources,
Restart restart, Restart? restart,
CompileExpression compileExpression, CompileExpression? compileExpression,
GetSkSLMethod getSkSLMethod, GetSkSLMethod? getSkSLMethod,
PrintStructuredErrorLogMethod printStructuredErrorLogMethod, PrintStructuredErrorLogMethod? printStructuredErrorLogMethod,
io.CompressionOptions compression, io.CompressionOptions? compression,
Device device, Device? device,
Logger logger, Logger? logger,
}) async => fakeVmServiceHost.vmService, }) async => fakeVmServiceHost.vmService,
}); });
} }
...@@ -242,8 +240,8 @@ class FakeApplicationPackageFactory extends Fake implements ApplicationPackageFa ...@@ -242,8 +240,8 @@ class FakeApplicationPackageFactory extends Fake implements ApplicationPackageFa
@override @override
Future<ApplicationPackage> getPackageForPlatform( Future<ApplicationPackage> getPackageForPlatform(
TargetPlatform platform, { TargetPlatform platform, {
BuildInfo buildInfo, BuildInfo? buildInfo,
File applicationBinary, File? applicationBinary,
}) async => FakeApplicationPackage(); }) async => FakeApplicationPackage();
} }
......
...@@ -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';
...@@ -22,7 +20,7 @@ import '../../src/context.dart'; ...@@ -22,7 +20,7 @@ import '../../src/context.dart';
// FlutterProject still depends on context. // FlutterProject still depends on context.
void main() { void main() {
FileSystem fileSystem; late FileSystem fileSystem;
// This setup is required to inject the context. // This setup is required to inject the context.
setUp(() { setUp(() {
......
...@@ -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/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/io.dart';
...@@ -34,9 +32,9 @@ final Platform macosPlatform = FakePlatform( ...@@ -34,9 +32,9 @@ final Platform macosPlatform = FakePlatform(
); );
void main() { void main() {
FakePlatform osx; late FakePlatform osx;
FileSystemUtils fsUtils; late FileSystemUtils fsUtils;
MemoryFileSystem fileSystem; late MemoryFileSystem fileSystem;
setUp(() { setUp(() {
osx = FakePlatform( osx = FakePlatform(
...@@ -48,8 +46,8 @@ void main() { ...@@ -48,8 +46,8 @@ void main() {
}); });
group('_IOSSimulatorDevicePortForwarder', () { group('_IOSSimulatorDevicePortForwarder', () {
FakeSimControl simControl; late FakeSimControl simControl;
Xcode xcode; late Xcode xcode;
setUp(() { setUp(() {
simControl = FakeSimControl(); simControl = FakeSimControl();
...@@ -100,7 +98,7 @@ void main() { ...@@ -100,7 +98,7 @@ void main() {
}); });
group('logFilePath', () { group('logFilePath', () {
FakeSimControl simControl; late FakeSimControl simControl;
setUp(() { setUp(() {
simControl = FakeSimControl(); simControl = FakeSimControl();
...@@ -163,7 +161,7 @@ void main() { ...@@ -163,7 +161,7 @@ void main() {
}); });
group('sdkMajorVersion', () { group('sdkMajorVersion', () {
FakeSimControl simControl; late FakeSimControl simControl;
setUp(() { setUp(() {
simControl = FakeSimControl(); simControl = FakeSimControl();
...@@ -205,7 +203,7 @@ void main() { ...@@ -205,7 +203,7 @@ void main() {
}); });
group('IOSSimulator.isSupported', () { group('IOSSimulator.isSupported', () {
FakeSimControl simControl; late FakeSimControl simControl;
setUp(() { setUp(() {
simControl = FakeSimControl(); simControl = FakeSimControl();
...@@ -368,8 +366,8 @@ void main() { ...@@ -368,8 +366,8 @@ void main() {
}); });
group('device log tool', () { group('device log tool', () {
FakeProcessManager fakeProcessManager; late FakeProcessManager fakeProcessManager;
FakeSimControl simControl; late FakeSimControl simControl;
setUp(() { setUp(() {
fakeProcessManager = FakeProcessManager.empty(); fakeProcessManager = FakeProcessManager.empty();
...@@ -472,10 +470,10 @@ void main() { ...@@ -472,10 +470,10 @@ void main() {
}); });
group('log reader', () { group('log reader', () {
FakeProcessManager fakeProcessManager; late FakeProcessManager fakeProcessManager;
FakeIosProject mockIosProject; late FakeIosProject mockIosProject;
FakeSimControl simControl; late FakeSimControl simControl;
Xcode xcode; late Xcode xcode;
setUp(() { setUp(() {
fakeProcessManager = FakeProcessManager.empty(); fakeProcessManager = FakeProcessManager.empty();
...@@ -616,7 +614,7 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text''' ...@@ -616,7 +614,7 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
}); });
group('unified logging', () { group('unified logging', () {
BufferLogger logger; late BufferLogger logger;
setUp(() { setUp(() {
logger = BufferLogger.test(); logger = BufferLogger.test();
...@@ -754,9 +752,9 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text''' ...@@ -754,9 +752,9 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
} }
'''; ''';
FakeProcessManager fakeProcessManager; late FakeProcessManager fakeProcessManager;
Xcode xcode; Xcode xcode;
SimControl simControl; late SimControl simControl;
const String deviceId = 'smart-phone'; const String deviceId = 'smart-phone';
const String appId = 'flutterApp'; const String appId = 'flutterApp';
...@@ -895,10 +893,10 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text''' ...@@ -895,10 +893,10 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
}); });
group('startApp', () { group('startApp', () {
FakePlistParser testPlistParser; late FakePlistParser testPlistParser;
FakeSimControl simControl; late FakeSimControl simControl;
Xcode xcode; late Xcode xcode;
BufferLogger logger; late BufferLogger logger;
setUp(() { setUp(() {
simControl = FakeSimControl(); simControl = FakeSimControl();
...@@ -1027,8 +1025,8 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text''' ...@@ -1027,8 +1025,8 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
}); });
group('IOSDevice.isSupportedForProject', () { group('IOSDevice.isSupportedForProject', () {
FakeSimControl simControl; late FakeSimControl simControl;
Xcode xcode; late Xcode xcode;
setUp(() { setUp(() {
simControl = FakeSimControl(); simControl = FakeSimControl();
...@@ -1113,17 +1111,17 @@ flutter: ...@@ -1113,17 +1111,17 @@ flutter:
class FakeIosProject extends Fake implements IosProject { class FakeIosProject extends Fake implements IosProject {
@override @override
Future<String> productBundleIdentifier(BuildInfo buildInfo) async => 'com.example.test'; Future<String> productBundleIdentifier(BuildInfo? buildInfo) async => 'com.example.test';
@override @override
Future<String> hostAppBundleName(BuildInfo buildInfo) async => 'My Super Awesome App.app'; Future<String> hostAppBundleName(BuildInfo? buildInfo) async => 'My Super Awesome App.app';
} }
class FakeSimControl extends Fake implements SimControl { class FakeSimControl extends Fake implements SimControl {
final List<LaunchRequest> requests = <LaunchRequest>[]; final List<LaunchRequest> requests = <LaunchRequest>[];
@override @override
Future<RunResult> launch(String deviceId, String appIdentifier, [ List<String> launchArgs ]) async { Future<RunResult> launch(String deviceId, String appIdentifier, [ List<String>? launchArgs ]) async {
requests.add(LaunchRequest(deviceId, appIdentifier, launchArgs)); requests.add(LaunchRequest(deviceId, appIdentifier, launchArgs));
return RunResult(ProcessResult(0, 0, '', ''), <String>['test']); return RunResult(ProcessResult(0, 0, '', ''), <String>['test']);
} }
...@@ -1139,5 +1137,5 @@ class LaunchRequest { ...@@ -1139,5 +1137,5 @@ class LaunchRequest {
final String deviceId; final String deviceId;
final String appIdentifier; final String appIdentifier;
final List<String> launchArgs; final List<String>? launchArgs;
} }
...@@ -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';
...@@ -56,11 +54,11 @@ void main() { ...@@ -56,11 +54,11 @@ void main() {
stdout: 'hw.optional.arm64: 1', stdout: 'hw.optional.arm64: 1',
); );
FakeProcessManager fakeProcessManager; late FakeProcessManager fakeProcessManager;
XcodeProjectInterpreter xcodeProjectInterpreter; late XcodeProjectInterpreter xcodeProjectInterpreter;
FakePlatform platform; late FakePlatform platform;
FileSystem fileSystem; late FileSystem fileSystem;
BufferLogger logger; late BufferLogger logger;
setUp(() { setUp(() {
fakeProcessManager = FakeProcessManager.empty(); fakeProcessManager = FakeProcessManager.empty();
...@@ -660,7 +658,7 @@ Information about project "Runner": ...@@ -660,7 +658,7 @@ Information about project "Runner":
expect(info.buildConfigurationFor(const BuildInfo(BuildMode.release, 'Paid', treeShakeIcons: false), 'Paid'), null); expect(info.buildConfigurationFor(const BuildInfo(BuildMode.release, 'Paid', treeShakeIcons: false), 'Paid'), null);
}); });
group('environmentVariablesAsXcodeBuildSettings', () { group('environmentVariablesAsXcodeBuildSettings', () {
FakePlatform platform; late FakePlatform platform;
setUp(() { setUp(() {
platform = FakePlatform(); platform = FakePlatform();
...@@ -679,9 +677,9 @@ Information about project "Runner": ...@@ -679,9 +677,9 @@ Information about project "Runner":
}); });
group('updateGeneratedXcodeProperties', () { group('updateGeneratedXcodeProperties', () {
Artifacts localIosArtifacts; late Artifacts localIosArtifacts;
FakePlatform macOS; late FakePlatform macOS;
FileSystem fs; late FileSystem fs;
setUp(() { setUp(() {
fs = MemoryFileSystem.test(); fs = MemoryFileSystem.test();
...@@ -691,8 +689,8 @@ Information about project "Runner": ...@@ -691,8 +689,8 @@ Information about project "Runner":
}); });
group('arm simulator', () { group('arm simulator', () {
FakeProcessManager fakeProcessManager; late FakeProcessManager fakeProcessManager;
XcodeProjectInterpreter xcodeProjectInterpreter; late XcodeProjectInterpreter xcodeProjectInterpreter;
setUp(() { setUp(() {
fakeProcessManager = FakeProcessManager.empty(); fakeProcessManager = FakeProcessManager.empty();
...@@ -1047,7 +1045,7 @@ Build settings for action build and target plugin2: ...@@ -1047,7 +1045,7 @@ Build settings for action build and target plugin2:
}); });
}); });
String propertyFor(String key, File file) { String? propertyFor(String key, File file) {
final List<String> properties = file final List<String> properties = file
.readAsLinesSync() .readAsLinesSync()
.where((String line) => line.startsWith('$key=')) .where((String line) => line.startsWith('$key='))
...@@ -1057,10 +1055,10 @@ Build settings for action build and target plugin2: ...@@ -1057,10 +1055,10 @@ Build settings for action build and target plugin2:
} }
Future<void> checkBuildVersion({ Future<void> checkBuildVersion({
String manifestString, required String manifestString,
BuildInfo buildInfo, required BuildInfo buildInfo,
String expectedBuildName, String? expectedBuildName,
String expectedBuildNumber, String? expectedBuildNumber,
}) async { }) async {
final File manifestFile = fs.file('path/to/project/pubspec.yaml'); final File manifestFile = fs.file('path/to/project/pubspec.yaml');
manifestFile.createSync(recursive: true); manifestFile.createSync(recursive: true);
......
...@@ -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:convert'; import 'dart:convert';
import 'package:file/file.dart'; import 'package:file/file.dart';
...@@ -23,9 +21,9 @@ import '../../src/context.dart'; ...@@ -23,9 +21,9 @@ import '../../src/context.dart';
void main() { void main() {
group('PrebuiltMacOSApp', () { group('PrebuiltMacOSApp', () {
FakeOperatingSystemUtils os; late FakeOperatingSystemUtils os;
FileSystem fileSystem; late FileSystem fileSystem;
BufferLogger logger; late BufferLogger logger;
final Map<Type, Generator> overrides = <Type, Generator>{ final Map<Type, Generator> overrides = <Type, Generator>{
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
...@@ -42,7 +40,7 @@ group('PrebuiltMacOSApp', () { ...@@ -42,7 +40,7 @@ group('PrebuiltMacOSApp', () {
}); });
testUsingContext('Error on non-existing file', () { testUsingContext('Error on non-existing file', () {
final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('not_existing.app')) as PrebuiltMacOSApp; final PrebuiltMacOSApp? macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('not_existing.app')) as PrebuiltMacOSApp?;
expect(macosApp, isNull); expect(macosApp, isNull);
expect(logger.errorText, contains('File "not_existing.app" does not exist.')); expect(logger.errorText, contains('File "not_existing.app" does not exist.'));
...@@ -50,7 +48,7 @@ group('PrebuiltMacOSApp', () { ...@@ -50,7 +48,7 @@ group('PrebuiltMacOSApp', () {
testUsingContext('Error on non-app-bundle folder', () { testUsingContext('Error on non-app-bundle folder', () {
fileSystem.directory('regular_folder').createSync(); fileSystem.directory('regular_folder').createSync();
final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('regular_folder')) as PrebuiltMacOSApp; final PrebuiltMacOSApp? macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('regular_folder')) as PrebuiltMacOSApp?;
expect(macosApp, isNull); expect(macosApp, isNull);
expect(logger.errorText, contains('Folder "regular_folder" is not an app bundle.')); expect(logger.errorText, contains('Folder "regular_folder" is not an app bundle.'));
...@@ -58,7 +56,7 @@ group('PrebuiltMacOSApp', () { ...@@ -58,7 +56,7 @@ group('PrebuiltMacOSApp', () {
testUsingContext('Error on no info.plist', () { testUsingContext('Error on no info.plist', () {
fileSystem.directory('bundle.app').createSync(); fileSystem.directory('bundle.app').createSync();
final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('bundle.app')) as PrebuiltMacOSApp; final PrebuiltMacOSApp? macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('bundle.app')) as PrebuiltMacOSApp?;
expect(macosApp, isNull); expect(macosApp, isNull);
expect(logger.errorText, contains('Invalid prebuilt macOS app. Does not contain Info.plist.')); expect(logger.errorText, contains('Invalid prebuilt macOS app. Does not contain Info.plist.'));
...@@ -67,10 +65,9 @@ group('PrebuiltMacOSApp', () { ...@@ -67,10 +65,9 @@ group('PrebuiltMacOSApp', () {
testUsingContext('Error on info.plist missing bundle identifier', () { testUsingContext('Error on info.plist missing bundle identifier', () {
final String contentsDirectory = fileSystem.path.join('bundle.app', 'Contents'); final String contentsDirectory = fileSystem.path.join('bundle.app', 'Contents');
fileSystem.directory(contentsDirectory).createSync(recursive: true); fileSystem.directory(contentsDirectory).createSync(recursive: true);
fileSystem fileSystem.file(fileSystem.path.join('bundle.app', 'Contents', 'Info.plist'))
.file(fileSystem.path.join('bundle.app', 'Contents', 'Info.plist'))
.writeAsStringSync(badPlistData); .writeAsStringSync(badPlistData);
final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('bundle.app')) as PrebuiltMacOSApp; final PrebuiltMacOSApp? macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('bundle.app')) as PrebuiltMacOSApp?;
expect(macosApp, isNull); expect(macosApp, isNull);
expect(logger.errorText, contains('Invalid prebuilt macOS app. Info.plist does not contain bundle identifier')); expect(logger.errorText, contains('Invalid prebuilt macOS app. Info.plist does not contain bundle identifier'));
...@@ -79,10 +76,9 @@ group('PrebuiltMacOSApp', () { ...@@ -79,10 +76,9 @@ group('PrebuiltMacOSApp', () {
testUsingContext('Error on info.plist missing executable', () { testUsingContext('Error on info.plist missing executable', () {
final String contentsDirectory = fileSystem.path.join('bundle.app', 'Contents'); final String contentsDirectory = fileSystem.path.join('bundle.app', 'Contents');
fileSystem.directory(contentsDirectory).createSync(recursive: true); fileSystem.directory(contentsDirectory).createSync(recursive: true);
fileSystem fileSystem.file(fileSystem.path.join('bundle.app', 'Contents', 'Info.plist'))
.file(fileSystem.path.join('bundle.app', 'Contents', 'Info.plist'))
.writeAsStringSync(badPlistDataNoExecutable); .writeAsStringSync(badPlistDataNoExecutable);
final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('bundle.app')) as PrebuiltMacOSApp; final PrebuiltMacOSApp? macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('bundle.app')) as PrebuiltMacOSApp?;
expect(macosApp, isNull); expect(macosApp, isNull);
expect(logger.errorText, contains('Invalid prebuilt macOS app. Info.plist does not contain bundle executable')); expect(logger.errorText, contains('Invalid prebuilt macOS app. Info.plist does not contain bundle executable'));
...@@ -91,13 +87,11 @@ group('PrebuiltMacOSApp', () { ...@@ -91,13 +87,11 @@ group('PrebuiltMacOSApp', () {
testUsingContext('Success with app bundle', () { testUsingContext('Success with app bundle', () {
final String appDirectory = fileSystem.path.join('bundle.app', 'Contents', 'MacOS'); final String appDirectory = fileSystem.path.join('bundle.app', 'Contents', 'MacOS');
fileSystem.directory(appDirectory).createSync(recursive: true); fileSystem.directory(appDirectory).createSync(recursive: true);
fileSystem fileSystem.file(fileSystem.path.join('bundle.app', 'Contents', 'Info.plist'))
.file(fileSystem.path.join('bundle.app', 'Contents', 'Info.plist'))
.writeAsStringSync(plistData); .writeAsStringSync(plistData);
fileSystem fileSystem.file(fileSystem.path.join(appDirectory, executableName))
.file(fileSystem.path.join(appDirectory, executableName))
.createSync(); .createSync();
final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('bundle.app')) as PrebuiltMacOSApp; final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('bundle.app'))! as PrebuiltMacOSApp;
expect(logger.errorText, isEmpty); expect(logger.errorText, isEmpty);
expect(macosApp.uncompressedBundle.path, 'bundle.app'); expect(macosApp.uncompressedBundle.path, 'bundle.app');
...@@ -107,7 +101,7 @@ group('PrebuiltMacOSApp', () { ...@@ -107,7 +101,7 @@ group('PrebuiltMacOSApp', () {
testUsingContext('Bad zipped app, no payload dir', () { testUsingContext('Bad zipped app, no payload dir', () {
fileSystem.file('app.zip').createSync(); fileSystem.file('app.zip').createSync();
final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('app.zip')) as PrebuiltMacOSApp; final PrebuiltMacOSApp? macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('app.zip')) as PrebuiltMacOSApp?;
expect(macosApp, isNull); expect(macosApp, isNull);
expect(logger.errorText, contains('Archive "app.zip" does not contain a single app bundle.')); expect(logger.errorText, contains('Archive "app.zip" does not contain a single app bundle.'));
...@@ -124,7 +118,7 @@ group('PrebuiltMacOSApp', () { ...@@ -124,7 +118,7 @@ group('PrebuiltMacOSApp', () {
fileSystem.directory(bundlePath1).createSync(recursive: true); fileSystem.directory(bundlePath1).createSync(recursive: true);
fileSystem.directory(bundlePath2).createSync(recursive: true); fileSystem.directory(bundlePath2).createSync(recursive: true);
}; };
final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('app.zip')) as PrebuiltMacOSApp; final PrebuiltMacOSApp? macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('app.zip')) as PrebuiltMacOSApp?;
expect(macosApp, isNull); expect(macosApp, isNull);
expect(logger.errorText, contains('Archive "app.zip" does not contain a single app bundle.')); expect(logger.errorText, contains('Archive "app.zip" does not contain a single app bundle.'));
...@@ -138,18 +132,15 @@ group('PrebuiltMacOSApp', () { ...@@ -138,18 +132,15 @@ group('PrebuiltMacOSApp', () {
} }
final Directory bundleAppContentsDir = fileSystem.directory(fileSystem.path.join(targetDirectory.path, 'bundle.app', 'Contents')); final Directory bundleAppContentsDir = fileSystem.directory(fileSystem.path.join(targetDirectory.path, 'bundle.app', 'Contents'));
bundleAppContentsDir.createSync(recursive: true); bundleAppContentsDir.createSync(recursive: true);
fileSystem fileSystem.file(fileSystem.path.join(bundleAppContentsDir.path, 'Info.plist'))
.file(fileSystem.path.join(bundleAppContentsDir.path, 'Info.plist'))
.writeAsStringSync(plistData); .writeAsStringSync(plistData);
fileSystem fileSystem.directory(fileSystem.path.join(bundleAppContentsDir.path, 'MacOS'))
.directory(fileSystem.path.join(bundleAppContentsDir.path, 'MacOS'))
.createSync(); .createSync();
fileSystem fileSystem.file(fileSystem.path
.file(fileSystem.path
.join(bundleAppContentsDir.path, 'MacOS', executableName)) .join(bundleAppContentsDir.path, 'MacOS', executableName))
.createSync(); .createSync();
}; };
final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('app.zip')) as PrebuiltMacOSApp; final PrebuiltMacOSApp macosApp = MacOSApp.fromPrebuiltApp(fileSystem.file('app.zip'))! as PrebuiltMacOSApp;
expect(logger.errorText, isEmpty); expect(logger.errorText, isEmpty);
expect(macosApp.uncompressedBundle.path, endsWith('bundle.app')); expect(macosApp.uncompressedBundle.path, endsWith('bundle.app'));
...@@ -170,7 +161,7 @@ group('PrebuiltMacOSApp', () { ...@@ -170,7 +161,7 @@ group('PrebuiltMacOSApp', () {
class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils { class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils {
FakeOperatingSystemUtils(); FakeOperatingSystemUtils();
void Function(File, Directory) unzipOverride; void Function(File, Directory)? unzipOverride;
@override @override
void unzip(File file, Directory targetDirectory) { void unzip(File file, Directory targetDirectory) {
...@@ -181,15 +172,15 @@ class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils { ...@@ -181,15 +172,15 @@ class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils {
class FakePlistUtils extends Fake implements PlistParser { class FakePlistUtils extends Fake implements PlistParser {
FakePlistUtils(this.fileSystem); FakePlistUtils(this.fileSystem);
final FileSystem fileSystem; final FileSystem? fileSystem;
@override @override
Map<String, dynamic> parseFile(String plistFilePath) { Map<String, Object> parseFile(String plistFilePath) {
final File file = fileSystem.file(plistFilePath); final File file = fileSystem!.file(plistFilePath);
if (!file.existsSync()) { if (!file.existsSync()) {
return <String, dynamic>{}; return <String, Object>{};
} }
return castStringKeyedMap(json.decode(file.readAsStringSync())); return castStringKeyedMap(json.decode(file.readAsStringSync()))!.cast();
} }
} }
......
...@@ -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/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
...@@ -22,11 +20,11 @@ import '../../src/context.dart'; ...@@ -22,11 +20,11 @@ import '../../src/context.dart';
import '../../src/fake_process_manager.dart'; import '../../src/fake_process_manager.dart';
void main() { void main() {
FileSystem fileSystem; late FileSystem fileSystem;
FakeProcessManager fakeProcessManager; late FakeProcessManager fakeProcessManager;
CocoaPods cocoaPodsUnderTest; late CocoaPods cocoaPodsUnderTest;
BufferLogger logger; late BufferLogger logger;
TestUsage usage; late TestUsage usage;
void pretendPodVersionFails() { void pretendPodVersionFails() {
fakeProcessManager.addCommand( fakeProcessManager.addCommand(
...@@ -77,17 +75,17 @@ void main() { ...@@ -77,17 +75,17 @@ void main() {
usage: usage, usage: usage,
); );
fileSystem.file(fileSystem.path.join( fileSystem.file(fileSystem.path.join(
Cache.flutterRoot, 'packages', 'flutter_tools', 'templates', 'cocoapods', 'Podfile-ios-objc', Cache.flutterRoot!, 'packages', 'flutter_tools', 'templates', 'cocoapods', 'Podfile-ios-objc',
)) ))
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsStringSync('Objective-C iOS podfile template'); ..writeAsStringSync('Objective-C iOS podfile template');
fileSystem.file(fileSystem.path.join( fileSystem.file(fileSystem.path.join(
Cache.flutterRoot, 'packages', 'flutter_tools', 'templates', 'cocoapods', 'Podfile-ios-swift', Cache.flutterRoot!, 'packages', 'flutter_tools', 'templates', 'cocoapods', 'Podfile-ios-swift',
)) ))
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsStringSync('Swift iOS podfile template'); ..writeAsStringSync('Swift iOS podfile template');
fileSystem.file(fileSystem.path.join( fileSystem.file(fileSystem.path.join(
Cache.flutterRoot, 'packages', 'flutter_tools', 'templates', 'cocoapods', 'Podfile-macos', Cache.flutterRoot!, 'packages', 'flutter_tools', 'templates', 'cocoapods', 'Podfile-macos',
)) ))
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsStringSync('macOS podfile template'); ..writeAsStringSync('macOS podfile template');
...@@ -728,7 +726,6 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by ...@@ -728,7 +726,6 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
final bool didInstall = await cocoaPodsUnderTest.processPods( final bool didInstall = await cocoaPodsUnderTest.processPods(
xcodeProject: projectUnderTest.ios, xcodeProject: projectUnderTest.ios,
buildMode: BuildMode.debug, buildMode: BuildMode.debug,
dependenciesChanged: true,
); );
expect(didInstall, isTrue); expect(didInstall, isTrue);
expect(fakeProcessManager, hasNoRemainingExpectations); expect(fakeProcessManager, hasNoRemainingExpectations);
...@@ -828,7 +825,7 @@ class FakeXcodeProjectInterpreter extends Fake implements XcodeProjectInterprete ...@@ -828,7 +825,7 @@ class FakeXcodeProjectInterpreter extends Fake implements XcodeProjectInterprete
@override @override
Future<Map<String, String>> getBuildSettings( Future<Map<String, String>> getBuildSettings(
String projectPath, { String projectPath, {
XcodeProjectBuildContext buildContext, XcodeProjectBuildContext? buildContext,
Duration timeout = const Duration(minutes: 1), Duration timeout = const Duration(minutes: 1),
}) async => buildSettings; }) async => buildSettings;
......
...@@ -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 'package:flutter_tools/src/artifacts.dart'; import 'package:flutter_tools/src/artifacts.dart';
...@@ -24,21 +22,21 @@ import '../../src/common.dart'; ...@@ -24,21 +22,21 @@ import '../../src/common.dart';
import '../../src/context.dart'; import '../../src/context.dart';
void main() { void main() {
BufferLogger logger; late BufferLogger logger;
setUp(() { setUp(() {
logger = BufferLogger.test(); logger = BufferLogger.test();
}); });
group('FakeProcessManager', () { group('FakeProcessManager', () {
FakeProcessManager fakeProcessManager; late FakeProcessManager fakeProcessManager;
setUp(() { setUp(() {
fakeProcessManager = FakeProcessManager.empty(); fakeProcessManager = FakeProcessManager.empty();
}); });
group('Xcode', () { group('Xcode', () {
FakeXcodeProjectInterpreter xcodeProjectInterpreter; late FakeXcodeProjectInterpreter xcodeProjectInterpreter;
setUp(() { setUp(() {
xcodeProjectInterpreter = FakeXcodeProjectInterpreter(); xcodeProjectInterpreter = FakeXcodeProjectInterpreter();
...@@ -94,7 +92,7 @@ void main() { ...@@ -94,7 +92,7 @@ void main() {
}); });
group('macOS', () { group('macOS', () {
Xcode xcode; late Xcode xcode;
setUp(() { setUp(() {
xcodeProjectInterpreter = FakeXcodeProjectInterpreter(); xcodeProjectInterpreter = FakeXcodeProjectInterpreter();
...@@ -276,8 +274,8 @@ void main() { ...@@ -276,8 +274,8 @@ void main() {
}); });
group('xcdevice not installed', () { group('xcdevice not installed', () {
XCDevice xcdevice; late XCDevice xcdevice;
Xcode xcode; late Xcode xcode;
setUp(() { setUp(() {
xcode = Xcode.test( xcode = Xcode.test(
...@@ -310,8 +308,8 @@ void main() { ...@@ -310,8 +308,8 @@ void main() {
}); });
group('xcdevice', () { group('xcdevice', () {
XCDevice xcdevice; late XCDevice xcdevice;
Xcode xcode; late Xcode xcode;
setUp(() { setUp(() {
xcode = Xcode.test(processManager: FakeProcessManager.any()); xcode = Xcode.test(processManager: FakeProcessManager.any());
...@@ -351,7 +349,7 @@ void main() { ...@@ -351,7 +349,7 @@ void main() {
// Attach: d83d5bc53967baa0ee18626ba87b6254b2ab5418 // Attach: d83d5bc53967baa0ee18626ba87b6254b2ab5418
// Attach: 00008027-00192736010F802E // Attach: 00008027-00192736010F802E
// Detach: d83d5bc53967baa0ee18626ba87b6254b2ab5418 // Detach: d83d5bc53967baa0ee18626ba87b6254b2ab5418
xcdevice.observedDeviceEvents().listen((Map<XCDeviceEvent, String> event) { xcdevice.observedDeviceEvents()!.listen((Map<XCDeviceEvent, String> event) {
expect(event.length, 1); expect(event.length, 1);
if (event.containsKey(XCDeviceEvent.attach)) { if (event.containsKey(XCDeviceEvent.attach)) {
if (event[XCDeviceEvent.attach] == 'd83d5bc53967baa0ee18626ba87b6254b2ab5418') { if (event[XCDeviceEvent.attach] == 'd83d5bc53967baa0ee18626ba87b6254b2ab5418') {
......
...@@ -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 'package:file/memory.dart'; import 'package:file/memory.dart';
...@@ -93,15 +91,15 @@ class FakeBundleBuilder extends Fake implements BundleBuilder { ...@@ -93,15 +91,15 @@ class FakeBundleBuilder extends Fake implements BundleBuilder {
@override @override
Future<void> build({ Future<void> build({
@required TargetPlatform platform, required TargetPlatform platform,
@required BuildInfo buildInfo, required BuildInfo buildInfo,
FlutterProject project, FlutterProject? project,
String mainPath, String? mainPath,
String manifestPath = defaultManifestPath, String manifestPath = defaultManifestPath,
String applicationKernelFilePath, String? applicationKernelFilePath,
String depfilePath, String? depfilePath,
String assetDirPath, String? assetDirPath,
@visibleForTesting BuildSystem buildSystem @visibleForTesting BuildSystem? buildSystem
}) async { }) async {
final Directory assetDirectory = fileSystem final Directory assetDirectory = fileSystem
.directory(assetDirPath) .directory(assetDirPath)
......
...@@ -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/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
......
...@@ -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 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
...@@ -107,8 +105,8 @@ void main() { ...@@ -107,8 +105,8 @@ void main() {
flutterDevices: <FlutterDevice>[], flutterDevices: <FlutterDevice>[],
); );
expect(handler.activeDevToolsServer.host, 'localhost'); expect(handler.activeDevToolsServer!.host, 'localhost');
expect(handler.activeDevToolsServer.port, 8181); expect(handler.activeDevToolsServer!.port, 8181);
}); });
testWithoutContext('serveAndAnnounceDevTools with attached device does not fail on null vm service', () async { testWithoutContext('serveAndAnnounceDevTools with attached device does not fail on null vm service', () async {
...@@ -425,13 +423,13 @@ void main() { ...@@ -425,13 +423,13 @@ void main() {
class FakeDevtoolsLauncher extends Fake implements DevtoolsLauncher { class FakeDevtoolsLauncher extends Fake implements DevtoolsLauncher {
@override @override
DevToolsServerAddress activeDevToolsServer; DevToolsServerAddress? activeDevToolsServer;
@override @override
Uri devToolsUrl; Uri? devToolsUrl;
@override @override
Future<DevToolsServerAddress> serve() async => null; Future<DevToolsServerAddress?> serve() async => null;
@override @override
Future<void> get ready => readyCompleter.future; Future<void> get ready => readyCompleter.future;
...@@ -452,7 +450,7 @@ class FakeFlutterDevice extends Fake implements FlutterDevice { ...@@ -452,7 +450,7 @@ class FakeFlutterDevice extends Fake implements FlutterDevice {
final Device device = FakeDevice(); final Device device = FakeDevice();
@override @override
FlutterVmService vmService; FlutterVmService? vmService;
@override @override
TargetPlatform targetPlatform = TargetPlatform.android_arm; TargetPlatform targetPlatform = TargetPlatform.android_arm;
......
...@@ -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 'package:file/file.dart'; import 'package:file/file.dart';
...@@ -945,14 +943,14 @@ void main() { ...@@ -945,14 +943,14 @@ void main() {
listViews, listViews,
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'ext.flutter.debugAllowBanner', method: 'ext.flutter.debugAllowBanner',
args: <String, Object>{ args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id, 'isolateId': fakeUnpausedIsolate.id,
'enabled': 'false', 'enabled': 'false',
}, },
), ),
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'ext.flutter.debugAllowBanner', method: 'ext.flutter.debugAllowBanner',
args: <String, Object>{ args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id, 'isolateId': fakeUnpausedIsolate.id,
'enabled': 'true', 'enabled': 'true',
}, },
...@@ -971,7 +969,7 @@ void main() { ...@@ -971,7 +969,7 @@ void main() {
listViews, listViews,
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'ext.flutter.debugAllowBanner', method: 'ext.flutter.debugAllowBanner',
args: <String, Object>{ args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id, 'isolateId': fakeUnpausedIsolate.id,
'enabled': 'false', 'enabled': 'false',
}, },
...@@ -985,7 +983,7 @@ void main() { ...@@ -985,7 +983,7 @@ void main() {
), ),
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'ext.flutter.debugAllowBanner', method: 'ext.flutter.debugAllowBanner',
args: <String, Object>{ args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id, 'isolateId': fakeUnpausedIsolate.id,
'enabled': 'true', 'enabled': 'true',
}, },
...@@ -1005,7 +1003,7 @@ void main() { ...@@ -1005,7 +1003,7 @@ void main() {
listViews, listViews,
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'ext.flutter.debugAllowBanner', method: 'ext.flutter.debugAllowBanner',
args: <String, Object>{ args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id, 'isolateId': fakeUnpausedIsolate.id,
'enabled': 'false', 'enabled': 'false',
}, },
...@@ -1019,7 +1017,7 @@ void main() { ...@@ -1019,7 +1017,7 @@ void main() {
), ),
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'ext.flutter.debugAllowBanner', method: 'ext.flutter.debugAllowBanner',
args: <String, Object>{ args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id, 'isolateId': fakeUnpausedIsolate.id,
'enabled': 'true', 'enabled': 'true',
}, },
...@@ -1090,7 +1088,7 @@ void main() { ...@@ -1090,7 +1088,7 @@ void main() {
listViews, listViews,
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'ext.flutter.debugAllowBanner', method: 'ext.flutter.debugAllowBanner',
args: <String, Object>{ args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id, 'isolateId': fakeUnpausedIsolate.id,
'enabled': 'false', 'enabled': 'false',
}, },
...@@ -1115,7 +1113,7 @@ void main() { ...@@ -1115,7 +1113,7 @@ void main() {
listViews, listViews,
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'ext.flutter.debugAllowBanner', method: 'ext.flutter.debugAllowBanner',
args: <String, Object>{ args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id, 'isolateId': fakeUnpausedIsolate.id,
'enabled': 'false', 'enabled': 'false',
}, },
...@@ -1127,7 +1125,7 @@ void main() { ...@@ -1127,7 +1125,7 @@ void main() {
), ),
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'ext.flutter.debugAllowBanner', method: 'ext.flutter.debugAllowBanner',
args: <String, Object>{ args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id, 'isolateId': fakeUnpausedIsolate.id,
'enabled': 'true', 'enabled': 'true',
}, },
...@@ -1150,7 +1148,7 @@ void main() { ...@@ -1150,7 +1148,7 @@ void main() {
listViews, listViews,
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'ext.flutter.debugAllowBanner', method: 'ext.flutter.debugAllowBanner',
args: <String, Object>{ args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id, 'isolateId': fakeUnpausedIsolate.id,
'enabled': 'false', 'enabled': 'false',
}, },
...@@ -1162,7 +1160,7 @@ void main() { ...@@ -1162,7 +1160,7 @@ void main() {
), ),
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'ext.flutter.debugAllowBanner', method: 'ext.flutter.debugAllowBanner',
args: <String, Object>{ args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id, 'isolateId': fakeUnpausedIsolate.id,
'enabled': 'true', 'enabled': 'true',
}, },
...@@ -1186,14 +1184,14 @@ void main() { ...@@ -1186,14 +1184,14 @@ void main() {
listViews, listViews,
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'ext.flutter.debugAllowBanner', method: 'ext.flutter.debugAllowBanner',
args: <String, Object>{ args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id, 'isolateId': fakeUnpausedIsolate.id,
'enabled': 'false', 'enabled': 'false',
}, },
), ),
FakeVmServiceRequest( FakeVmServiceRequest(
method: 'ext.flutter.debugAllowBanner', method: 'ext.flutter.debugAllowBanner',
args: <String, Object>{ args: <String, Object?>{
'isolateId': fakeUnpausedIsolate.id, 'isolateId': fakeUnpausedIsolate.id,
'enabled': 'true', 'enabled': 'true',
}, },
...@@ -1309,7 +1307,7 @@ class FakeResidentRunner extends ResidentHandlers { ...@@ -1309,7 +1307,7 @@ class FakeResidentRunner extends ResidentHandlers {
} }
@override @override
void printHelp({bool details}) { void printHelp({required bool details}) {
if (details) { if (details) {
calledPrintWithDetails = true; calledPrintWithDetails = true;
} else { } else {
...@@ -1321,7 +1319,7 @@ class FakeResidentRunner extends ResidentHandlers { ...@@ -1321,7 +1319,7 @@ class FakeResidentRunner extends ResidentHandlers {
Future<void> runSourceGenerators() async { } Future<void> runSourceGenerators() async { }
@override @override
Future<OperationResult> restart({bool fullRestart = false, bool pause = false, String reason}) async { Future<OperationResult> restart({bool fullRestart = false, bool pause = false, String? reason}) async {
if (fullRestart && !supportsRestart) { if (fullRestart && !supportsRestart) {
throw StateError('illegal restart'); throw StateError('illegal restart');
} }
...@@ -1345,7 +1343,7 @@ class FakeResidentDevtoolsHandler extends Fake implements ResidentDevtoolsHandle ...@@ -1345,7 +1343,7 @@ class FakeResidentDevtoolsHandler extends Fake implements ResidentDevtoolsHandle
bool calledLaunchDevToolsInBrowser = false; bool calledLaunchDevToolsInBrowser = false;
@override @override
bool launchDevToolsInBrowser({List<FlutterDevice> flutterDevices}) { bool launchDevToolsInBrowser({List<FlutterDevice?>? flutterDevices}) {
return calledLaunchDevToolsInBrowser = true; return calledLaunchDevToolsInBrowser = true;
} }
} }
...@@ -1382,8 +1380,8 @@ TerminalHandler setUpTerminalHandler(List<FakeVmServiceRequest> requests, { ...@@ -1382,8 +1380,8 @@ TerminalHandler setUpTerminalHandler(List<FakeVmServiceRequest> requests, {
bool supportsScreenshot = false, bool supportsScreenshot = false,
int reloadExitCode = 0, int reloadExitCode = 0,
BuildMode buildMode = BuildMode.debug, BuildMode buildMode = BuildMode.debug,
Logger logger, Logger? logger,
FileSystem fileSystem, FileSystem? fileSystem,
}) { }) {
final Logger testLogger = logger ?? BufferLogger.test(); final Logger testLogger = logger ?? BufferLogger.test();
final Signals signals = Signals.test(); final Signals signals = Signals.test();
...@@ -1440,7 +1438,7 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler { } ...@@ -1440,7 +1438,7 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler { }
class TestRunner extends Fake implements ResidentRunner { class TestRunner extends Fake implements ResidentRunner {
bool hasHelpBeenPrinted = false; bool hasHelpBeenPrinted = false;
String receivedCommand; String? receivedCommand;
@override @override
Future<void> cleanupAfterSignal() async { } Future<void> cleanupAfterSignal() async { }
...@@ -1449,22 +1447,22 @@ class TestRunner extends Fake implements ResidentRunner { ...@@ -1449,22 +1447,22 @@ class TestRunner extends Fake implements ResidentRunner {
Future<void> cleanupAtFinish() async { } Future<void> cleanupAtFinish() async { }
@override @override
void printHelp({ bool details }) { void printHelp({ bool? details }) {
hasHelpBeenPrinted = true; hasHelpBeenPrinted = true;
} }
@override @override
Future<int> run({ Future<int?> run({
Completer<DebugConnectionInfo> connectionInfoCompleter, Completer<DebugConnectionInfo>? connectionInfoCompleter,
Completer<void> appStartedCompleter, Completer<void>? appStartedCompleter,
bool enableDevTools = false, bool enableDevTools = false,
String route, String? route,
}) async => null; }) async => null;
@override @override
Future<int> attach({ Future<int?> attach({
Completer<DebugConnectionInfo> connectionInfoCompleter, Completer<DebugConnectionInfo>? connectionInfoCompleter,
Completer<void> appStartedCompleter, Completer<void>? appStartedCompleter,
bool allowExistingDdsInstance = false, bool allowExistingDdsInstance = false,
bool enableDevTools = false, bool enableDevTools = false,
bool needsFullRestart = true, bool needsFullRestart = true,
...@@ -1491,10 +1489,10 @@ class _TestSignals implements Signals { ...@@ -1491,10 +1489,10 @@ class _TestSignals implements Signals {
if (!_handlersTable.containsKey(signal)) { if (!_handlersTable.containsKey(signal)) {
return false; return false;
} }
if (!_handlersTable[signal].containsKey(token)) { if (!_handlersTable[signal]!.containsKey(token)) {
return false; return false;
} }
_handlersTable[signal].remove(token); _handlersTable[signal]!.remove(token);
return true; return true;
} }
......
...@@ -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';
...@@ -33,8 +31,8 @@ final BuildInfo debugBuild = BuildInfo( ...@@ -33,8 +31,8 @@ final BuildInfo debugBuild = BuildInfo(
); );
void main() { void main() {
FakeResidentCompiler residentCompiler; late FakeResidentCompiler residentCompiler;
FileSystem fileSystem; late FileSystem fileSystem;
setUp(() { setUp(() {
fileSystem = MemoryFileSystem.test(); fileSystem = MemoryFileSystem.test();
...@@ -149,8 +147,7 @@ environment: ...@@ -149,8 +147,7 @@ environment:
await testCompiler.compile(Uri.parse('test/foo.dart')); await testCompiler.compile(Uri.parse('test/foo.dart'));
final File generatedMain = fileSystem final File generatedMain = fileSystem.directory('.dart_tool')
.directory('.dart_tool')
.childDirectory('flutter_build') .childDirectory('flutter_build')
.childFile('dart_plugin_registrant.dart'); .childFile('dart_plugin_registrant.dart');
...@@ -170,17 +167,17 @@ environment: ...@@ -170,17 +167,17 @@ environment:
/// Override the creation of the Resident Compiler to simplify testing. /// Override the creation of the Resident Compiler to simplify testing.
class FakeTestCompiler extends TestCompiler { class FakeTestCompiler extends TestCompiler {
FakeTestCompiler( FakeTestCompiler(
BuildInfo buildInfo, super.buildInfo,
FlutterProject flutterProject, super.flutterProject,
this.residentCompiler, { this.residentCompiler, {
String precompiledDillPath, super.precompiledDillPath,
} }
) : super(buildInfo, flutterProject, precompiledDillPath: precompiledDillPath); );
final FakeResidentCompiler residentCompiler; final FakeResidentCompiler? residentCompiler;
@override @override
Future<ResidentCompiler> createCompiler() async { Future<ResidentCompiler?> createCompiler() async {
return residentCompiler; return residentCompiler;
} }
} }
...@@ -188,24 +185,24 @@ class FakeTestCompiler extends TestCompiler { ...@@ -188,24 +185,24 @@ class FakeTestCompiler extends TestCompiler {
class FakeResidentCompiler extends Fake implements ResidentCompiler { class FakeResidentCompiler extends Fake implements ResidentCompiler {
FakeResidentCompiler(this.fileSystem); FakeResidentCompiler(this.fileSystem);
final FileSystem fileSystem; final FileSystem? fileSystem;
CompilerOutput compilerOutput; CompilerOutput? compilerOutput;
bool didShutdown = false; bool didShutdown = false;
@override @override
Future<CompilerOutput> recompile( Future<CompilerOutput?> recompile(
Uri mainUri, Uri mainUri,
List<Uri> invalidatedFiles, { List<Uri>? invalidatedFiles, {
String outputPath, String? outputPath,
PackageConfig packageConfig, PackageConfig? packageConfig,
String projectRootPath, String? projectRootPath,
FileSystem fs, FileSystem? fs,
bool suppressErrors = false, bool suppressErrors = false,
bool checkDartPluginRegistry = false, bool checkDartPluginRegistry = false,
}) async { }) async {
if (compilerOutput != null) { if (compilerOutput != null) {
fileSystem.file(compilerOutput.outputFilename).createSync(recursive: true); fileSystem!.file(compilerOutput!.outputFilename).createSync(recursive: true);
} }
return compilerOutput; return compilerOutput;
} }
...@@ -217,7 +214,8 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler { ...@@ -217,7 +214,8 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler {
void reset() { } void reset() { }
@override @override
Future<void> shutdown() async { Future<Object> shutdown() async {
didShutdown = true; didShutdown = true;
return Object();
} }
} }
...@@ -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:io'; import 'dart:io';
...@@ -24,7 +22,7 @@ void main() { ...@@ -24,7 +22,7 @@ void main() {
test('Can provide default interfaces', () async { test('Can provide default interfaces', () async {
final Testbed testbed = Testbed(); final Testbed testbed = Testbed();
FileSystem localFileSystem; late FileSystem localFileSystem;
await testbed.run(() { await testbed.run(() {
localFileSystem = globals.fs; localFileSystem = globals.fs;
}); });
...@@ -39,7 +37,7 @@ void main() { ...@@ -39,7 +37,7 @@ void main() {
A: () => A(), A: () => A(),
}); });
A instance; A? instance;
await testbed.run(() { await testbed.run(() {
instance = context.get<A>(); instance = context.get<A>();
}); });
...@@ -52,7 +50,7 @@ void main() { ...@@ -52,7 +50,7 @@ void main() {
A: () => A(), A: () => A(),
}); });
A instance; A? instance;
await testbed.run(() { await testbed.run(() {
instance = context.get<A>(); instance = context.get<A>();
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
......
...@@ -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:convert'; import 'dart:convert';
import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
...@@ -24,8 +22,8 @@ final DateTime _stampUpToDate = _testClock.ago(VersionFreshnessValidator.checkAg ...@@ -24,8 +22,8 @@ final DateTime _stampUpToDate = _testClock.ago(VersionFreshnessValidator.checkAg
final DateTime _stampOutOfDate = _testClock.ago(VersionFreshnessValidator.checkAgeConsideredUpToDate * 2); final DateTime _stampOutOfDate = _testClock.ago(VersionFreshnessValidator.checkAgeConsideredUpToDate * 2);
void main() { void main() {
FakeCache cache; late FakeCache cache;
FakeProcessManager processManager; late FakeProcessManager processManager;
setUp(() { setUp(() {
processManager = FakeProcessManager.empty(); processManager = FakeProcessManager.empty();
...@@ -323,15 +321,15 @@ void main() { ...@@ -323,15 +321,15 @@ void main() {
const String flutterNonStandardUrlDotGit = 'https://githubmirror.com/flutter/flutter.git'; const String flutterNonStandardUrlDotGit = 'https://githubmirror.com/flutter/flutter.git';
const String flutterStandardSshUrlDotGit = 'git@github.com:flutter/flutter.git'; const String flutterStandardSshUrlDotGit = 'git@github.com:flutter/flutter.git';
VersionCheckError runUpstreamValidator({ VersionCheckError? runUpstreamValidator({
String versionUpstreamUrl, String? versionUpstreamUrl,
String flutterGitUrl, String? flutterGitUrl,
}){ }){
final Platform testPlatform = FakePlatform(environment: <String, String> { final Platform testPlatform = FakePlatform(environment: <String, String> {
if (flutterGitUrl != null) 'FLUTTER_GIT_URL': flutterGitUrl, if (flutterGitUrl != null) 'FLUTTER_GIT_URL': flutterGitUrl,
}); });
return VersionUpstreamValidator( return VersionUpstreamValidator(
version: FakeFlutterVersion(repositoryUrl: versionUpstreamUrl), version: FakeFlutterVersion(repositoryUrl: versionUpstreamUrl, channel: 'master'),
platform: testPlatform, platform: testPlatform,
).run(); ).run();
} }
...@@ -339,7 +337,7 @@ void main() { ...@@ -339,7 +337,7 @@ void main() {
testWithoutContext('returns error if repository url is null', () { testWithoutContext('returns error if repository url is null', () {
final VersionCheckError error = runUpstreamValidator( final VersionCheckError error = runUpstreamValidator(
// repositoryUrl is null by default // repositoryUrl is null by default
); )!;
expect(error, isNotNull); expect(error, isNotNull);
expect( expect(
error.message, error.message,
...@@ -352,7 +350,7 @@ void main() { ...@@ -352,7 +350,7 @@ void main() {
}); });
testWithoutContext('returns error at non-standard remote url with FLUTTER_GIT_URL unset', () { testWithoutContext('returns error at non-standard remote url with FLUTTER_GIT_URL unset', () {
final VersionCheckError error = runUpstreamValidator(versionUpstreamUrl: flutterNonStandardUrlDotGit); final VersionCheckError error = runUpstreamValidator(versionUpstreamUrl: flutterNonStandardUrlDotGit)!;
expect(error, isNotNull); expect(error, isNotNull);
expect( expect(
error.message, error.message,
...@@ -375,7 +373,7 @@ void main() { ...@@ -375,7 +373,7 @@ void main() {
final VersionCheckError error = runUpstreamValidator( final VersionCheckError error = runUpstreamValidator(
versionUpstreamUrl: flutterStandardUrlDotGit, versionUpstreamUrl: flutterStandardUrlDotGit,
flutterGitUrl: flutterNonStandardUrlDotGit, flutterGitUrl: flutterNonStandardUrlDotGit,
); )!;
expect(error, isNotNull); expect(error, isNotNull);
expect( expect(
error.message, error.message,
...@@ -673,7 +671,7 @@ void main() { ...@@ -673,7 +671,7 @@ void main() {
} }
class FakeCache extends Fake implements Cache { class FakeCache extends Fake implements Cache {
String versionStamp; String? versionStamp;
bool setVersionStamp = false; bool setVersionStamp = false;
@override @override
...@@ -689,7 +687,7 @@ class FakeCache extends Fake implements Cache { ...@@ -689,7 +687,7 @@ class FakeCache extends Fake implements Cache {
void checkLockAcquired() { } void checkLockAcquired() { }
@override @override
String getStampFor(String artifactName) { String? getStampFor(String artifactName) {
if (artifactName == VersionCheckStamp.flutterVersionCheckStampFile) { if (artifactName == VersionCheckStamp.flutterVersionCheckStampFile) {
return versionStamp; return versionStamp;
} }
...@@ -705,11 +703,11 @@ class FakeCache extends Fake implements Cache { ...@@ -705,11 +703,11 @@ class FakeCache extends Fake implements Cache {
} }
class FakeFlutterVersion extends Fake implements FlutterVersion { class FakeFlutterVersion extends Fake implements FlutterVersion {
FakeFlutterVersion({this.channel, this.repositoryUrl}); FakeFlutterVersion({required this.channel, this.repositoryUrl});
@override @override
final String channel; final String channel;
@override @override
final String repositoryUrl; final String? repositoryUrl;
} }
...@@ -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/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
...@@ -17,9 +15,9 @@ import '../../src/context.dart'; ...@@ -17,9 +15,9 @@ import '../../src/context.dart';
void main() { void main() {
group('PrebuiltWindowsApp', () { group('PrebuiltWindowsApp', () {
FakeOperatingSystemUtils os; late FakeOperatingSystemUtils os;
FileSystem fileSystem; late FileSystem fileSystem;
BufferLogger logger; late BufferLogger logger;
final Map<Type, Generator> overrides = <Type, Generator>{ final Map<Type, Generator> overrides = <Type, Generator>{
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
...@@ -35,7 +33,7 @@ void main() { ...@@ -35,7 +33,7 @@ void main() {
}); });
testUsingContext('Error on non-existing exe file', () { testUsingContext('Error on non-existing exe file', () {
final PrebuiltWindowsApp windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('not_existing.exe')) as PrebuiltWindowsApp; final PrebuiltWindowsApp? windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('not_existing.exe')) as PrebuiltWindowsApp?;
expect(windowsApp, isNull); expect(windowsApp, isNull);
expect(logger.errorText, contains('File "not_existing.exe" does not exist.')); expect(logger.errorText, contains('File "not_existing.exe" does not exist.'));
...@@ -43,13 +41,13 @@ void main() { ...@@ -43,13 +41,13 @@ void main() {
testUsingContext('Success on exe file', () { testUsingContext('Success on exe file', () {
fileSystem.file('file.exe').createSync(); fileSystem.file('file.exe').createSync();
final PrebuiltWindowsApp windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('file.exe')) as PrebuiltWindowsApp; final PrebuiltWindowsApp windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('file.exe'))! as PrebuiltWindowsApp;
expect(windowsApp.name, 'file.exe'); expect(windowsApp.name, 'file.exe');
}, overrides: overrides); }, overrides: overrides);
testUsingContext('Error on non-existing zip file', () { testUsingContext('Error on non-existing zip file', () {
final PrebuiltWindowsApp windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('not_existing.zip')) as PrebuiltWindowsApp; final PrebuiltWindowsApp? windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('not_existing.zip')) as PrebuiltWindowsApp?;
expect(windowsApp, isNull); expect(windowsApp, isNull);
expect(logger.errorText, contains('File "not_existing.zip" does not exist.')); expect(logger.errorText, contains('File "not_existing.zip" does not exist.'));
...@@ -57,7 +55,7 @@ void main() { ...@@ -57,7 +55,7 @@ void main() {
testUsingContext('Bad zipped app, no payload dir', () { testUsingContext('Bad zipped app, no payload dir', () {
fileSystem.file('app.zip').createSync(); fileSystem.file('app.zip').createSync();
final PrebuiltWindowsApp windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('app.zip')) as PrebuiltWindowsApp; final PrebuiltWindowsApp? windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('app.zip')) as PrebuiltWindowsApp?;
expect(windowsApp, isNull); expect(windowsApp, isNull);
expect(logger.errorText, contains('Cannot find .exe files in the zip archive.')); expect(logger.errorText, contains('Cannot find .exe files in the zip archive.'));
...@@ -74,7 +72,7 @@ void main() { ...@@ -74,7 +72,7 @@ void main() {
fileSystem.directory(exePath1).createSync(recursive: true); fileSystem.directory(exePath1).createSync(recursive: true);
fileSystem.directory(exePath2).createSync(recursive: true); fileSystem.directory(exePath2).createSync(recursive: true);
}; };
final PrebuiltWindowsApp windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('app.zip')) as PrebuiltWindowsApp; final PrebuiltWindowsApp? windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('app.zip')) as PrebuiltWindowsApp?;
expect(windowsApp, isNull); expect(windowsApp, isNull);
expect(logger.errorText, contains('Archive "app.zip" contains more than one .exe files.')); expect(logger.errorText, contains('Archive "app.zip" contains more than one .exe files.'));
...@@ -82,7 +80,7 @@ void main() { ...@@ -82,7 +80,7 @@ void main() {
testUsingContext('Success with zipped app', () { testUsingContext('Success with zipped app', () {
fileSystem.file('app.zip').createSync(); fileSystem.file('app.zip').createSync();
String exePath; String? exePath;
os.unzipOverride = (File zipFile, Directory targetDirectory) { os.unzipOverride = (File zipFile, Directory targetDirectory) {
if (zipFile.path != 'app.zip') { if (zipFile.path != 'app.zip') {
return; return;
...@@ -90,7 +88,7 @@ void main() { ...@@ -90,7 +88,7 @@ void main() {
exePath = fileSystem.path.join(targetDirectory.path, 'app.exe'); exePath = fileSystem.path.join(targetDirectory.path, 'app.exe');
fileSystem.directory(exePath).createSync(recursive: true); fileSystem.directory(exePath).createSync(recursive: true);
}; };
final PrebuiltWindowsApp windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('app.zip')) as PrebuiltWindowsApp; final PrebuiltWindowsApp windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('app.zip'))! as PrebuiltWindowsApp;
expect(logger.errorText, isEmpty); expect(logger.errorText, isEmpty);
expect(windowsApp.name, exePath); expect(windowsApp.name, exePath);
...@@ -99,7 +97,7 @@ void main() { ...@@ -99,7 +97,7 @@ void main() {
testUsingContext('Error on unknown file type', () { testUsingContext('Error on unknown file type', () {
fileSystem.file('not_existing.app').createSync(); fileSystem.file('not_existing.app').createSync();
final PrebuiltWindowsApp windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('not_existing.app')) as PrebuiltWindowsApp; final PrebuiltWindowsApp? windowsApp = WindowsApp.fromPrebuiltApp(fileSystem.file('not_existing.app')) as PrebuiltWindowsApp?;
expect(windowsApp, isNull); expect(windowsApp, isNull);
expect(logger.errorText, contains('Unknown windows application type.')); expect(logger.errorText, contains('Unknown windows application type.'));
...@@ -110,7 +108,7 @@ void main() { ...@@ -110,7 +108,7 @@ void main() {
class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils { class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils {
FakeOperatingSystemUtils(); FakeOperatingSystemUtils();
void Function(File, Directory) unzipOverride; void Function(File, Directory)? unzipOverride;
@override @override
void unzip(File file, Directory targetDirectory) { void unzip(File file, Directory targetDirectory) {
......
...@@ -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:vm_service/vm_service.dart'; import 'package:vm_service/vm_service.dart';
...@@ -16,8 +14,8 @@ import 'test_utils.dart'; ...@@ -16,8 +14,8 @@ import 'test_utils.dart';
void batch1() { void batch1() {
final BasicProject project = BasicProject(); final BasicProject project = BasicProject();
Directory tempDir; late Directory tempDir;
FlutterRunTestDriver flutter; late FlutterRunTestDriver flutter;
Future<void> initProject() async { Future<void> initProject() async {
tempDir = createResolvedTempDirectorySync('run_expression_eval_test.'); tempDir = createResolvedTempDirectorySync('run_expression_eval_test.');
...@@ -95,8 +93,8 @@ void batch1() { ...@@ -95,8 +93,8 @@ void batch1() {
void batch2() { void batch2() {
final TestsProject project = TestsProject(); final TestsProject project = TestsProject();
Directory tempDir; late Directory tempDir;
FlutterTestTestDriver flutter; late FlutterTestTestDriver flutter;
Future<void> initProject() async { Future<void> initProject() async {
tempDir = createResolvedTempDirectorySync('test_expression_eval_test.'); tempDir = createResolvedTempDirectorySync('test_expression_eval_test.');
...@@ -105,7 +103,7 @@ void batch2() { ...@@ -105,7 +103,7 @@ void batch2() {
} }
Future<void> cleanProject() async { Future<void> cleanProject() async {
await flutter?.waitForCompletion(); await flutter.waitForCompletion();
tryToDelete(tempDir); tryToDelete(tempDir);
} }
...@@ -165,14 +163,14 @@ Future<void> evaluateComplexReturningExpressions(FlutterTestDriver flutter) asyn ...@@ -165,14 +163,14 @@ Future<void> evaluateComplexReturningExpressions(FlutterTestDriver flutter) asyn
final DateTime date = DateTime(2000); final DateTime date = DateTime(2000);
final ObjRef resp = await flutter.evaluateInFrame('new DateTime(2000)'); final ObjRef resp = await flutter.evaluateInFrame('new DateTime(2000)');
expectInstanceOfClass(resp, 'DateTime'); expectInstanceOfClass(resp, 'DateTime');
final ObjRef res = await flutter.evaluate(resp.id, r'"$year-$month-$day"'); final ObjRef res = await flutter.evaluate(resp.id!, r'"$year-$month-$day"');
expectValue(res, '${date.year}-${date.month}-${date.day}'); expectValue(res, '${date.year}-${date.month}-${date.day}');
} }
void expectInstanceOfClass(ObjRef result, String name) { void expectInstanceOfClass(ObjRef result, String name) {
expect(result, expect(result,
const TypeMatcher<InstanceRef>() const TypeMatcher<InstanceRef>()
.having((InstanceRef instance) => instance.classRef.name, 'resp.classRef.name', name)); .having((InstanceRef instance) => instance.classRef!.name, 'resp.classRef.name', name));
} }
void expectValueOfType(ObjRef result, String kind, String message) { void expectValueOfType(ObjRef result, String kind, String message) {
......
...@@ -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:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/flutter_project_metadata.dart'; import 'package:flutter_tools/src/flutter_project_metadata.dart';
...@@ -17,9 +15,9 @@ import 'test_utils.dart'; ...@@ -17,9 +15,9 @@ import 'test_utils.dart';
void main() { void main() {
Directory tempDir; late Directory tempDir;
FlutterRunTestDriver flutter; late FlutterRunTestDriver flutter;
Logger logger; late Logger logger;
setUp(() async { setUp(() async {
tempDir = createResolvedTempDirectorySync('run_test.'); tempDir = createResolvedTempDirectorySync('run_test.');
...@@ -71,11 +69,11 @@ migration: ...@@ -71,11 +69,11 @@ migration:
''', flush: true); ''', flush: true);
FlutterProjectMetadata metadata = FlutterProjectMetadata(metadataFile, logger); FlutterProjectMetadata metadata = FlutterProjectMetadata(metadataFile, logger);
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.root].createRevision, equals('fj19vkla9vnlka9vni3n808v3nch8cd')); expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.root]!.createRevision, equals('fj19vkla9vnlka9vni3n808v3nch8cd'));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.root].baseRevision, equals('93kf9v3njfa90vnidfjvn39nvi3vnie')); expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.root]!.baseRevision, equals('93kf9v3njfa90vnidfjvn39nvi3vnie'));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.android].createRevision, equals('abfj19vkla9vnlka9vni3n808v3nch8cd')); expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.android]!.createRevision, equals('abfj19vkla9vnlka9vni3n808v3nch8cd'));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.android].baseRevision, equals('ab93kf9v3njfa90vnidfjvn39nvi3vnie')); expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.android]!.baseRevision, equals('ab93kf9v3njfa90vnidfjvn39nvi3vnie'));
expect(metadata.migrateConfig.unmanagedFiles[0], equals('lib/main.dart')); expect(metadata.migrateConfig.unmanagedFiles[0], equals('lib/main.dart'));
expect(metadata.migrateConfig.unmanagedFiles[1], equals('ios/Runner.xcodeproj/project.pbxproj')); expect(metadata.migrateConfig.unmanagedFiles[1], equals('ios/Runner.xcodeproj/project.pbxproj'));
...@@ -169,8 +167,6 @@ migration: ...@@ -169,8 +167,6 @@ migration:
projectDirectory: tempDir, projectDirectory: tempDir,
currentRevision: currentRevision, currentRevision: currentRevision,
createRevision: createRevision, createRevision: createRevision,
create: true,
update: true,
logger: logger, logger: logger,
); );
...@@ -179,16 +175,16 @@ migration: ...@@ -179,16 +175,16 @@ migration:
final List<SupportedPlatform> keyList = List<SupportedPlatform>.from(metadata.migrateConfig.platformConfigs.keys); final List<SupportedPlatform> keyList = List<SupportedPlatform>.from(metadata.migrateConfig.platformConfigs.keys);
expect(keyList[0], equals(SupportedPlatform.root)); expect(keyList[0], equals(SupportedPlatform.root));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.root].baseRevision, equals(currentRevision)); expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.root]!.baseRevision, equals(currentRevision));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.root].createRevision, equals(createRevision)); expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.root]!.createRevision, equals(createRevision));
expect(keyList[1], equals(SupportedPlatform.android)); expect(keyList[1], equals(SupportedPlatform.android));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.android].baseRevision, equals(currentRevision)); expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.android]!.baseRevision, equals(currentRevision));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.android].createRevision, equals(createRevision)); expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.android]!.createRevision, equals(createRevision));
expect(keyList[2], equals(SupportedPlatform.ios)); expect(keyList[2], equals(SupportedPlatform.ios));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.ios].baseRevision, equals(currentRevision)); expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.ios]!.baseRevision, equals(currentRevision));
expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.ios].createRevision, equals(createRevision)); expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.ios]!.createRevision, equals(createRevision));
final File metadataFileOutput = tempDir.childFile('.metadata_output'); final File metadataFileOutput = tempDir.childFile('.metadata_output');
metadata.writeFile(outputFile: metadataFileOutput); metadata.writeFile(outputFile: metadataFileOutput);
......
...@@ -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/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
...@@ -15,7 +13,7 @@ import '../src/context.dart'; ...@@ -15,7 +13,7 @@ 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;
group('analyze project command', () { group('analyze project command', () {
......
...@@ -849,9 +849,9 @@ class FlutterTestTestDriver extends FlutterTestDriver { ...@@ -849,9 +849,9 @@ class FlutterTestTestDriver extends FlutterTestDriver {
await resume(); await resume();
final Future<Object> timeoutFuture = final Future<void> timeoutFuture =
Future<Object>.delayed(defaultTimeout); Future<void>.delayed(defaultTimeout);
await Future.any<Object>(<Future<Object>>[done.future, timeoutFuture]); await Future.any<void>(<Future<void>>[done.future, timeoutFuture]);
await subscription.cancel(); await subscription.cancel();
if (!done.isCompleted) { if (!done.isCompleted) {
await quit(); await quit();
......
...@@ -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 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
...@@ -21,8 +19,8 @@ import '../src/context.dart'; ...@@ -21,8 +19,8 @@ import '../src/context.dart';
import '../src/test_flutter_command_runner.dart'; import '../src/test_flutter_command_runner.dart';
void main() { void main() {
Directory tempDir; late Directory tempDir;
Directory projectDir; late Directory projectDir;
setUpAll(() async { setUpAll(() async {
Cache.disableLocking(); Cache.disableLocking();
...@@ -195,8 +193,8 @@ Future<void> _createProject(Directory dir, List<String> createArgs) async { ...@@ -195,8 +193,8 @@ Future<void> _createProject(Directory dir, List<String> createArgs) async {
Future<void> _addDependency( Future<void> _addDependency(
Directory projectDir, Directory projectDir,
String package, { String package, {
String version, String? version,
String path, String? path,
}) async { }) async {
assert(version != null || path != null, assert(version != null || path != null,
'Need to define a source for the package.'); 'Need to define a source for the package.');
...@@ -249,7 +247,7 @@ Future<void> _analyzeEntity(FileSystemEntity target) async { ...@@ -249,7 +247,7 @@ Future<void> _analyzeEntity(FileSystemEntity target) async {
]; ];
final ProcessResult exec = await Process.run( final ProcessResult exec = await Process.run(
globals.artifacts.getHostArtifact(HostArtifact.engineDartBinary).path, globals.artifacts!.getHostArtifact(HostArtifact.engineDartBinary).path,
args, args,
workingDirectory: target is Directory ? target.path : target.dirname, workingDirectory: target is Directory ? target.path : target.dirname,
); );
...@@ -277,7 +275,7 @@ Future<void> _buildWebProject(Directory workingDir) async { ...@@ -277,7 +275,7 @@ Future<void> _buildWebProject(Directory workingDir) async {
]; ];
final ProcessResult exec = await Process.run( final ProcessResult exec = await Process.run(
globals.artifacts.getHostArtifact(HostArtifact.engineDartBinary).path, globals.artifacts!.getHostArtifact(HostArtifact.engineDartBinary).path,
args, args,
workingDirectory: workingDir.path, workingDirectory: workingDir.path,
); );
......
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