diff --git a/packages/flutter_tools/lib/src/build_system/targets/assets.dart b/packages/flutter_tools/lib/src/build_system/targets/assets.dart index f6bd39660fbb..a9e186b19a7d 100644 --- a/packages/flutter_tools/lib/src/build_system/targets/assets.dart +++ b/packages/flutter_tools/lib/src/build_system/targets/assets.dart @@ -210,10 +210,10 @@ DevFSContent? processSkSLBundle(String? bundlePath, { } // Step 2: validate top level bundle structure. - Map? bundle; + Map? bundle; try { final Object? rawBundle = json.decode(skSLBundleFile.readAsStringSync()); - if (rawBundle is Map) { + if (rawBundle is Map) { bundle = rawBundle; } else { logger.printError('"$bundle" was not a JSON object: $rawBundle'); diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart index 6d4db333cef3..dd80b1e46e11 100644 --- a/packages/flutter_tools/lib/src/cache.dart +++ b/packages/flutter_tools/lib/src/cache.dart @@ -389,10 +389,10 @@ class Cache { throw Exception('Could not find file at $versionFilePath'); } final dynamic data = jsonDecode(versionFile.readAsStringSync()); - if (data is! Map) { - throw Exception("Expected object of type 'Map' but got one of type '${data.runtimeType}'"); + if (data is! Map) { + throw Exception("Expected object of type 'Map' but got one of type '${data.runtimeType}'"); } - final dynamic version = data['version']; + final Object? version = data['version']; if (version == null) { throw Exception('Could not parse DevTools version from $version'); } diff --git a/packages/flutter_tools/lib/src/commands/create_base.dart b/packages/flutter_tools/lib/src/commands/create_base.dart index d4e2c7a29624..9d272b786ae3 100644 --- a/packages/flutter_tools/lib/src/commands/create_base.dart +++ b/packages/flutter_tools/lib/src/commands/create_base.dart @@ -668,11 +668,11 @@ abstract class CreateBase extends FlutterCommand { 'templates', 'template_manifest.json', ); - final Map manifest = json.decode( + final Map manifest = json.decode( globals.fs.file(manifestPath).readAsStringSync(), - ) as Map; + ) as Map; return Set.from( - (manifest['files']! as List).cast().map( + (manifest['files']! as List).cast().map( (String path) => Uri.file(globals.fs.path.join(flutterToolsAbsolutePath, path))), ); diff --git a/packages/flutter_tools/lib/src/macos/application_package.dart b/packages/flutter_tools/lib/src/macos/application_package.dart index 691a7f345093..54228ce374e4 100644 --- a/packages/flutter_tools/lib/src/macos/application_package.dart +++ b/packages/flutter_tools/lib/src/macos/application_package.dart @@ -86,8 +86,8 @@ abstract class MacOSApp extends ApplicationPackage { return null; } final Map propertyValues = globals.plistParser.parseFile(plistPath); - final String id = propertyValues[PlistParser.kCFBundleIdentifierKey] as String; - final String executableName = propertyValues[PlistParser.kCFBundleExecutable] as String; + final String? id = propertyValues[PlistParser.kCFBundleIdentifierKey] as String?; + final String? executableName = propertyValues[PlistParser.kCFBundleExecutable] as String?; if (id == null) { globals.printError('Invalid prebuilt macOS app. Info.plist does not contain bundle identifier'); return null; diff --git a/packages/flutter_tools/lib/src/runner/flutter_command.dart b/packages/flutter_tools/lib/src/runner/flutter_command.dart index e53335fd1665..f48d0840abad 100644 --- a/packages/flutter_tools/lib/src/runner/flutter_command.dart +++ b/packages/flutter_tools/lib/src/runner/flutter_command.dart @@ -1534,7 +1534,7 @@ abstract class FlutterCommand extends Command { if (!argParser.options.containsKey(name)) { return null; } - return argResults![name] as String; + return argResults![name] as String?; } /// Gets the parsed command-line option named [name] as an `int`. diff --git a/packages/flutter_tools/lib/src/test/coverage_collector.dart b/packages/flutter_tools/lib/src/test/coverage_collector.dart index 2402cb59fa82..62ad1f609dd3 100644 --- a/packages/flutter_tools/lib/src/test/coverage_collector.dart +++ b/packages/flutter_tools/lib/src/test/coverage_collector.dart @@ -117,7 +117,7 @@ class CoverageCollector extends TestWatcher { ); final Future collectionComplete = testDevice.observatoryUri - .then((Uri observatoryUri) { + .then((Uri? observatoryUri) { _logMessage('collecting coverage data from $testDevice at $observatoryUri...'); return collect(observatoryUri, libraryNames) .then((Map result) { diff --git a/packages/flutter_tools/lib/src/test/flutter_platform.dart b/packages/flutter_tools/lib/src/test/flutter_platform.dart index 60d0cc0584b7..7734ff48c41d 100644 --- a/packages/flutter_tools/lib/src/test/flutter_platform.dart +++ b/packages/flutter_tools/lib/src/test/flutter_platform.dart @@ -494,7 +494,7 @@ class FlutterPlatform extends PlatformPlugin { await Future.any(>[ testDevice.finished, () async { - final Uri processObservatoryUri = await testDevice.observatoryUri; + final Uri? processObservatoryUri = await testDevice.observatoryUri; if (processObservatoryUri != null) { globals.printTrace('test $ourTestCount: Observatory uri is available at $processObservatoryUri'); } else { diff --git a/packages/flutter_tools/lib/src/test/flutter_tester_device.dart b/packages/flutter_tools/lib/src/test/flutter_tester_device.dart index 5d239fb2bc68..1a243ba5efae 100644 --- a/packages/flutter_tools/lib/src/test/flutter_tester_device.dart +++ b/packages/flutter_tools/lib/src/test/flutter_tester_device.dart @@ -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(!debuggingOptions.startPaused || enableObservatory), _gotProcessObservatoryUri = enableObservatory - // ignore: null_argument_to_non_null_type - ? Completer() : (Completer()..complete()), + ? Completer() : (Completer()..complete()), _operatingSystemUtils = OperatingSystemUtils( fileSystem: fileSystem, logger: logger, @@ -73,7 +72,7 @@ class FlutterTesterTestDevice extends TestDevice { final CompileExpression? compileExpression; final FontConfigManager fontConfigManager; - final Completer _gotProcessObservatoryUri; + final Completer _gotProcessObservatoryUri; final Completer _exitCode = Completer(); Process? _process; @@ -209,7 +208,7 @@ class FlutterTesterTestDevice extends TestDevice { } @override - Future get observatoryUri { + Future get observatoryUri { assert(_gotProcessObservatoryUri != null); return _gotProcessObservatoryUri.future; } diff --git a/packages/flutter_tools/lib/src/test/test_compiler.dart b/packages/flutter_tools/lib/src/test/test_compiler.dart index 8f9d4ea8dae2..7b119fd90233 100644 --- a/packages/flutter_tools/lib/src/test/test_compiler.dart +++ b/packages/flutter_tools/lib/src/test/test_compiler.dart @@ -79,7 +79,7 @@ class TestCompiler { late File outputDill; Future compile(Uri mainDart) { - final Completer completer = Completer(); + final Completer completer = Completer(); if (compilerController.isClosed) { return Future.value(); } @@ -175,7 +175,7 @@ class TestCompiler { // compiler to avoid reusing compiler that might have gotten into // a weird state. if (outputPath == null || compilerOutput!.errorCount > 0) { - request.result.complete(null); + request.result.complete(); await _shutdown(); } else { if (shouldCopyDillFile) { diff --git a/packages/flutter_tools/lib/src/test/test_device.dart b/packages/flutter_tools/lib/src/test/test_device.dart index 42774c299312..28ff3641691b 100644 --- a/packages/flutter_tools/lib/src/test/test_device.dart +++ b/packages/flutter_tools/lib/src/test/test_device.dart @@ -22,7 +22,7 @@ abstract class TestDevice { Future> start(String entrypointPath); /// Should complete with null if the observatory is not enabled. - Future get observatoryUri; + Future get observatoryUri; /// Terminates the test device. Future kill(); diff --git a/packages/flutter_tools/test/general.shard/analytics_test.dart b/packages/flutter_tools/test/general.shard/analytics_test.dart index 75266cd66a82..6afe65dd16f6 100644 --- a/packages/flutter_tools/test/general.shard/analytics_test.dart +++ b/packages/flutter_tools/test/general.shard/analytics_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:args/command_runner.dart'; import 'package:file/memory.dart'; import 'package:flutter_tools/src/android/android_workflow.dart'; @@ -37,8 +35,8 @@ void main() { }); group('analytics', () { - Directory tempDir; - Config testConfig; + late Directory tempDir; + late Config testConfig; setUp(() { Cache.flutterRoot = '../..'; @@ -108,7 +106,7 @@ void main() { }); 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); usage.sendCommand('test'); @@ -126,9 +124,9 @@ void main() { }); testUsingContext('Usage records multiple features in experiment setting', () async { - testConfig.setValue(flutterWebFeature.configSetting, true); - testConfig.setValue(flutterLinuxDesktopFeature.configSetting, true); - testConfig.setValue(flutterMacOSDesktopFeature.configSetting, true); + testConfig.setValue(flutterWebFeature.configSetting!, true); + testConfig.setValue(flutterLinuxDesktopFeature.configSetting!, true); + testConfig.setValue(flutterMacOSDesktopFeature.configSetting!, true); final Usage usage = Usage(runningOnBot: true); usage.sendCommand('test'); @@ -150,11 +148,11 @@ void main() { }); group('analytics with fakes', () { - MemoryFileSystem memoryFileSystem; - FakeStdio fakeStdio; - TestUsage testUsage; - FakeClock fakeClock; - FakeDoctor doctor; + late MemoryFileSystem memoryFileSystem; + late FakeStdio fakeStdio; + late TestUsage testUsage; + late FakeClock fakeClock; + late FakeDoctor doctor; setUp(() { memoryFileSystem = MemoryFileSystem.test(); @@ -211,7 +209,7 @@ void main() { testUsingContext('compound command usage path', () async { 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'); }, overrides: { @@ -280,7 +278,7 @@ void main() { }); group('analytics bots', () { - Directory tempDir; + late Directory tempDir; setUp(() { tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_analytics_bots_test.'); @@ -341,8 +339,8 @@ Analytics throwingAnalyticsIOFactory( String trackingId, String applicationName, String applicationVersion, { - String analyticsUrl, - Directory documentDirectory, + String? analyticsUrl, + Directory? documentDirectory, }) { throw const FileSystemException('Could not create file'); } @@ -368,9 +366,9 @@ class FakeDoctor extends Fake implements Doctor { bool androidLicenses = false, bool verbose = true, bool showColor = true, - AndroidLicenseValidator androidLicenseValidator, + AndroidLicenseValidator? androidLicenseValidator, bool showPii = true, - List startedValidatorTasks, + List? startedValidatorTasks, bool sendEvent = true, }) async { return diagnoseSucceeds; diff --git a/packages/flutter_tools/test/general.shard/android/android_gradle_builder_test.dart b/packages/flutter_tools/test/general.shard/android/android_gradle_builder_test.dart index 37246c9362b4..e9be1046f0c6 100644 --- a/packages/flutter_tools/test/general.shard/android/android_gradle_builder_test.dart +++ b/packages/flutter_tools/test/general.shard/android/android_gradle_builder_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:archive/archive.dart'; import 'package:file/memory.dart'; import 'package:file_testing/file_testing.dart'; @@ -27,10 +25,10 @@ import '../../src/fake_process_manager.dart'; void main() { group('gradle build', () { - BufferLogger logger; - TestUsage testUsage; - FileSystem fileSystem; - FakeProcessManager processManager; + late BufferLogger logger; + late TestUsage testUsage; + late FileSystem fileSystem; + late FakeProcessManager processManager; setUp(() { processManager = FakeProcessManager.empty(); @@ -99,10 +97,10 @@ void main() { return line.contains('Some gradle message'); }, handler: ({ - String line, - FlutterProject project, - bool usesAndroidX, - bool multidexEnabled + String? line, + FlutterProject? project, + bool? usesAndroidX, + bool? multidexEnabled }) async { handlerCalled = true; return GradleBuildStatus.exit; @@ -263,10 +261,10 @@ void main() { return false; }, handler: ({ - String line, - FlutterProject project, - bool usesAndroidX, - bool multidexEnabled + String? line, + FlutterProject? project, + bool? usesAndroidX, + bool? multidexEnabled }) async { return GradleBuildStatus.retry; }, @@ -351,10 +349,10 @@ void main() { return line.contains('Some gradle message'); }, handler: ({ - String line, - FlutterProject project, - bool usesAndroidX, - bool multidexEnabled + String? line, + FlutterProject? project, + bool? usesAndroidX, + bool? multidexEnabled }) async { handlerCalled = true; return GradleBuildStatus.exit; @@ -517,10 +515,10 @@ void main() { return line.contains('Some gradle message'); }, handler: ({ - String line, - FlutterProject project, - bool usesAndroidX, - bool multidexEnabled + String? line, + FlutterProject? project, + bool? usesAndroidX, + bool? multidexEnabled }) async { return GradleBuildStatus.retry; }, @@ -595,7 +593,7 @@ void main() { .childDirectory('flutter-apk') .childFile('app-release.apk') ..createSync(recursive: true) - ..writeAsBytesSync(ZipEncoder().encode(archive)); + ..writeAsBytesSync(ZipEncoder().encode(archive)!); fileSystem.file('foo/snapshot.arm64-v8a.json') ..createSync(recursive: true) diff --git a/packages/flutter_tools/test/general.shard/android/android_sdk_test.dart b/packages/flutter_tools/test/general.shard/android/android_sdk_test.dart index 35bcda4a76ec..95e75fc20390 100644 --- a/packages/flutter_tools/test/general.shard/android/android_sdk_test.dart +++ b/packages/flutter_tools/test/general.shard/android/android_sdk_test.dart @@ -2,23 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/memory.dart'; import 'package:flutter_tools/src/android/android_sdk.dart'; import 'package:flutter_tools/src/base/config.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/globals.dart' as globals; -import 'package:meta/meta.dart'; import '../../src/common.dart'; import '../../src/context.dart'; void main() { - MemoryFileSystem fileSystem; - FakeProcessManager processManager; - Config config; + late MemoryFileSystem fileSystem; + late FakeProcessManager processManager; + late Config config; setUp(() { fileSystem = MemoryFileSystem.test(); @@ -27,22 +24,22 @@ void main() { }); group('AndroidSdk', () { - Directory sdkDir; + Directory? sdkDir; tearDown(() { if (sdkDir != null) { - tryToDelete(sdkDir); + tryToDelete(sdkDir!); sdkDir = null; } }); testUsingContext('parse sdk', () { sdkDir = createSdkDirectory(fileSystem: fileSystem); - config.setValue('android-sdk', sdkDir.path); + config.setValue('android-sdk', sdkDir!.path); - final AndroidSdk sdk = AndroidSdk.locateAndroidSdk(); + final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!; expect(sdk.latestVersion, isNotNull); - expect(sdk.latestVersion.sdkLevel, 23); + expect(sdk.latestVersion!.sdkLevel, 23); }, overrides: { FileSystem: () => fileSystem, ProcessManager: () => FakeProcessManager.any(), @@ -51,11 +48,11 @@ void main() { testUsingContext('parse sdk N', () { sdkDir = createSdkDirectory(withAndroidN: true, fileSystem: fileSystem); - config.setValue('android-sdk', sdkDir.path); + config.setValue('android-sdk', sdkDir!.path); - final AndroidSdk sdk = AndroidSdk.locateAndroidSdk(); + final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!; expect(sdk.latestVersion, isNotNull); - expect(sdk.latestVersion.sdkLevel, 24); + expect(sdk.latestVersion!.sdkLevel, 24); }, overrides: { FileSystem: () => fileSystem, ProcessManager: () => FakeProcessManager.any(), @@ -64,9 +61,9 @@ void main() { testUsingContext('returns sdkmanager path under cmdline tools on Linux/macOS', () { sdkDir = createSdkDirectory(fileSystem: fileSystem); - config.setValue('android-sdk', sdkDir.path); + config.setValue('android-sdk', sdkDir!.path); - final AndroidSdk sdk = AndroidSdk.locateAndroidSdk(); + final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!; fileSystem.file( fileSystem.path.join(sdk.directory.path, 'cmdline-tools', 'latest', 'bin', 'sdkmanager') ).createSync(recursive: true); @@ -81,9 +78,9 @@ void main() { testUsingContext('returns sdkmanager path under cmdline tools (highest version) on Linux/macOS', () { sdkDir = createSdkDirectory(fileSystem: fileSystem, withSdkManager: false); - config.setValue('android-sdk', sdkDir.path); + config.setValue('android-sdk', sdkDir!.path); - final AndroidSdk sdk = AndroidSdk.locateAndroidSdk(); + final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!; final List versions = ['3.0', '2.1', '1.0']; for (final String version in versions) { fileSystem.file( @@ -101,9 +98,9 @@ void main() { testUsingContext('Does not return sdkmanager under deprecated tools component', () { sdkDir = createSdkDirectory(fileSystem: fileSystem, withSdkManager: false); - config.setValue('android-sdk', sdkDir.path); + config.setValue('android-sdk', sdkDir!.path); - final AndroidSdk sdk = AndroidSdk.locateAndroidSdk(); + final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!; fileSystem.file( fileSystem.path.join(sdk.directory.path, 'tools/bin/sdkmanager') ).createSync(recursive: true); @@ -118,14 +115,14 @@ void main() { testUsingContext('Can look up cmdline tool from deprecated tools path', () { sdkDir = createSdkDirectory(fileSystem: fileSystem, withSdkManager: false); - config.setValue('android-sdk', sdkDir.path); + config.setValue('android-sdk', sdkDir!.path); - final AndroidSdk sdk = AndroidSdk.locateAndroidSdk(); + final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!; fileSystem.file( fileSystem.path.join(sdk.directory.path, 'tools/bin/foo') ).createSync(recursive: true); - expect(sdk.getCmdlineToolsPath('foo', skipOldTools: false), '/.tmp_rand0/flutter_mock_android_sdk.rand0/tools/bin/foo'); + expect(sdk.getCmdlineToolsPath('foo'), '/.tmp_rand0/flutter_mock_android_sdk.rand0/tools/bin/foo'); }, overrides: { FileSystem: () => fileSystem, ProcessManager: () => FakeProcessManager.any(), @@ -135,9 +132,9 @@ void main() { testUsingContext('Caches adb location after first access', () { sdkDir = createSdkDirectory(fileSystem: fileSystem); - config.setValue('android-sdk', sdkDir.path); + config.setValue('android-sdk', sdkDir!.path); - final AndroidSdk sdk = AndroidSdk.locateAndroidSdk(); + final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!; final File adbFile = fileSystem.file( fileSystem.path.join(sdk.directory.path, 'cmdline-tools', 'adb.exe') )..createSync(recursive: true); @@ -156,9 +153,9 @@ void main() { testUsingContext('returns sdkmanager.bat path under cmdline tools for windows', () { sdkDir = createSdkDirectory(fileSystem: fileSystem); - config.setValue('android-sdk', sdkDir.path); + config.setValue('android-sdk', sdkDir!.path); - final AndroidSdk sdk = AndroidSdk.locateAndroidSdk(); + final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!; fileSystem.file( fileSystem.path.join(sdk.directory.path, 'cmdline-tools', 'latest', 'bin', 'sdkmanager.bat') ).createSync(recursive: true); @@ -174,7 +171,7 @@ void main() { testUsingContext('returns sdkmanager version', () { sdkDir = createSdkDirectory(fileSystem: fileSystem); - config.setValue('android-sdk', sdkDir.path); + config.setValue('android-sdk', sdkDir!.path); processManager.addCommand( const FakeCommand( command: [ @@ -184,7 +181,7 @@ void main() { stdout: '26.1.1\n', ), ); - final AndroidSdk sdk = AndroidSdk.locateAndroidSdk(); + final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!; expect(sdk.sdkManagerVersion, '26.1.1'); }, overrides: { @@ -202,8 +199,8 @@ void main() { '/.tmp_rand0/flutter_mock_android_sdk.rand0/cmdline-tools/latest/bin/sdkmanager', '--version', ])); - config.setValue('android-sdk', sdkDir.path); - final AndroidSdk sdk = AndroidSdk.locateAndroidSdk(); + config.setValue('android-sdk', sdkDir!.path); + final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!; final List validationIssues = sdk.validateSdkWellFormed(); expect(validationIssues.first, 'No valid Android SDK platforms found in' @@ -219,7 +216,7 @@ void main() { testUsingContext('does not throw on sdkmanager version check failure', () { sdkDir = createSdkDirectory(fileSystem: fileSystem); - config.setValue('android-sdk', sdkDir.path); + config.setValue('android-sdk', sdkDir!.path); processManager.addCommand( const FakeCommand( command: [ @@ -232,7 +229,7 @@ void main() { ), ); - final AndroidSdk sdk = AndroidSdk.locateAndroidSdk(); + final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!; expect(sdk.sdkManagerVersion, isNull); }, overrides: { @@ -244,11 +241,11 @@ void main() { testUsingContext('throws on sdkmanager version check if sdkmanager not found', () { sdkDir = createSdkDirectory(withSdkManager: false, fileSystem: fileSystem); - config.setValue('android-sdk', sdkDir.path); + config.setValue('android-sdk', sdkDir!.path); processManager.excludedExecutables.add('/.tmp_rand0/flutter_mock_android_sdk.rand0/cmdline-tools/latest/bin/sdkmanager'); - final AndroidSdk sdk = AndroidSdk.locateAndroidSdk(); + final AndroidSdk? sdk = AndroidSdk.locateAndroidSdk(); - expect(() => sdk.sdkManagerVersion, throwsToolExit()); + expect(() => sdk!.sdkManagerVersion, throwsToolExit()); }, overrides: { FileSystem: () => fileSystem, ProcessManager: () => processManager, @@ -258,9 +255,9 @@ void main() { testUsingContext('returns avdmanager path under cmdline tools', () { sdkDir = createSdkDirectory(fileSystem: fileSystem); - config.setValue('android-sdk', sdkDir.path); + config.setValue('android-sdk', sdkDir!.path); - final AndroidSdk sdk = AndroidSdk.locateAndroidSdk(); + final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!; fileSystem.file( fileSystem.path.join(sdk.directory.path, 'cmdline-tools', 'latest', 'bin', 'avdmanager') ).createSync(recursive: true); @@ -275,9 +272,9 @@ void main() { testUsingContext('returns avdmanager path under cmdline tools on windows', () { sdkDir = createSdkDirectory(fileSystem: fileSystem); - config.setValue('android-sdk', sdkDir.path); + config.setValue('android-sdk', sdkDir!.path); - final AndroidSdk sdk = AndroidSdk.locateAndroidSdk(); + final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!; fileSystem.file( fileSystem.path.join(sdk.directory.path, 'cmdline-tools', 'latest', 'bin', 'avdmanager.bat') ).createSync(recursive: true); @@ -292,9 +289,9 @@ void main() { testUsingContext("returns avdmanager path under tools if cmdline doesn't exist", () { sdkDir = createSdkDirectory(fileSystem: fileSystem); - config.setValue('android-sdk', sdkDir.path); + config.setValue('android-sdk', sdkDir!.path); - final AndroidSdk sdk = AndroidSdk.locateAndroidSdk(); + final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!; fileSystem.file( fileSystem.path.join(sdk.directory.path, 'tools', 'bin', 'avdmanager') ).createSync(recursive: true); @@ -309,9 +306,9 @@ void main() { testUsingContext("returns avdmanager path under tools if cmdline doesn't exist on windows", () { sdkDir = createSdkDirectory(fileSystem: fileSystem); - config.setValue('android-sdk', sdkDir.path); + config.setValue('android-sdk', sdkDir!.path); - final AndroidSdk sdk = AndroidSdk.locateAndroidSdk(); + final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!; fileSystem.file( fileSystem.path.join(sdk.directory.path, 'tools', 'bin', 'avdmanager.bat') ).createSync(recursive: true); @@ -330,7 +327,7 @@ void main() { Directory createBrokenSdkDirectory({ bool withAndroidN = false, bool withSdkManager = true, - @required FileSystem fileSystem, + required FileSystem fileSystem, }) { final Directory dir = fileSystem.systemTempDirectory.createTempSync('flutter_mock_android_sdk.'); _createSdkFile(dir, 'licenses/dummy'); @@ -346,7 +343,7 @@ Directory createBrokenSdkDirectory({ return dir; } -void _createSdkFile(Directory dir, String filePath, { String contents }) { +void _createSdkFile(Directory dir, String filePath, { String? contents }) { final File file = dir.childFile(filePath); file.createSync(recursive: true); if (contents != null) { @@ -359,7 +356,7 @@ Directory createSdkDirectory({ bool withSdkManager = true, bool withPlatformTools = true, bool withBuildTools = true, - @required FileSystem fileSystem, + required FileSystem fileSystem, }) { final Directory dir = fileSystem.systemTempDirectory.createTempSync('flutter_mock_android_sdk.'); final String exe = globals.platform.isWindows ? '.exe' : ''; diff --git a/packages/flutter_tools/test/general.shard/android/android_studio_test.dart b/packages/flutter_tools/test/general.shard/android/android_studio_test.dart index 9673129d2f2c..598eebe66dbd 100644 --- a/packages/flutter_tools/test/general.shard/android/android_studio_test.dart +++ b/packages/flutter_tools/test/general.shard/android/android_studio_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/memory.dart'; import 'package:flutter_tools/src/android/android_studio.dart'; import 'package:flutter_tools/src/base/file_system.dart'; @@ -20,24 +18,24 @@ import '../../src/fake_process_manager.dart'; const String homeLinux = '/home/me'; const String homeMac = '/Users/me'; -const Map macStudioInfoPlist = { +const Map macStudioInfoPlist = { 'CFBundleGetInfoString': 'Android Studio 3.3, build AI-182.5107.16.33.5199772. Copyright JetBrains s.r.o., (c) 2000-2018', 'CFBundleShortVersionString': '3.3', 'CFBundleVersion': 'AI-182.5107.16.33.5199772', - 'JVMOptions': { - 'Properties': { + 'JVMOptions': { + 'Properties': { 'idea.paths.selector': 'AndroidStudio3.3', 'idea.platform.prefix': 'AndroidStudio', }, }, }; -const Map macStudioInfoPlist4_1 = { +const Map macStudioInfoPlist4_1 = { 'CFBundleGetInfoString': 'Android Studio 4.1, build AI-201.8743.12.41.6858069. Copyright JetBrains s.r.o., (c) 2000-2020', 'CFBundleShortVersionString': '4.1', 'CFBundleVersion': 'AI-201.8743.12.41.6858069', - 'JVMOptions': { - 'Properties': { + 'JVMOptions': { + 'Properties': { 'idea.vendor.name' : 'Google', 'idea.paths.selector': 'AndroidStudio4.1', 'idea.platform.prefix': 'AndroidStudio', @@ -45,12 +43,12 @@ const Map macStudioInfoPlist4_1 = { }, }; -const Map macStudioInfoPlist2020_3 = { +const Map macStudioInfoPlist2020_3 = { 'CFBundleGetInfoString': 'Android Studio 2020.3, build AI-203.7717.56.2031.7583922. Copyright JetBrains s.r.o., (c) 2000-2021', 'CFBundleShortVersionString': '2020.3', 'CFBundleVersion': 'AI-203.7717.56.2031.7583922', - 'JVMOptions': { - 'Properties': { + 'JVMOptions': { + 'Properties': { 'idea.vendor.name' : 'Google', 'idea.paths.selector': 'AndroidStudio2020.3', 'idea.platform.prefix': 'AndroidStudio', @@ -58,12 +56,12 @@ const Map macStudioInfoPlist2020_3 = { }, }; -const Map macStudioInfoPlistEAP = { +const Map macStudioInfoPlistEAP = { 'CFBundleGetInfoString': 'Android Studio EAP AI-212.5712.43.2112.8233820, build AI-212.5712.43.2112.8233820. Copyright JetBrains s.r.o., (c) 2000-2022', 'CFBundleShortVersionString': 'EAP AI-212.5712.43.2112.8233820', 'CFBundleVersion': 'AI-212.5712.43.2112.8233820', - 'JVMOptions': { - 'Properties': { + 'JVMOptions': { + 'Properties': { 'idea.vendor.name' : 'Google', 'idea.paths.selector': 'AndroidStudio2021.2', 'idea.platform.prefix': 'AndroidStudio', @@ -90,7 +88,7 @@ Platform macPlatform() { } void main() { - FileSystem fileSystem; + late FileSystem fileSystem; setUp(() { fileSystem = MemoryFileSystem.test(); @@ -105,7 +103,7 @@ void main() { globals.fs.file(homeFile).writeAsStringSync(installPath); final AndroidStudio studio = - AndroidStudio.fromHomeDot(globals.fs.directory(studioHome)); + AndroidStudio.fromHomeDot(globals.fs.directory(studioHome))!; expect(studio, isNotNull); expect(studio.pluginsPath, equals('/home/me/.AndroidStudioWithCheese5.0/config/plugins')); @@ -122,10 +120,10 @@ void main() { }); group('pluginsPath on Mac', () { - FileSystemUtils fsUtils; - Platform platform; - FakePlistUtils plistUtils; - FakeProcessManager processManager; + late FileSystemUtils fsUtils; + late Platform platform; + late FakePlistUtils plistUtils; + late FakeProcessManager processManager; setUp(() { plistUtils = FakePlistUtils(); @@ -157,8 +155,8 @@ void main() { ) ); final AndroidStudio studio = AndroidStudio.fromMacOSBundle( - globals.fs.directory(studioInApplicationPlistFolder)?.parent?.path, - ); + globals.fs.directory(studioInApplicationPlistFolder).parent.path, + )!; expect(studio, isNotNull); expect(studio.pluginsPath, equals(globals.fs.path.join( @@ -199,8 +197,8 @@ void main() { ) ); final AndroidStudio studio = AndroidStudio.fromMacOSBundle( - globals.fs.directory(studioInApplicationPlistFolder)?.parent?.path, - ); + globals.fs.directory(studioInApplicationPlistFolder).parent.path, + )!; expect(studio, isNotNull); expect(studio.pluginsPath, equals(globals.fs.path.join( @@ -241,8 +239,8 @@ void main() { ) ); final AndroidStudio studio = AndroidStudio.fromMacOSBundle( - globals.fs.directory(studioInApplicationPlistFolder)?.parent?.path, - ); + globals.fs.directory(studioInApplicationPlistFolder).parent.path, + )!; expect(studio, isNotNull); expect(studio.pluginsPath, equals(globals.fs.path.join( @@ -282,8 +280,8 @@ void main() { ) ); final AndroidStudio studio = AndroidStudio.fromMacOSBundle( - globals.fs.directory(studioInApplicationPlistFolder)?.parent?.path, - ); + globals.fs.directory(studioInApplicationPlistFolder).parent.path, + )!; expect(studio, isNotNull); expect(studio.pluginsPath, equals(globals.fs.path.join( @@ -313,13 +311,13 @@ void main() { globals.fs.directory(applicationPlistFolder).createSync(recursive: true); final String applicationsPlistFilePath = globals.fs.path.join(applicationPlistFolder, 'Info.plist'); - const Map jetbrainsInfoPlist = { + const Map jetbrainsInfoPlist = { 'JetBrainsToolboxApp': 'ignored', }; plistUtils.fileContents[applicationsPlistFilePath] = jetbrainsInfoPlist; final String homeDirectoryPlistFolder = globals.fs.path.join( - globals.fsUtils.homeDirPath, + globals.fsUtils.homeDirPath!, 'Applications', 'Android Studio.app', 'Contents', @@ -438,7 +436,7 @@ void main() { plistUtils.fileContents[applicationsPlistFilePath] = macStudioInfoPlist; final String homeDirectoryPlistFolder = globals.fs.path.join( - globals.fsUtils.homeDirPath, + globals.fsUtils.homeDirPath!, 'Applications', 'Android Studio.app', 'Contents', @@ -449,7 +447,7 @@ void main() { plistUtils.fileContents[homeDirectoryPlistFilePath] = macStudioInfoPlist4_1; expect(AndroidStudio.allInstalled().length, 2); - expect(AndroidStudio.latestValid().version, Version(4, 1, 0)); + expect(AndroidStudio.latestValid()!.version, Version(4, 1, 0)); }, overrides: { FileSystem: () => fileSystem, FileSystemUtils: () => fsUtils, @@ -470,8 +468,8 @@ void main() { final String plistFilePath = globals.fs.path.join(studioInApplicationPlistFolder, 'Info.plist'); plistUtils.fileContents[plistFilePath] = macStudioInfoPlist; final AndroidStudio studio = AndroidStudio.fromMacOSBundle( - globals.fs.directory(studioInApplicationPlistFolder)?.parent?.path, - ); + globals.fs.directory(studioInApplicationPlistFolder).parent.path, + )!; expect(studio, isNotNull); expect(studio.pluginsPath, equals(globals.fs.path.join( homeMac, @@ -490,7 +488,7 @@ void main() { }); }); - FileSystem windowsFileSystem; + late FileSystem windowsFileSystem; setUp(() { windowsFileSystem = MemoryFileSystem.test(style: FileSystemStyle.windows); @@ -500,8 +498,7 @@ void main() { windowsFileSystem.file(r'C:\Users\Dash\AppData\Local\Google\AndroidStudio4.1\.home') ..createSync(recursive: true) ..writeAsStringSync(r'C:\Program Files\AndroidStudio'); - windowsFileSystem - .directory(r'C:\Program Files\AndroidStudio') + windowsFileSystem.directory(r'C:\Program Files\AndroidStudio') .createSync(recursive: true); final AndroidStudio studio = AndroidStudio.allInstalled().single; @@ -518,8 +515,7 @@ void main() { windowsFileSystem.file(r'C:\Users\Dash\AppData\Local\Google\AndroidStudio4.2\.home') ..createSync(recursive: true) ..writeAsStringSync(r'C:\Program Files\AndroidStudio'); - windowsFileSystem - .directory(r'C:\Program Files\AndroidStudio') + windowsFileSystem.directory(r'C:\Program Files\AndroidStudio') .createSync(recursive: true); final AndroidStudio studio = AndroidStudio.allInstalled().single; @@ -536,8 +532,7 @@ void main() { windowsFileSystem.file(r'C:\Users\Dash\AppData\Local\Google\AndroidStudio2020.3\.home') ..createSync(recursive: true) ..writeAsStringSync(r'C:\Program Files\AndroidStudio'); - windowsFileSystem - .directory(r'C:\Program Files\AndroidStudio') + windowsFileSystem.directory(r'C:\Program Files\AndroidStudio') .createSync(recursive: true); final AndroidStudio studio = AndroidStudio.allInstalled().single; @@ -554,8 +549,7 @@ void main() { windowsFileSystem.file(r'C:\Users\Dash\AppData\Local\Google\AndroidStudio4.1\.home') ..createSync(recursive: true) ..writeAsStringSync(r'C:\Program Files\AndroidStudio'); - windowsFileSystem - .directory(r'C:\Program Files\AndroidStudio') + windowsFileSystem.directory(r'C:\Program Files\AndroidStudio') .createSync(recursive: true); expect(AndroidStudio.allInstalled(), isEmpty); @@ -572,8 +566,7 @@ void main() { windowsFileSystem.file(r'C:\Users\Dash\AppData\Local\Google\AndroidStudio4.2\.home') ..createSync(recursive: true) ..writeAsStringSync(r'C:\Program Files\AndroidStudio'); - windowsFileSystem - .directory(r'C:\Program Files\AndroidStudio') + windowsFileSystem.directory(r'C:\Program Files\AndroidStudio') .createSync(recursive: true); expect(AndroidStudio.allInstalled(), isEmpty); @@ -590,8 +583,7 @@ void main() { windowsFileSystem.file(r'C:\Users\Dash\AppData\Local\Google\AndroidStudio2020.3\.home') ..createSync(recursive: true) ..writeAsStringSync(r'C:\Program Files\AndroidStudio'); - windowsFileSystem - .directory(r'C:\Program Files\AndroidStudio') + windowsFileSystem.directory(r'C:\Program Files\AndroidStudio') .createSync(recursive: true); expect(AndroidStudio.allInstalled(), isEmpty); @@ -605,7 +597,7 @@ void main() { }); group('Installation detection on Linux', () { - FileSystemUtils fsUtils; + late FileSystemUtils fsUtils; setUp(() { fsUtils = FileSystemUtils( @@ -698,10 +690,10 @@ void main() { } class FakePlistUtils extends Fake implements PlistParser { - final Map> fileContents = >{}; + final Map> fileContents = >{}; @override - Map parseFile(String plistFilePath) { - return fileContents[plistFilePath]; + Map parseFile(String plistFilePath) { + return fileContents[plistFilePath]!; } } diff --git a/packages/flutter_tools/test/general.shard/android/android_studio_validator_test.dart b/packages/flutter_tools/test/general.shard/android/android_studio_validator_test.dart index 975f439fb046..4f5230443560 100644 --- a/packages/flutter_tools/test/general.shard/android/android_studio_validator_test.dart +++ b/packages/flutter_tools/test/general.shard/android/android_studio_validator_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/memory.dart'; import 'package:flutter_tools/src/android/android_studio_validator.dart'; import 'package:flutter_tools/src/base/config.dart'; @@ -24,8 +22,8 @@ final Platform linuxPlatform = FakePlatform( ); void main() { - FileSystem fileSystem; - FakeProcessManager fakeProcessManager; + late FileSystem fileSystem; + late FakeProcessManager fakeProcessManager; setUp(() { fileSystem = MemoryFileSystem.test(); diff --git a/packages/flutter_tools/test/general.shard/android/deferred_components_prebuild_validator_test.dart b/packages/flutter_tools/test/general.shard/android/deferred_components_prebuild_validator_test.dart index e8978f2f54de..1495f244f6cf 100644 --- a/packages/flutter_tools/test/general.shard/android/deferred_components_prebuild_validator_test.dart +++ b/packages/flutter_tools/test/general.shard/android/deferred_components_prebuild_validator_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/memory.dart'; import 'package:flutter_tools/src/android/deferred_components_prebuild_validator.dart'; import 'package:flutter_tools/src/android/deferred_components_validator.dart'; @@ -16,11 +14,11 @@ import '../../src/common.dart'; import '../../src/context.dart'; void main() { - FileSystem fileSystem; - BufferLogger logger; - Directory projectDir; - Platform platform; - Directory flutterRootDir; + late FileSystem fileSystem; + late BufferLogger logger; + late Directory projectDir; + late Platform platform; + late Directory flutterRootDir; setUp(() { fileSystem = MemoryFileSystem.test(); diff --git a/packages/flutter_tools/test/general.shard/android/gradle_test.dart b/packages/flutter_tools/test/general.shard/android/gradle_test.dart index 3114249cd0dd..3d9c48abe0c4 100644 --- a/packages/flutter_tools/test/general.shard/android/gradle_test.dart +++ b/packages/flutter_tools/test/general.shard/android/gradle_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/memory.dart'; import 'package:flutter_tools/src/android/android_sdk.dart'; import 'package:flutter_tools/src/android/gradle.dart'; @@ -33,7 +31,7 @@ void main() { Cache.flutterRoot = getFlutterRoot(); group('build artifacts', () { - FileSystem fileSystem; + late FileSystem fileSystem; setUp(() { fileSystem = MemoryFileSystem.test(); @@ -194,8 +192,8 @@ void main() { }); group('Gradle local.properties', () { - Artifacts localEngineArtifacts; - FileSystem fs; + late Artifacts localEngineArtifacts; + late FileSystem fs; setUp(() { fs = MemoryFileSystem.test(); @@ -211,7 +209,7 @@ void main() { }); } - String propertyFor(String key, File file) { + String? propertyFor(String key, File file) { final Iterable result = file.readAsLinesSync() .where((String line) => line.startsWith('$key=')) .map((String line) => line.split('=')[1]); @@ -219,10 +217,10 @@ void main() { } Future checkBuildVersion({ - String manifest, - BuildInfo buildInfo, - String expectedBuildName, - String expectedBuildNumber, + required String manifest, + BuildInfo? buildInfo, + String? expectedBuildName, + String? expectedBuildNumber, }) async { final File manifestFile = globals.fs.file('path/to/project/pubspec.yaml'); manifestFile.createSync(recursive: true); @@ -457,7 +455,7 @@ flutter: }); group('isAppUsingAndroidX', () { - FileSystem fs; + late FileSystem fs; setUp(() { fs = MemoryFileSystem.test(); @@ -503,8 +501,8 @@ flutter: }); group('printHowToConsumeAar', () { - BufferLogger logger; - FileSystem fileSystem; + late BufferLogger logger; + late FileSystem fileSystem; setUp(() { logger = BufferLogger.test(); @@ -694,8 +692,8 @@ flutter: // 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 // 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 legacySettingsDotGradleFiles = globals.fs.file(globals.fs.path.join(Cache.flutterRoot, 'packages','flutter_tools', 'gradle', 'settings.gradle.legacy_versions')); + 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')); expect( legacySettingsDotGradleFiles.readAsStringSync().split(';EOF').map((String body) => body.trim()), contains(templateSettingsDotGradle.readAsStringSync().trim()), diff --git a/packages/flutter_tools/test/general.shard/android/multidex_test.dart b/packages/flutter_tools/test/general.shard/android/multidex_test.dart index 9f7fcb437d3b..11cf20272569 100644 --- a/packages/flutter_tools/test/general.shard/android/multidex_test.dart +++ b/packages/flutter_tools/test/general.shard/android/multidex_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/file.dart'; import 'package:file/memory.dart'; import 'package:flutter_tools/src/android/multidex.dart'; diff --git a/packages/flutter_tools/test/general.shard/asset_bundle_package_fonts_test.dart b/packages/flutter_tools/test/general.shard/asset_bundle_package_fonts_test.dart index a312ea919713..f44cd20a9aab 100644 --- a/packages/flutter_tools/test/general.shard/asset_bundle_package_fonts_test.dart +++ b/packages/flutter_tools/test/general.shard/asset_bundle_package_fonts_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'dart:convert'; import 'package:file/file.dart'; @@ -24,9 +22,9 @@ void main() { // fixed we fix them here. // TODO(dantup): Remove this function once the above issue is fixed and // 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) { fontsSection = ''; } else { @@ -61,14 +59,14 @@ $fontsSection String expectedAssetManifest, ) async { 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 packageFont in packageFonts) { final String entryKey = 'packages/$packageName/$packageFont'; expect(bundle.entries.containsKey(entryKey), true); expect( - utf8.decode(await bundle.entries[entryKey].contentsAsBytes()), + utf8.decode(await bundle.entries[entryKey]!.contentsAsBytes()), packageFont, ); } @@ -76,14 +74,14 @@ $fontsSection for (final String localFont in localFonts) { expect(bundle.entries.containsKey(localFont), true); expect( - utf8.decode(await bundle.entries[localFont].contentsAsBytes()), + utf8.decode(await bundle.entries[localFont]!.contentsAsBytes()), localFont, ); } } expect( - json.decode(utf8.decode(await bundle.entries['FontManifest.json'].contentsAsBytes())), + json.decode(utf8.decode(await bundle.entries['FontManifest.json']!.contentsAsBytes())), json.decode(expectedAssetManifest), ); } @@ -95,7 +93,7 @@ $fontsSection } group('AssetBundle fonts from packages', () { - FileSystem testFileSystem; + FileSystem? testFileSystem; setUp(() async { testFileSystem = MemoryFileSystem( @@ -103,7 +101,7 @@ $fontsSection ? FileSystemStyle.windows : 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 { @@ -112,7 +110,7 @@ $fontsSection writePubspecFile('p/p/pubspec.yaml', 'test_package'); 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.containsKey('FontManifest.json'), isTrue); }, overrides: { diff --git a/packages/flutter_tools/test/general.shard/asset_bundle_package_test.dart b/packages/flutter_tools/test/general.shard/asset_bundle_package_test.dart index a733bd2f5175..dc4d8681d8c4 100644 --- a/packages/flutter_tools/test/general.shard/asset_bundle_package_test.dart +++ b/packages/flutter_tools/test/general.shard/asset_bundle_package_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'dart:convert'; import 'package:file/file.dart'; @@ -24,9 +22,9 @@ void main() { // fixed we fix them here. // TODO(dantup): Remove this function once the above issue is fixed and // rolls into Flutter. - return path?.replaceAll('/', globals.fs.path.separator); + return path.replaceAll('/', globals.fs.path.separator); } - void writePubspecFile(String path, String name, { List assets }) { + void writePubspecFile(String path, String name, { List? assets }) { String assetsSection; if (assets == null) { assetsSection = ''; @@ -65,11 +63,11 @@ $assetsSection Future buildAndVerifyAssets( List assets, List packages, - String expectedAssetManifest, { + String? expectedAssetManifest, { bool expectExists = true, }) async { 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 asset in assets) { @@ -78,7 +76,7 @@ $assetsSection reason: 'Cannot find key on bundle: $entryKey'); if (expectExists) { expect( - utf8.decode(await bundle.entries[entryKey].contentsAsBytes()), + utf8.decode(await bundle.entries[entryKey]!.contentsAsBytes()), asset, ); } @@ -87,7 +85,7 @@ $assetsSection if (expectExists) { expect( - utf8.decode(await bundle.entries['AssetManifest.json'].contentsAsBytes()), + utf8.decode(await bundle.entries['AssetManifest.json']!.contentsAsBytes()), expectedAssetManifest, ); } @@ -103,7 +101,7 @@ $assetsSection } } - FileSystem testFileSystem; + late FileSystem testFileSystem; setUp(() async { testFileSystem = MemoryFileSystem( @@ -121,15 +119,15 @@ $assetsSection writePubspecFile('p/p/pubspec.yaml', 'test_package'); 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 const String expectedAssetManifest = '{}'; expect( - utf8.decode(await bundle.entries['AssetManifest.json'].contentsAsBytes()), + utf8.decode(await bundle.entries['AssetManifest.json']!.contentsAsBytes()), expectedAssetManifest, ); expect( - utf8.decode(await bundle.entries['FontManifest.json'].contentsAsBytes()), + utf8.decode(await bundle.entries['FontManifest.json']!.contentsAsBytes()), '[]', ); }, overrides: { @@ -146,15 +144,15 @@ $assetsSection writeAssets('p/p/', assets); 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 const String expectedAssetManifest = '{}'; expect( - utf8.decode(await bundle.entries['AssetManifest.json'].contentsAsBytes()), + utf8.decode(await bundle.entries['AssetManifest.json']!.contentsAsBytes()), expectedAssetManifest, ); expect( - utf8.decode(await bundle.entries['FontManifest.json'].contentsAsBytes()), + utf8.decode(await bundle.entries['FontManifest.json']!.contentsAsBytes()), '[]', ); }, overrides: { @@ -540,7 +538,7 @@ $assetsSection writeAssets('p/p/', assetsOnDisk); 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, reason: 'Invalid pubspec.yaml should not generate AssetManifest.json' ); diff --git a/packages/flutter_tools/test/general.shard/asset_bundle_test.dart b/packages/flutter_tools/test/general.shard/asset_bundle_test.dart index f467db6215c8..00d0dec4721a 100644 --- a/packages/flutter_tools/test/general.shard/asset_bundle_test.dart +++ b/packages/flutter_tools/test/general.shard/asset_bundle_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'dart:convert'; import 'package:file/file.dart'; @@ -21,7 +19,7 @@ import '../src/context.dart'; void main() { group('AssetBundle.build', () { - FileSystem testFileSystem; + late FileSystem testFileSystem; setUp(() async { testFileSystem = MemoryFileSystem( @@ -47,11 +45,11 @@ void main() { ..writeAsStringSync(''); final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); - await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'); + await bundle.build(packagesPath: '.packages'); expect(bundle.entries.length, 1); const String expectedAssetManifest = '{}'; expect( - utf8.decode(await bundle.entries['AssetManifest.json'].contentsAsBytes()), + utf8.decode(await bundle.entries['AssetManifest.json']!.contentsAsBytes()), expectedAssetManifest, ); }, overrides: { @@ -71,22 +69,22 @@ flutter: - assets/foo/ '''); final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); - await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'); + await bundle.build(packagesPath: '.packages'); // Expected assets: // - asset manifest // - font manifest // - license file // - assets/foo/bar.txt expect(bundle.entries.length, 4); - expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), false); + expect(bundle.needsBuild(), false); // Simulate modifying the files by updating the filestat time manually. globals.fs.file(globals.fs.path.join('assets', 'foo', 'fizz.txt')) ..createSync(recursive: true) ..setLastModifiedSync(packageFile.lastModifiedSync().add(const Duration(hours: 1))); - expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), true); - await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'); + expect(bundle.needsBuild(), true); + await bundle.build(packagesPath: '.packages'); // Expected assets: // - asset manifest // - font manifest @@ -111,14 +109,14 @@ flutter: '''); globals.fs.file('.packages').createSync(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); - await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'); + await bundle.build(packagesPath: '.packages'); // Expected assets: // - asset manifest // - font manifest // - license file // - assets/foo/bar.txt expect(bundle.entries.length, 4); - expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), false); + expect(bundle.needsBuild(), false); // Delete the wildcard directory and update pubspec file. final DateTime modifiedTime = pubspec.lastModifiedSync().add(const Duration(hours: 1)); @@ -136,8 +134,8 @@ name: example''') // Even though the previous file was removed, it is left in the // asset manifest and not updated. This is due to the devfs not // supporting file deletion. - expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), true); - await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'); + expect(bundle.needsBuild(), true); + await bundle.build(packagesPath: '.packages'); // Expected assets: // - asset manifest // - font manifest @@ -165,14 +163,14 @@ flutter: '''); globals.fs.file('.packages').createSync(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); - await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'); + await bundle.build(packagesPath: '.packages'); // Expected assets: // - asset manifest // - font manifest // - license file // - assets/foo/bar.txt expect(bundle.entries.length, 4); - expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), false); + expect(bundle.needsBuild(), false); }, overrides: { FileSystem: () => testFileSystem, ProcessManager: () => FakeProcessManager.any(), @@ -202,7 +200,7 @@ flutter: platform: globals.platform, splitDeferredAssets: true, ).createBundle(); - await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages', deferredComponentsEnabled: true); + await bundle.build(packagesPath: '.packages', deferredComponentsEnabled: true); // Expected assets: // - asset manifest // - font manifest @@ -210,8 +208,8 @@ flutter: // - assets/foo/bar.txt expect(bundle.entries.length, 4); expect(bundle.deferredComponentsEntries.length, 1); - expect(bundle.deferredComponentsEntries['component1'].length, 2); - expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), false); + expect(bundle.deferredComponentsEntries['component1']!.length, 2); + expect(bundle.needsBuild(), false); }, overrides: { FileSystem: () => testFileSystem, ProcessManager: () => FakeProcessManager.any(), @@ -236,7 +234,7 @@ flutter: - assets/wild/ '''); final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); - await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages', deferredComponentsEnabled: false); + await bundle.build(packagesPath: '.packages'); // Expected assets: // - asset manifest // - font manifest @@ -244,7 +242,7 @@ flutter: // - assets/foo/bar.txt expect(bundle.entries.length, 6); expect(bundle.deferredComponentsEntries.isEmpty, true); - expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), false); + expect(bundle.needsBuild(), false); }, overrides: { FileSystem: () => testFileSystem, ProcessManager: () => FakeProcessManager.any(), @@ -274,7 +272,7 @@ flutter: platform: globals.platform, splitDeferredAssets: true, ).createBundle(); - await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages', deferredComponentsEnabled: true); + await bundle.build(packagesPath: '.packages', deferredComponentsEnabled: true); // Expected assets: // - asset manifest // - font manifest @@ -282,20 +280,20 @@ flutter: // - assets/foo/bar.txt expect(bundle.entries.length, 4); expect(bundle.deferredComponentsEntries.length, 1); - expect(bundle.deferredComponentsEntries['component1'].length, 2); - expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), false); + expect(bundle.deferredComponentsEntries['component1']!.length, 2); + expect(bundle.needsBuild(), false); // Simulate modifying the files by updating the filestat time manually. globals.fs.file(globals.fs.path.join('assets', 'wild', 'fizz.txt')) ..createSync(recursive: true) ..setLastModifiedSync(packageFile.lastModifiedSync().add(const Duration(hours: 1))); - expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), true); - await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages', deferredComponentsEnabled: true); + expect(bundle.needsBuild(), true); + await bundle.build(packagesPath: '.packages', deferredComponentsEnabled: true); expect(bundle.entries.length, 4); expect(bundle.deferredComponentsEntries.length, 1); - expect(bundle.deferredComponentsEntries['component1'].length, 3); + expect(bundle.deferredComponentsEntries['component1']!.length, 3); }, overrides: { FileSystem: () => testFileSystem, ProcessManager: () => FakeProcessManager.any(), @@ -327,16 +325,16 @@ assets: - assets/foo/bar.txt '''); final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); - await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'); + await bundle.build(packagesPath: '.packages'); - final DevFSStringContent assetManifest = bundle.entries['AssetManifest.json'] - as DevFSStringContent; - final DevFSStringContent fontManifest = bundle.entries['FontManifest.json'] - as DevFSStringContent; - final DevFSStringContent license = bundle.entries['NOTICES'] - as DevFSStringContent; + final DevFSStringContent? assetManifest = bundle.entries['AssetManifest.json'] + as DevFSStringContent?; + final DevFSStringContent? fontManifest = bundle.entries['FontManifest.json'] + as DevFSStringContent?; + final DevFSStringContent? license = bundle.entries['NOTICES'] + as DevFSStringContent?; - await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'); + await bundle.build(packagesPath: '.packages'); expect(assetManifest, bundle.entries['AssetManifest.json']); expect(fontManifest, bundle.entries['FontManifest.json']); @@ -360,7 +358,7 @@ flutter: '''); final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); - expect(await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'), 0); + expect(await bundle.build(packagesPath: '.packages'), 0); expect(bundle.additionalDependencies.single.path, contains('DOES_NOT_EXIST_RERUN_FOR_WILDCARD')); }, overrides: { FileSystem: () => MemoryFileSystem.test(), @@ -381,7 +379,7 @@ flutter: '''); final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); - expect(await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'), 0); + expect(await bundle.build(packagesPath: '.packages'), 0); expect(bundle.additionalDependencies, isEmpty); }, overrides: { FileSystem: () => MemoryFileSystem.test(), @@ -390,12 +388,12 @@ flutter: group('Shaders: ', () { - MemoryFileSystem fileSystem; - Artifacts artifacts; - String impellerc; - Directory output; - String shaderPath; - String outputPath; + late MemoryFileSystem fileSystem; + late Artifacts artifacts; + late String impellerc; + late Directory output; + late String shaderPath; + late String outputPath; setUp(() { artifacts = Artifacts.test(); @@ -422,7 +420,7 @@ flutter: '''); final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); - expect(await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'), 0); + expect(await bundle.build(packagesPath: '.packages'), 0); await writeBundle(output, bundle.entries, loggerOverride: testLogger); @@ -472,7 +470,7 @@ flutter: final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); globals.fs.file('foo/bar/fizz.txt').createSync(recursive: true); - expect(await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'), 0); + expect(await bundle.build(packagesPath: '.packages'), 0); expect(bundle.additionalDependencies, isEmpty); }, overrides: { FileSystem: () => MemoryFileSystem.test(), @@ -506,16 +504,16 @@ flutter: final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); globals.fs.file('foo/bar/fizz.txt').createSync(recursive: true); - await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'); + await bundle.build(packagesPath: '.packages'); expect(bundle.entries, hasLength(4)); - expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), false); + expect(bundle.needsBuild(), false); // Does not track dependency's wildcard directories. globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt')) .deleteSync(); - expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), false); + expect(bundle.needsBuild(), false); }, overrides: { FileSystem: () => MemoryFileSystem.test(), ProcessManager: () => FakeProcessManager.any(), @@ -548,7 +546,7 @@ flutter: '''); final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); - expect(await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'), 1); + expect(await bundle.build(packagesPath: '.packages'), 1); expect(testLogger.errorText, contains('This asset was included from package foo')); }, overrides: { FileSystem: () => MemoryFileSystem.test(), @@ -571,7 +569,7 @@ flutter: '''); final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); - expect(await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'), 1); + expect(await bundle.build(packagesPath: '.packages'), 1); expect(testLogger.errorText, isNot(contains('This asset was included from'))); }, overrides: { FileSystem: () => MemoryFileSystem.test(), @@ -605,9 +603,9 @@ flutter: '''); final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); - expect(await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'), 0); - expect((bundle.entries['FontManifest.json'] as DevFSStringContent).string, '[]'); - expect((bundle.entries['AssetManifest.json'] as DevFSStringContent).string, '{}'); + expect(await bundle.build(packagesPath: '.packages'), 0); + expect((bundle.entries['FontManifest.json']! as DevFSStringContent).string, '[]'); + expect((bundle.entries['AssetManifest.json']! as DevFSStringContent).string, '{}'); expect(testLogger.errorText, contains( 'package:foo has `uses-material-design: true` set' )); @@ -642,7 +640,7 @@ flutter: final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); - expect(await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'), 0); + expect(await bundle.build(packagesPath: '.packages'), 0); expect(bundle.entries.length, 4); }, overrides: { FileSystem: () => MemoryFileSystem.test(), @@ -676,11 +674,11 @@ flutter: globals.fs.file('assets/zebra.jpg').createSync(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); - expect(await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'), 0); - expect((bundle.entries['FontManifest.json'] as DevFSStringContent).string, '[]'); + expect(await bundle.build(packagesPath: '.packages'), 0); + expect((bundle.entries['FontManifest.json']! as DevFSStringContent).string, '[]'); // The assets from deferred components and regular assets // are both included in alphabetical order - expect((bundle.entries['AssetManifest.json'] as DevFSStringContent).string, '{"assets/apple.jpg":["assets/apple.jpg"],"assets/bar.jpg":["assets/bar.jpg"],"assets/foo.jpg":["assets/foo.jpg"],"assets/zebra.jpg":["assets/zebra.jpg"]}'); + expect((bundle.entries['AssetManifest.json']! as DevFSStringContent).string, '{"assets/apple.jpg":["assets/apple.jpg"],"assets/bar.jpg":["assets/bar.jpg"],"assets/foo.jpg":["assets/foo.jpg"],"assets/zebra.jpg":["assets/zebra.jpg"]}'); }, overrides: { FileSystem: () => MemoryFileSystem.test(), ProcessManager: () => FakeProcessManager.any(), diff --git a/packages/flutter_tools/test/general.shard/asset_bundle_variant_test.dart b/packages/flutter_tools/test/general.shard/asset_bundle_variant_test.dart index 7ae9dd1f4256..5b2546ce29fe 100644 --- a/packages/flutter_tools/test/general.shard/asset_bundle_variant_test.dart +++ b/packages/flutter_tools/test/general.shard/asset_bundle_variant_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'dart:convert'; import 'package:file/file.dart'; @@ -24,11 +22,11 @@ void main() { // fixed we fix them here. // TODO(dantup): Remove this function once the above issue is fixed and // rolls into Flutter. - return path?.replaceAll('/', globals.fs.path.separator); + return path.replaceAll('/', globals.fs.path.separator); } group('AssetBundle asset variants', () { - FileSystem testFileSystem; + late FileSystem testFileSystem; setUp(() async { testFileSystem = MemoryFileSystem( style: globals.platform.isWindows @@ -67,24 +65,24 @@ flutter: } 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. for (final String asset in assets) { 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(); 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 // the /a/b/c/*/foo variants do exist. expect(bundle.entries.containsKey('a/b/c/foo'), false); for (final String asset in assets.skip(1)) { 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: { FileSystem: () => testFileSystem, diff --git a/packages/flutter_tools/test/general.shard/asset_test.dart b/packages/flutter_tools/test/general.shard/asset_test.dart index 0b134558ed75..128457cd8765 100644 --- a/packages/flutter_tools/test/general.shard/asset_test.dart +++ b/packages/flutter_tools/test/general.shard/asset_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:flutter_tools/src/asset.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/cache.dart'; @@ -86,5 +84,5 @@ void main() { } Future getValueAsString(String key, AssetBundle asset) async { - return String.fromCharCodes(await asset.entries[key].contentsAsBytes()); + return String.fromCharCodes(await asset.entries[key]!.contentsAsBytes()); } diff --git a/packages/flutter_tools/test/general.shard/build_system/source_test.dart b/packages/flutter_tools/test/general.shard/build_system/source_test.dart index 182a35b4f669..fc2dab85de22 100644 --- a/packages/flutter_tools/test/general.shard/build_system/source_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/source_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:flutter_tools/src/artifacts.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/platform.dart'; @@ -21,9 +19,9 @@ final Platform windowsPlatform = FakePlatform( ); void main() { - Testbed testbed; - SourceVisitor visitor; - Environment environment; + late Testbed testbed; + late SourceVisitor visitor; + late Environment environment; setUp(() { testbed = Testbed(setup: () { @@ -33,7 +31,7 @@ void main() { environment = Environment.test( globals.fs.currentDirectory, outputDir: outputs, - artifacts: globals.artifacts, // using real artifacts + artifacts: globals.artifacts!, // using real artifacts processManager: FakeProcessManager.any(), fileSystem: globals.fs, // engineVersion being null simulates a local engine. diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/android_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/android_test.dart index cebedb3f6501..427c76e7e32b 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/android_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/android_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/memory.dart'; import 'package:file_testing/file_testing.dart'; import 'package:flutter_tools/src/artifacts.dart'; @@ -21,10 +19,10 @@ import '../../../src/context.dart'; import '../../../src/fake_process_manager.dart'; void main() { - FakeProcessManager processManager; - FileSystem fileSystem; - Artifacts artifacts; - Logger logger; + late FakeProcessManager processManager; + late FileSystem fileSystem; + late Artifacts artifacts; + late Logger logger; setUp(() { logger = BufferLogger.test(); diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/assets_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/assets_test.dart index ed20556a8cbd..97fab5ff49d2 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/assets_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/assets_test.dart @@ -2,8 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - +import 'package:collection/collection.dart' show IterableExtension; import 'package:file/memory.dart'; import 'package:file_testing/file_testing.dart'; import 'package:flutter_tools/src/artifacts.dart'; @@ -21,8 +20,8 @@ import '../../../src/common.dart'; import '../../../src/context.dart'; void main() { - Environment environment; - FileSystem fileSystem; + late Environment environment; + late FileSystem fileSystem; setUp(() { fileSystem = MemoryFileSystem.test(); @@ -75,7 +74,7 @@ flutter: final Depfile dependencies = depfileService.parse(depfile); expect( - dependencies.inputs.firstWhere((File file) => file.path == '/bar/LICENSE', orElse: () => null), + dependencies.inputs.firstWhereOrNull((File file) => file.path == '/bar/LICENSE'), isNotNull, ); }, overrides: { @@ -124,7 +123,6 @@ flutter: targetPlatform: TargetPlatform.android, fileSystem: MemoryFileSystem.test(), logger: BufferLogger.test(), - engineVersion: null, ), isNull); }); @@ -136,7 +134,6 @@ flutter: targetPlatform: TargetPlatform.android, fileSystem: MemoryFileSystem.test(), logger: BufferLogger.test(), - engineVersion: null, ), throwsException); }); @@ -152,7 +149,6 @@ flutter: targetPlatform: TargetPlatform.android, fileSystem: fileSystem, logger: logger, - engineVersion: null, ), throwsException); expect(logger.errorText, contains('was not a JSON object')); }); @@ -169,7 +165,6 @@ flutter: targetPlatform: TargetPlatform.android, fileSystem: fileSystem, logger: logger, - engineVersion: null, ), throwsException); expect(logger.errorText, contains('was not a JSON object')); }); @@ -214,7 +209,7 @@ flutter: fileSystem: fileSystem, logger: logger, engineVersion: '2', - ); + )!; expect(await content.contentsAsBytes(), utf8.encode('{"data":{}}')); expect(logger.errorText, contains('This may lead to less efficient shader caching')); @@ -238,7 +233,7 @@ flutter: fileSystem: fileSystem, logger: logger, engineVersion: '2', - ); + )!; expect(await content.contentsAsBytes(), utf8.encode('{"data":{}}')); expect(logger.errorText, isEmpty); diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/common_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/common_test.dart index 4bed2077fb53..92c2d81631a8 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/common_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/common_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/memory.dart'; import 'package:flutter_tools/src/artifacts.dart'; import 'package:flutter_tools/src/base/file_system.dart'; @@ -26,12 +24,12 @@ const String kAssemblyAot = '--snapshot_kind=app-aot-assembly'; final Platform macPlatform = FakePlatform(operatingSystem: 'macos', environment: {}); void main() { - FakeProcessManager processManager; - Environment androidEnvironment; - Environment iosEnvironment; - Artifacts artifacts; - FileSystem fileSystem; - Logger logger; + late FakeProcessManager processManager; + late Environment androidEnvironment; + late Environment iosEnvironment; + late Artifacts artifacts; + late FileSystem fileSystem; + late Logger logger; setUp(() { processManager = FakeProcessManager.empty(); diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/dart_plugin_registrant_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/dart_plugin_registrant_test.dart index 9ede15b79208..b8cbf288dc25 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/dart_plugin_registrant_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/dart_plugin_registrant_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - // TODO(gspencergoog): Remove this tag once this test's state leaks/test // dependencies have been fixed. // https://github.com/flutter/flutter/issues/85160 diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/deferred_components_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/deferred_components_test.dart index 5964744bc34c..49635687743d 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/deferred_components_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/deferred_components_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/memory.dart'; import 'package:flutter_tools/src/artifacts.dart'; import 'package:flutter_tools/src/base/file_system.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. // Detailed per-check tests are in android/deferred_components_setup_validator_test.dart. void main() { - FileSystem fileSystem; - BufferLogger logger; + late FileSystem fileSystem; + late BufferLogger logger; setUp(() { logger = BufferLogger.test(); @@ -55,9 +53,9 @@ void main() { await validatorTarget.build(environment); // We check the inputs to determine if the task was executed. - expect(validatorTarget.validator.inputs.length, 3); - 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.length, 3); + expect(validatorTarget.validator!.inputs[0].path, 'project/pubspec.yaml'); + expect(validatorTarget.validator!.inputs[1].path, 'project/android/app/src/main/AndroidManifest.xml'); }); testUsingContext('checkAgainstLoadingUnitsCache checks runs', () async { @@ -88,8 +86,8 @@ void main() { await validatorTarget.build(environment); // We check the inputs to determine if the task was executed. - expect(validatorTarget.validator.inputs.length, 3); - expect(validatorTarget.validator.inputs[2].path, 'project/deferred_components_loading_units.yaml'); + expect(validatorTarget.validator!.inputs.length, 3); + expect(validatorTarget.validator!.inputs[2].path, 'project/deferred_components_loading_units.yaml'); }); testUsingContext('writeLoadingUnitsCache task runs', () async { @@ -120,7 +118,7 @@ void main() { await validatorTarget.build(environment); // We check the inputs to determine if the task was executed. - expect(validatorTarget.validator.outputs.length, 1); - expect(validatorTarget.validator.outputs[0].path, 'project/deferred_components_loading_units.yaml'); + expect(validatorTarget.validator!.outputs.length, 1); + expect(validatorTarget.validator!.outputs[0].path, 'project/deferred_components_loading_units.yaml'); }); } diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart index 2603e69425a5..b0674e508272 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/memory.dart'; import 'package:file_testing/file_testing.dart'; import 'package:flutter_tools/src/artifacts.dart'; @@ -39,11 +37,11 @@ const List _kSharedConfig = [ ]; void main() { - Environment environment; - FileSystem fileSystem; - FakeProcessManager processManager; - Artifacts artifacts; - BufferLogger logger; + late Environment environment; + late FileSystem fileSystem; + late FakeProcessManager processManager; + late Artifacts artifacts; + late BufferLogger logger; setUp(() { fileSystem = MemoryFileSystem.test(); @@ -323,13 +321,13 @@ void main() { }); group('copies Flutter.framework', () { - Directory outputDir; - File binary; - FakeCommand copyPhysicalFrameworkCommand; - FakeCommand lipoCommandNonFatResult; - FakeCommand lipoVerifyArm64Command; - FakeCommand bitcodeStripCommand; - FakeCommand adHocCodesignCommand; + late Directory outputDir; + late File binary; + late FakeCommand copyPhysicalFrameworkCommand; + late FakeCommand lipoCommandNonFatResult; + late FakeCommand lipoVerifyArm64Command; + late FakeCommand bitcodeStripCommand; + late FakeCommand adHocCodesignCommand; setUp(() { final FileSystem fileSystem = MemoryFileSystem.test(); diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/linux_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/linux_test.dart index 963c217e9c03..e6b21fc9cd98 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/linux_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/linux_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/memory.dart'; import 'package:file_testing/file_testing.dart'; import 'package:flutter_tools/src/artifacts.dart'; @@ -90,7 +88,8 @@ void main() { }); // Only required for the test below that still depends on the context. - FileSystem fileSystem; + late FileSystem fileSystem; + setUp(() { fileSystem = MemoryFileSystem.test(); }); diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart index 6922195b9c9f..68be86184e94 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/memory.dart'; import 'package:file_testing/file_testing.dart'; import 'package:flutter_tools/src/artifacts.dart'; @@ -19,16 +17,16 @@ import '../../../src/context.dart'; import '../../../src/fake_process_manager.dart'; void main() { - Environment environment; - FileSystem fileSystem; - Artifacts artifacts; - FakeProcessManager processManager; - File binary; - BufferLogger logger; - FakeCommand copyFrameworkCommand; - FakeCommand lipoInfoNonFatCommand; - FakeCommand lipoInfoFatCommand; - FakeCommand lipoVerifyX86_64Command; + late Environment environment; + late FileSystem fileSystem; + late Artifacts artifacts; + late FakeProcessManager processManager; + late File binary; + late BufferLogger logger; + late FakeCommand copyFrameworkCommand; + late FakeCommand lipoInfoNonFatCommand; + late FakeCommand lipoInfoFatCommand; + late FakeCommand lipoVerifyX86_64Command; setUp(() { processManager = FakeProcessManager.empty(); diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/web_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/web_test.dart index 1b1575d8cbc4..38c94045fd69 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/web_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/web_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file_testing/file_testing.dart'; import 'package:flutter_tools/src/artifacts.dart'; import 'package:flutter_tools/src/base/file_system.dart'; @@ -30,9 +28,9 @@ const List kDart2jsLinuxArgs = [ ]; void main() { - Testbed testbed; - Environment environment; - FakeProcessManager processManager; + late Testbed testbed; + late Environment environment; + late FakeProcessManager processManager; final Platform linux = FakePlatform( environment: {}, ); @@ -40,7 +38,7 @@ void main() { operatingSystem: 'windows', environment: {}, ); - DepfileService depfileService; + late DepfileService depfileService; setUp(() { testbed = Testbed(setup: () { diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/windows_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/windows_test.dart index c9c28559caa8..a7d027900d5a 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/windows_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/windows_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/memory.dart'; import 'package:file_testing/file_testing.dart'; import 'package:flutter_tools/src/artifacts.dart'; @@ -120,7 +118,7 @@ void main() { }); // AssetBundleFactory still uses context injection - FileSystem fileSystem; + late FileSystem fileSystem; setUp(() { fileSystem = MemoryFileSystem.test(style: FileSystemStyle.windows); diff --git a/packages/flutter_tools/test/general.shard/bundle_builder_test.dart b/packages/flutter_tools/test/general.shard/bundle_builder_test.dart index 8c5f949b7e15..190400acb580 100644 --- a/packages/flutter_tools/test/general.shard/bundle_builder_test.dart +++ b/packages/flutter_tools/test/general.shard/bundle_builder_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/memory.dart'; import 'package:flutter_tools/src/base/config.dart'; import 'package:flutter_tools/src/base/file_system.dart'; @@ -71,7 +69,7 @@ void main() { final String mainPath = globals.fs.path.join('lib', 'main.dart'); const String assetDirPath = 'example'; const String depfilePath = 'example.d'; - Environment env; + Environment? env; final BuildSystem buildSystem = TestBuildSystem.all( BuildResult(success: true), (Target target, Environment environment) { @@ -104,17 +102,17 @@ void main() { ); expect(env, isNotNull); - expect(env.defines[kBuildMode], 'debug'); - expect(env.defines[kTargetPlatform], 'ios'); - expect(env.defines[kTargetFile], mainPath); - expect(env.defines[kTrackWidgetCreation], 'true'); - expect(env.defines[kExtraFrontEndOptions], 'test1,test2'); - expect(env.defines[kExtraGenSnapshotOptions], 'test3,test4'); - expect(env.defines[kFileSystemRoots], 'test5,test6'); - expect(env.defines[kFileSystemScheme], 'test7'); - expect(env.defines[kDartDefines], encodeDartDefines(['test8', 'test9'])); - expect(env.defines[kIconTreeShakerFlag], 'true'); - expect(env.defines[kDeferredComponents], 'false'); + expect(env!.defines[kBuildMode], 'debug'); + expect(env!.defines[kTargetPlatform], 'ios'); + expect(env!.defines[kTargetFile], mainPath); + expect(env!.defines[kTrackWidgetCreation], 'true'); + expect(env!.defines[kExtraFrontEndOptions], 'test1,test2'); + expect(env!.defines[kExtraGenSnapshotOptions], 'test3,test4'); + expect(env!.defines[kFileSystemRoots], 'test5,test6'); + expect(env!.defines[kFileSystemScheme], 'test7'); + expect(env!.defines[kDartDefines], encodeDartDefines(['test8', 'test9'])); + expect(env!.defines[kIconTreeShakerFlag], 'true'); + expect(env!.defines[kDeferredComponents], 'false'); }, overrides: { FileSystem: () => MemoryFileSystem.test(), ProcessManager: () => FakeProcessManager.any(), diff --git a/packages/flutter_tools/test/general.shard/cache_test.dart b/packages/flutter_tools/test/general.shard/cache_test.dart index 85b46371ad6d..8edda353c712 100644 --- a/packages/flutter_tools/test/general.shard/cache_test.dart +++ b/packages/flutter_tools/test/general.shard/cache_test.dart @@ -2,8 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - +import 'package:collection/collection.dart' show IterableExtension; import 'package:file/file.dart'; import 'package:file/memory.dart'; import 'package:file_testing/file_testing.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/flutter_cache.dart'; import 'package:flutter_tools/src/globals.dart' as globals; -import 'package:meta/meta.dart'; import 'package:test/fake.dart'; import '../src/common.dart'; @@ -41,7 +39,7 @@ const FakeCommand unameCommandForArm64 = FakeCommand( ); void main() { - FakeProcessManager fakeProcessManager; + late FakeProcessManager fakeProcessManager; setUp(() { fakeProcessManager = FakeProcessManager.empty(); @@ -79,7 +77,7 @@ void main() { }); testWithoutContext('should not throw when lock is acquired', () async { - final String oldRoot = Cache.flutterRoot; + final String? oldRoot = Cache.flutterRoot; Cache.flutterRoot = ''; try { final FileSystem fileSystem = MemoryFileSystem.test(); @@ -365,7 +363,7 @@ void main() { final Directory dir = fileSystem.systemTempDirectory .listSync(recursive: true) .whereType() - .singleWhere((Directory directory) => directory.basename == 'bin_dir', orElse: () => null); + .singleWhereOrNull((Directory directory) => directory.basename == 'bin_dir')!; expect(dir, isNotNull); expect(dir.path, artifactDir.childDirectory('bin_dir').path); @@ -458,6 +456,7 @@ void main() { testWithoutContext('FlutterRunnerDebugSymbols downloads Flutter runner debug symbols', () async { final FileSystem fileSystem = MemoryFileSystem.test(); final Cache cache = FakeSecondaryCache() + ..artifactDirectory = fileSystem.currentDirectory ..version = '123456'; final FakeVersionedPackageResolver packageResolver = FakeVersionedPackageResolver(); @@ -974,9 +973,9 @@ void main() { }); group('AndroidMavenArtifacts', () { - MemoryFileSystem memoryFileSystem; - Cache cache; - FakeAndroidSdk fakeAndroidSdk; + MemoryFileSystem? memoryFileSystem; + Cache? cache; + FakeAndroidSdk? fakeAndroidSdk; setUp(() { memoryFileSystem = MemoryFileSystem.test(); @@ -988,25 +987,25 @@ void main() { }); 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); }); 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 = ''; try { - final AndroidMavenArtifacts mavenArtifacts = AndroidMavenArtifacts(cache, platform: FakePlatform()); - expect(await mavenArtifacts.isUpToDate(memoryFileSystem), isFalse); + final AndroidMavenArtifacts mavenArtifacts = AndroidMavenArtifacts(cache!, platform: FakePlatform()); + 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.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(fakeAndroidSdk.reinitialized, true); + expect(await mavenArtifacts.isUpToDate(memoryFileSystem!), isFalse); + expect(fakeAndroidSdk!.reinitialized, true); } finally { Cache.flutterRoot = oldRoot; } @@ -1028,12 +1027,12 @@ void main() { }); testUsingContext('AndroidMavenArtifacts is a no-op if the Android SDK is absent', () async { - final AndroidMavenArtifacts mavenArtifacts = AndroidMavenArtifacts(cache, platform: FakePlatform()); - expect(await mavenArtifacts.isUpToDate(memoryFileSystem), isFalse); + final AndroidMavenArtifacts mavenArtifacts = AndroidMavenArtifacts(cache!, platform: FakePlatform()); + 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: { Cache: () => cache, FileSystem: () => memoryFileSystem, @@ -1046,8 +1045,8 @@ void main() { class FakeCachedArtifact extends EngineCachedArtifact { FakeCachedArtifact({ String stampName = 'STAMP', - @required Cache cache, - DevelopmentArtifact requiredArtifacts, + required Cache cache, + required DevelopmentArtifact requiredArtifacts, this.binaryDirs = const >[], this.licenseDirs = const [], this.packageDirs = const [], @@ -1081,7 +1080,7 @@ class FakeSimpleArtifact extends CachedArtifact { class FakeSecondaryCachedArtifact extends Fake implements CachedArtifact { bool upToDate = false; bool didUpdate = false; - Exception updateException; + Exception? updateException; @override Future isUpToDate(FileSystem fileSystem) async => upToDate; @@ -1089,7 +1088,7 @@ class FakeSecondaryCachedArtifact extends Fake implements CachedArtifact { @override Future update(ArtifactUpdater artifactUpdater, Logger logger, FileSystem fileSystem, OperatingSystemUtils operatingSystemUtils, {bool offline = false}) async { if (updateException != null) { - throw updateException; + throw updateException!; } didUpdate = true; } @@ -1107,10 +1106,10 @@ class FakeIosUsbArtifacts extends Fake implements IosUsbArtifacts { } class FakeSecondaryCache extends Fake implements Cache { - Directory downloadDir; - Directory artifactDirectory; - String version; - void Function(String artifactName, String version) onSetStamp; + Directory? downloadDir; + late Directory artifactDirectory; + String? version; + late void Function(String artifactName, String version) onSetStamp; @override String get storageBaseUrl => 'https://storage.googleapis.com'; @@ -1132,7 +1131,7 @@ class FakeSecondaryCache extends Fake implements Cache { } @override - String getVersionFor(String artifactName) => version; + String? getVersionFor(String artifactName) => version; @override void setStampFor(String artifactName, String version) { @@ -1155,13 +1154,13 @@ class FakePub extends Fake implements Pub { @override Future get({ - PubContext context, - String directory, + PubContext? context, + String? directory, bool skipIfAbsent = false, bool upgrade = false, bool offline = false, bool generateSyntheticPackage = false, - String flutterRootOverride, + String? flutterRootOverride, bool checkUpToDate = false, bool shouldSkipThirdPartyGenerator = true, bool printProgress = true, @@ -1172,19 +1171,15 @@ class FakePub extends Fake implements Pub { class FakeCache extends Cache { FakeCache({ - @required Logger logger, - @required FileSystem fileSystem, - @required Platform platform, - @required OperatingSystemUtils osUtils, + required super.logger, + required super.fileSystem, + required super.platform, + required super.osUtils, }) : super( - logger: logger, - fileSystem: fileSystem, - platform: platform, - osUtils: osUtils, artifacts: [], ); - File stampFile; + late File stampFile; @override File getStampFileFor(String artifactName) { @@ -1202,8 +1197,8 @@ class FakeAndroidSdk extends Fake implements AndroidSdk { } class FakeArtifactUpdater extends Fake implements ArtifactUpdater { - void Function(String, Uri, Directory) onDownloadZipArchive; - void Function(String, Uri, Directory) onDownloadZipTarball; + void Function(String, Uri, Directory)? onDownloadZipArchive; + void Function(String, Uri, Directory)? onDownloadZipTarball; @override Future downloadZippedTarball(String message, Uri url, Directory location) async { diff --git a/packages/flutter_tools/test/general.shard/channel_test.dart b/packages/flutter_tools/test/general.shard/channel_test.dart index ca26708cbb26..847e96543e28 100644 --- a/packages/flutter_tools/test/general.shard/channel_test.dart +++ b/packages/flutter_tools/test/general.shard/channel_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - // TODO(gspencergoog): Remove this tag once this test's state leaks/test // dependencies have been fixed. // https://github.com/flutter/flutter/issues/85160 @@ -24,7 +22,7 @@ import '../src/test_flutter_command_runner.dart'; void main() { group('channel', () { - FakeProcessManager fakeProcessManager; + late FakeProcessManager fakeProcessManager; setUp(() { fakeProcessManager = FakeProcessManager.empty(); @@ -159,7 +157,7 @@ void main() { final Iterable rows = testLogger.statusText .split('\n') .map((String line) => line.trim()) - .where((String line) => line?.isNotEmpty == true) + .where((String line) => line.isNotEmpty == true) .skip(1); // remove `Flutter channels:` line expect(rows, ['beta', 'stable', 'Currently not on an official channel.']); @@ -190,7 +188,7 @@ void main() { final Iterable rows = testLogger.statusText .split('\n') .map((String line) => line.trim()) - .where((String line) => line?.isNotEmpty == true) + .where((String line) => line.isNotEmpty == true) .skip(1); // remove `Flutter channels:` line expect(rows, ['beta', 'stable', 'Currently not on an official channel.']); diff --git a/packages/flutter_tools/test/general.shard/cmake_test.dart b/packages/flutter_tools/test/general.shard/cmake_test.dart index 1ef9bfcefb22..3fe01ca705fe 100644 --- a/packages/flutter_tools/test/general.shard/cmake_test.dart +++ b/packages/flutter_tools/test/general.shard/cmake_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/memory.dart'; import 'package:file_testing/file_testing.dart'; import 'package:flutter_tools/src/base/file_system.dart'; @@ -17,11 +15,11 @@ const String _kTestFlutterRoot = '/flutter'; const String _kTestWindowsFlutterRoot = r'C:\flutter'; void main() { - FileSystem fileSystem; - - ProcessManager processManager; + late FileSystem fileSystem; + late ProcessManager processManager; setUp(() { + processManager = FakeProcessManager.any(); fileSystem = MemoryFileSystem.test(); }); @@ -33,7 +31,7 @@ void main() { ..createSync(recursive: true) ..writeAsStringSync('set(BINARY_NAME "hello")'); - final String name = getCmakeExecutableName(cmakeProject); + final String? name = getCmakeExecutableName(cmakeProject); expect(name, 'hello'); }, overrides: { @@ -45,7 +43,7 @@ void main() { final FlutterProject project = FlutterProject.fromDirectoryTest(fileSystem.currentDirectory); final CmakeBasedProject cmakeProject = _FakeProject.fromFlutter(project); - final String name = getCmakeExecutableName(cmakeProject); + final String? name = getCmakeExecutableName(cmakeProject); expect(name, isNull); }, overrides: { diff --git a/packages/flutter_tools/test/general.shard/cold_test.dart b/packages/flutter_tools/test/general.shard/cold_test.dart index cf19d3b50393..e2b71e00a344 100644 --- a/packages/flutter_tools/test/general.shard/cold_test.dart +++ b/packages/flutter_tools/test/general.shard/cold_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/memory.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.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/tracing.dart'; import 'package:flutter_tools/src/vmservice.dart'; -import 'package:meta/meta.dart'; import 'package:test/fake.dart'; import 'package:vm_service/vm_service.dart'; @@ -68,8 +65,9 @@ void main() { }); group('cold run', () { - MemoryFileSystem memoryFileSystem; - FakePlatform fakePlatform; + late MemoryFileSystem memoryFileSystem; + late FakePlatform fakePlatform; + setUp(() { memoryFileSystem = MemoryFileSystem(); fakePlatform = FakePlatform(environment: {}); @@ -159,7 +157,7 @@ class FakeFlutterDevice extends Fake implements FlutterDevice { int runColdCode = 0; @override - Future runCold({ColdRunner coldRunner, String route}) async { + Future runCold({ColdRunner? coldRunner, String? route}) async { return runColdCode; } @@ -175,10 +173,10 @@ class FakeDevice extends Fake implements Device { bool isSupported() => true; @override - bool supportsHotReload; + bool supportsHotReload = false; @override - bool supportsHotRestart; + bool supportsHotRestart = false; @override Future get sdkNameAndVersion async => 'Android 10'; @@ -199,9 +197,9 @@ class FakeDevice extends Fake implements Device { class TestFlutterDevice extends FlutterDevice { TestFlutterDevice({ - @required Device device, - @required this.exception, - @required ResidentCompiler generator, + required Device device, + required this.exception, + required ResidentCompiler generator, }) : assert(exception != null), super(device, buildInfo: BuildInfo.debug, generator: generator); @@ -210,17 +208,17 @@ class TestFlutterDevice extends FlutterDevice { @override Future connect({ - ReloadSources reloadSources, - Restart restart, - CompileExpression compileExpression, - GetSkSLMethod getSkSLMethod, - PrintStructuredErrorLogMethod printStructuredErrorLogMethod, + ReloadSources? reloadSources, + Restart? restart, + CompileExpression? compileExpression, + GetSkSLMethod? getSkSLMethod, + PrintStructuredErrorLogMethod? printStructuredErrorLogMethod, bool enableDds = true, bool cacheStartupProfile = false, bool disableServiceAuthCodes = false, - int hostVmServicePort, - int ddsPort, - bool ipv6 = false, + int? hostVmServicePort, + int? ddsPort, + bool? ipv6 = false, bool allowExistingDdsInstance = false, }) async { throw exception; @@ -239,10 +237,10 @@ class FakeFlutterVmService extends Fake implements FlutterVmService { } @override - Future flutterAlreadyPaintedFirstUsefulFrame({String isolateId}) async => true; + Future flutterAlreadyPaintedFirstUsefulFrame({String? isolateId}) async => true; @override - Future getTimeline() async { + Future getTimeline() async { return Response.parse({ 'traceEvents': [ { diff --git a/packages/flutter_tools/test/general.shard/coverage_collector_test.dart b/packages/flutter_tools/test/general.shard/coverage_collector_test.dart index e7d06d32a9b8..0e64618778f5 100644 --- a/packages/flutter_tools/test/general.shard/coverage_collector_test.dart +++ b/packages/flutter_tools/test/general.shard/coverage_collector_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:flutter_tools/src/test/coverage_collector.dart'; import 'package:vm_service/vm_service.dart'; @@ -20,11 +18,11 @@ void main() { ), FakeVmServiceRequest( method: 'getVM', - jsonResponse: (VM.parse({}) + jsonResponse: (VM.parse({})! ..isolates = [ IsolateRef.parse({ 'id': '1', - }), + })!, ] ).toJson(), ), @@ -40,10 +38,10 @@ void main() { ], ); - final Map result = await collect( + final Map result = await collect( null, {'foo'}, - connector: (Uri uri) async { + connector: (Uri? uri) async { return fakeVmServiceHost.vmService; }, ); @@ -61,11 +59,11 @@ void main() { ), FakeVmServiceRequest( method: 'getVM', - jsonResponse: (VM.parse({}) + jsonResponse: (VM.parse({})! ..isolates = [ IsolateRef.parse({ 'id': '1', - }), + })!, ] ).toJson(), ), @@ -112,10 +110,10 @@ void main() { ], ); - final Map result = await collect( + final Map result = await collect( null, {'foo'}, - connector: (Uri uri) async { + connector: (Uri? uri) async { return fakeVmServiceHost.vmService; }, ); @@ -148,11 +146,11 @@ void main() { ), FakeVmServiceRequest( method: 'getVM', - jsonResponse: (VM.parse({}) + jsonResponse: (VM.parse({})! ..isolates = [ IsolateRef.parse({ 'id': '1', - }), + })!, ] ).toJson(), ), @@ -229,10 +227,10 @@ void main() { ], ); - final Map result = await collect( + final Map result = await collect( null, null, - connector: (Uri uri) async { + connector: (Uri? uri) async { return fakeVmServiceHost.vmService; }, ); @@ -276,11 +274,11 @@ void main() { ), FakeVmServiceRequest( method: 'getVM', - jsonResponse: (VM.parse({}) + jsonResponse: (VM.parse({})! ..isolates = [ IsolateRef.parse({ 'id': '1', - }), + })!, ] ).toJson(), ), @@ -317,10 +315,10 @@ void main() { ], ); - final Map result = await collect( + final Map result = await collect( null, {'foo'}, - connector: (Uri uri) async { + connector: (Uri? uri) async { return fakeVmServiceHost.vmService; }, ); @@ -353,11 +351,11 @@ void main() { ), FakeVmServiceRequest( method: 'getVM', - jsonResponse: (VM.parse({}) + jsonResponse: (VM.parse({})! ..isolates = [ IsolateRef.parse({ 'id': '1', - }), + })!, ] ).toJson(), ), @@ -393,10 +391,10 @@ void main() { ], ); - final Map result = await collect( + final Map result = await collect( null, null, - connector: (Uri uri) async { + connector: (Uri? uri) async { return fakeVmServiceHost.vmService; }, ); diff --git a/packages/flutter_tools/test/general.shard/create_config_test.dart b/packages/flutter_tools/test/general.shard/create_config_test.dart index bb6069039236..1699de1528d8 100644 --- a/packages/flutter_tools/test/general.shard/create_config_test.dart +++ b/packages/flutter_tools/test/general.shard/create_config_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:flutter_tools/src/commands/create_base.dart'; import '../src/common.dart'; diff --git a/packages/flutter_tools/test/general.shard/custom_devices/custom_device_test.dart b/packages/flutter_tools/test/general.shard/custom_devices/custom_device_test.dart index 34e550abb59b..971eb9f1c85e 100644 --- a/packages/flutter_tools/test/general.shard/custom_devices/custom_device_test.dart +++ b/packages/flutter_tools/test/general.shard/custom_devices/custom_device_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'dart:async'; import 'package:file/file.dart'; @@ -116,9 +114,7 @@ void main() { final CustomDeviceConfig disabledTestConfig = testConfig.copyWith(enabled: false); final CustomDeviceConfig testConfigNonForwarding = testConfig.copyWith( explicitForwardPortCommand: true, - forwardPortCommand: null, explicitForwardPortSuccessRegex: true, - forwardPortSuccessRegex: null, ); testUsingContext('CustomDevice defaults', @@ -339,12 +335,12 @@ void main() { final CustomDevicePortForwarder forwarder = CustomDevicePortForwarder( deviceName: 'testdevicename', - forwardPortCommand: testConfig.forwardPortCommand, - forwardPortSuccessRegex: testConfig.forwardPortSuccessRegex, + forwardPortCommand: testConfig.forwardPortCommand!, + forwardPortSuccessRegex: testConfig.forwardPortSuccessRegex!, logger: BufferLogger.test(), processManager: FakeProcessManager.list([ FakeCommand( - command: testConfig.forwardPortCommand, + command: testConfig.forwardPortCommand!, stdout: testConfigForwardPortSuccessOutput, completer: forwardPortCommandCompleter, ), @@ -373,7 +369,7 @@ void main() { stdout: 'The Dart VM service is listening on http://127.0.0.1:12345/abcd/\n', ), FakeCommand( - command: testConfig.forwardPortCommand, + command: testConfig.forwardPortCommand!, completer: forwardPortCompleter, stdout: testConfigForwardPortSuccessOutput, ), @@ -450,7 +446,7 @@ void main() { command: testConfig.pingCommand, stdout: testConfigPingSuccessOutput ), - FakeCommand(command: testConfig.postBuildCommand), + FakeCommand(command: testConfig.postBuildCommand!), FakeCommand(command: testConfig.uninstallCommand), FakeCommand(command: testConfig.installCommand), FakeCommand( @@ -459,7 +455,7 @@ void main() { stdout: 'The Dart VM service is listening on http://127.0.0.1:12345/abcd/\n', ), FakeCommand( - command: testConfig.forwardPortCommand, + command: testConfig.forwardPortCommand!, completer: forwardPortCompleter, stdout: testConfigForwardPortSuccessOutput, ), @@ -524,7 +520,7 @@ void main() { final FakeProcessManager processManager = FakeProcessManager.list([ FakeCommand( - command: testConfig.screenshotCommand, + command: testConfig.screenshotCommand!, onRun: () => screenshotCommandWasExecuted = true, ), ]); @@ -550,7 +546,7 @@ void main() { final FakeProcessManager processManager = FakeProcessManager.list([ FakeCommand( - command: testConfig.screenshotCommand, + command: testConfig.screenshotCommand!, onRun: () => screenshotCommandWasExecuted = true, ), ]); @@ -560,8 +556,7 @@ void main() { final CustomDevice device = CustomDevice( config: testConfig.copyWith( - explicitScreenshotCommand: true, - screenshotCommand: null + explicitScreenshotCommand: true ), logger: BufferLogger.test(), processManager: processManager @@ -640,14 +635,14 @@ class MyFakeStreamSubscription extends Fake implements StreamSubscription class FakeBundleBuilder extends Fake implements BundleBuilder { @override Future build({ - TargetPlatform platform, - BuildInfo buildInfo, - FlutterProject project, - String mainPath, + TargetPlatform? platform, + BuildInfo? buildInfo, + FlutterProject? project, + String? mainPath, String manifestPath = defaultManifestPath, - String applicationKernelFilePath, - String depfilePath, - String assetDirPath, - @visibleForTesting BuildSystem buildSystem + String? applicationKernelFilePath, + String? depfilePath, + String? assetDirPath, + @visibleForTesting BuildSystem? buildSystem }) async {} } diff --git a/packages/flutter_tools/test/general.shard/dart_plugin_test.dart b/packages/flutter_tools/test/general.shard/dart_plugin_test.dart index 74c1de28bf92..a42d265b45c2 100644 --- a/packages/flutter_tools/test/general.shard/dart_plugin_test.dart +++ b/packages/flutter_tools/test/general.shard/dart_plugin_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/file.dart'; import 'package:file/memory.dart'; import 'package:flutter_tools/src/dart/package_map.dart'; @@ -22,9 +20,9 @@ import '../src/context.dart'; void main() { group('Dart plugin registrant', () { - FileSystem fs; - FakeFlutterProject flutterProject; - FakeFlutterManifest flutterManifest; + late FileSystem fs; + late FakeFlutterProject flutterProject; + late FakeFlutterManifest flutterManifest; setUp(() async { fs = MemoryFileSystem.test(); @@ -1023,35 +1021,35 @@ class FakeFlutterProject extends Fake implements FlutterProject { bool isModule = false; @override - FlutterManifest manifest; + late FlutterManifest manifest; @override - Directory directory; + late Directory directory; @override - File flutterPluginsFile; + late File flutterPluginsFile; @override - File flutterPluginsDependenciesFile; + late File flutterPluginsDependenciesFile; @override - File dartPluginRegistrant; + late File dartPluginRegistrant; @override - IosProject ios; + late IosProject ios; @override - AndroidProject android; + late AndroidProject android; @override - WebProject web; + late WebProject web; @override - MacOSProject macos; + late MacOSProject macos; @override - LinuxProject linux; + late LinuxProject linux; @override - WindowsProject windows; + late WindowsProject windows; } diff --git a/packages/flutter_tools/test/general.shard/devfs_test.dart b/packages/flutter_tools/test/general.shard/devfs_test.dart index 9d1d2401554d..e16c09f5d26f 100644 --- a/packages/flutter_tools/test/general.shard/devfs_test.dart +++ b/packages/flutter_tools/test/general.shard/devfs_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'dart:async'; import 'dart:convert'; import 'dart:io' as io show ProcessSignal, Process; @@ -101,7 +99,6 @@ void main() { final DateTime fiveSecondsAgo = file.statSync().modified.subtract(const Duration(seconds: 5)); expect(content.isModifiedAfter(fiveSecondsAgo), isTrue); expect(content.isModifiedAfter(fiveSecondsAgo), isTrue); - expect(content.isModifiedAfter(null), isTrue); file.writeAsBytesSync([2, 3, 4], flush: true); @@ -186,7 +183,7 @@ void main() { requests: [createDevFSRequest], httpAddress: Uri.parse('http://localhost'), ); - residentCompiler.onRecompile = (Uri mainUri, List invalidatedFiles) async { + residentCompiler.onRecompile = (Uri mainUri, List? invalidatedFiles) async { fileSystem.file('lib/foo.dill') ..createSync(recursive: true) ..writeAsBytesSync([1, 2, 3, 4, 5]); @@ -250,10 +247,10 @@ void main() { ); await devFS.create(); - final DateTime previousCompile = devFS.lastCompiled; + final DateTime? previousCompile = devFS.lastCompiled; final FakeResidentCompiler residentCompiler = FakeResidentCompiler(); - residentCompiler.onRecompile = (Uri mainUri, List invalidatedFiles) async { + residentCompiler.onRecompile = (Uri mainUri, List? invalidatedFiles) async { return const CompilerOutput('lib/foo.dill', 2, []); }; @@ -289,10 +286,10 @@ void main() { ); await devFS.create(); - final DateTime previousCompile = devFS.lastCompiled; + final DateTime? previousCompile = devFS.lastCompiled; final FakeResidentCompiler residentCompiler = FakeResidentCompiler(); - residentCompiler.onRecompile = (Uri mainUri, List invalidatedFiles) async { + residentCompiler.onRecompile = (Uri mainUri, List? invalidatedFiles) async { fileSystem.file('lib/foo.txt.dill').createSync(recursive: true); return const CompilerOutput('lib/foo.txt.dill', 0, []); }; @@ -330,10 +327,10 @@ void main() { ); await devFS.create(); - final DateTime previousCompile = devFS.lastCompiled; + final DateTime? previousCompile = devFS.lastCompiled; final FakeResidentCompiler residentCompiler = FakeResidentCompiler(); - residentCompiler.onRecompile = (Uri mainUri, List invalidatedFiles) async { + residentCompiler.onRecompile = (Uri mainUri, List? invalidatedFiles) async { fileSystem.file('lib/foo.txt.dill').createSync(recursive: true); return const CompilerOutput('lib/foo.txt.dill', 0, []); }; @@ -380,7 +377,7 @@ void main() { await devFS.create(); final FakeResidentCompiler residentCompiler = FakeResidentCompiler(); - residentCompiler.onRecompile = (Uri mainUri, List invalidatedFiles) async { + residentCompiler.onRecompile = (Uri mainUri, List? invalidatedFiles) async { fileSystem.file('example').createSync(); return const CompilerOutput('lib/foo.txt.dill', 0, []); }; @@ -456,7 +453,7 @@ void main() { await devFS.create(); final FakeResidentCompiler residentCompiler = FakeResidentCompiler(); - residentCompiler.onRecompile = (Uri mainUri, List invalidatedFiles) async { + residentCompiler.onRecompile = (Uri mainUri, List? invalidatedFiles) async { fileSystem.file('lib/foo.txt.dill').createSync(recursive: true); return const CompilerOutput('lib/foo.txt.dill', 0, []); }; @@ -506,7 +503,7 @@ void main() { await Future.delayed(const Duration(milliseconds: 5)); } - String boundaryKey; + String? boundaryKey; while(processed < frontendServerStdIn.writes.length) { final List data = frontendServerStdIn.writes[processed]; final String stringData = utf8.decode(data); @@ -581,10 +578,10 @@ void main() { } class FakeResidentCompiler extends Fake implements ResidentCompiler { - Future Function(Uri mainUri, List invalidatedFiles) onRecompile; + Future Function(Uri mainUri, List? invalidatedFiles)? onRecompile; @override - Future recompile(Uri mainUri, List invalidatedFiles, {String outputPath, PackageConfig packageConfig, String projectRootPath, FileSystem fs, bool suppressErrors = false, bool checkDartPluginRegistry = false}) { + Future recompile(Uri mainUri, List? invalidatedFiles, {String? outputPath, PackageConfig? packageConfig, String? projectRootPath, FileSystem? fs, bool suppressErrors = false, bool checkDartPluginRegistry = false}) { return onRecompile?.call(mainUri, invalidatedFiles) ?? Future.value(const CompilerOutput('', 1, [])); } @@ -605,12 +602,12 @@ class LoggingLogger extends BufferLogger { List messages = []; @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); } @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); } @@ -625,7 +622,7 @@ class FakeBundle extends AssetBundle { List get additionalDependencies => []; @override - Future build({String manifestPath = defaultManifestPath, String assetDirPath, String packagesPath, bool deferredComponentsEnabled = false, TargetPlatform targetPlatform}) async { + Future build({String manifestPath = defaultManifestPath, String? assetDirPath, String? packagesPath, bool deferredComponentsEnabled = false, TargetPlatform? targetPlatform}) async { return 0; } @@ -657,7 +654,7 @@ class AnsweringFakeProcessManager implements ProcessManager { final IOSink stdin; @override - bool canRun(dynamic executable, {String workingDirectory}) { + bool canRun(dynamic executable, {String? workingDirectory}) { return true; } @@ -667,17 +664,17 @@ class AnsweringFakeProcessManager implements ProcessManager { } @override - Future run(List command, {String workingDirectory, Map environment, bool includeParentEnvironment = true, bool runInShell = false, Encoding stdoutEncoding = systemEncoding, Encoding stderrEncoding = systemEncoding}) async { + Future run(List command, {String? workingDirectory, Map? environment, bool includeParentEnvironment = true, bool runInShell = false, Encoding? stdoutEncoding = systemEncoding, Encoding? stderrEncoding = systemEncoding}) async { throw UnimplementedError(); } @override - ProcessResult runSync(List command, {String workingDirectory, Map environment, bool includeParentEnvironment = true, bool runInShell = false, Encoding stdoutEncoding = systemEncoding, Encoding stderrEncoding = systemEncoding}) { + ProcessResult runSync(List command, {String? workingDirectory, Map? environment, bool includeParentEnvironment = true, bool runInShell = false, Encoding? stdoutEncoding = systemEncoding, Encoding? stderrEncoding = systemEncoding}) { throw UnimplementedError(); } @override - Future start(List command, {String workingDirectory, Map environment, bool includeParentEnvironment = true, bool runInShell = false, ProcessStartMode mode = ProcessStartMode.normal}) async { + Future start(List command, {String? workingDirectory, Map? environment, bool includeParentEnvironment = true, bool runInShell = false, ProcessStartMode mode = ProcessStartMode.normal}) async { return AnsweringFakeProcess(stdout, stderr, stdin); } } diff --git a/packages/flutter_tools/test/general.shard/devtools_launcher_test.dart b/packages/flutter_tools/test/general.shard/devtools_launcher_test.dart index dfdfc3e63901..94770357bea2 100644 --- a/packages/flutter_tools/test/general.shard/devtools_launcher_test.dart +++ b/packages/flutter_tools/test/general.shard/devtools_launcher_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'dart:async'; import 'package:flutter_tools/src/base/io.dart'; @@ -17,7 +15,7 @@ import '../src/fake_process_manager.dart'; import '../src/fakes.dart'; void main() { - BufferLogger logger; + late BufferLogger logger; Cache.flutterRoot = ''; @@ -44,9 +42,9 @@ void main() { ]), ); - final DevToolsServerAddress address = await launcher.serve(); - expect(address.host, '127.0.0.1'); - expect(address.port, 9100); + final DevToolsServerAddress? address = await launcher.serve(); + expect(address?.host, '127.0.0.1'); + expect(address?.port, 9100); }); testWithoutContext('DevtoolsLauncher does not launch a new DevTools instance if one is already active', () async { @@ -68,14 +66,14 @@ void main() { ]), ); - DevToolsServerAddress address = await launcher.serve(); - expect(address.host, '127.0.0.1'); - expect(address.port, 9100); + DevToolsServerAddress? address = await launcher.serve(); + expect(address?.host, '127.0.0.1'); + expect(address?.port, 9100); // Call `serve` again and verify that the already running server is returned. address = await launcher.serve(); - expect(address.host, '127.0.0.1'); - expect(address.port, 9100); + expect(address?.host, '127.0.0.1'); + expect(address?.port, 9100); }); testWithoutContext('DevtoolsLauncher can launch devtools with a memory profile', () async { diff --git a/packages/flutter_tools/test/general.shard/flutter_platform_test.dart b/packages/flutter_tools/test/general.shard/flutter_platform_test.dart index b0a5674d48b8..68362339c836 100644 --- a/packages/flutter_tools/test/general.shard/flutter_platform_test.dart +++ b/packages/flutter_tools/test/general.shard/flutter_platform_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/memory.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; @@ -17,12 +15,11 @@ import '../src/common.dart'; import '../src/context.dart'; void main() { - FileSystem fileSystem; + late FileSystem fileSystem; setUp(() { fileSystem = MemoryFileSystem.test(); - fileSystem - .file('.dart_tool/package_config.json') + fileSystem.file('.dart_tool/package_config.json') ..createSync(recursive: true) ..writeAsStringSync('{"configVersion":2,"packages":[]}'); }); @@ -80,7 +77,7 @@ void main() { ), ), throwsAssertionError); - FlutterPlatform capturedPlatform; + FlutterPlatform? capturedPlatform; final Map expectedPrecompiledDillFiles = {'Key': 'Value'}; final FlutterPlatform flutterPlatform = installHook( shellPath: 'abc', diff --git a/packages/flutter_tools/test/general.shard/flutter_tester_device_test.dart b/packages/flutter_tools/test/general.shard/flutter_tester_device_test.dart index 4527d9d3eec7..1b07356b70e9 100644 --- a/packages/flutter_tools/test/general.shard/flutter_tester_device_test.dart +++ b/packages/flutter_tools/test/general.shard/flutter_tester_device_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'dart:async'; import 'package:dds/dds.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/test/flutter_tester_device.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:test/fake.dart'; @@ -25,10 +22,10 @@ import '../src/context.dart'; import '../src/fake_process_manager.dart'; void main() { - FakePlatform platform; - FileSystem fileSystem; - FakeProcessManager processManager; - FlutterTesterTestDevice device; + late FakePlatform platform; + late FileSystem fileSystem; + late FakeProcessManager processManager; + late FlutterTesterTestDevice device; setUp(() { fileSystem = MemoryFileSystem.test(); @@ -265,17 +262,14 @@ void main() { /// Uses a mock HttpServer. We don't want to bind random ports in our CI hosts. class TestFlutterTesterDevice extends FlutterTesterTestDevice { TestFlutterTesterDevice({ - @required Platform platform, - @required FileSystem fileSystem, - @required ProcessManager processManager, - @required bool enableObservatory, - @required List dartEntrypointArgs, + required super.platform, + required super.fileSystem, + required super.processManager, + required super.enableObservatory, + required List dartEntrypointArgs, }) : super( id: 999, shellPath: '/', - platform: platform, - fileSystem: fileSystem, - processManager: processManager, logger: BufferLogger.test(), debuggingOptions: DebuggingOptions.enabled( const BuildInfo( @@ -286,7 +280,6 @@ class TestFlutterTesterDevice extends FlutterTesterTestDevice { hostVmServicePort: 1234, dartEntrypointArgs: dartEntrypointArgs, ), - enableObservatory: enableObservatory, machine: false, host: InternetAddress.loopbackIPv6, testAssetDirectory: null, @@ -307,7 +300,7 @@ class TestFlutterTesterDevice extends FlutterTesterTestDevice { } @override - Future bind(InternetAddress host, int port) async => FakeHttpServer(); + Future bind(InternetAddress? host, int port) async => FakeHttpServer(); @override Future> get remoteChannel async => StreamChannelController().foreign; diff --git a/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_pm_test.dart b/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_pm_test.dart index 834e023d5025..2e00ce77530d 100644 --- a/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_pm_test.dart +++ b/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_pm_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/memory.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/fuchsia/fuchsia_pm.dart'; @@ -16,13 +14,12 @@ import '../../src/fake_process_manager.dart'; void main() { group('FuchsiaPM', () { - File pm; - FakeProcessManager fakeProcessManager; - FakeFuchsiaArtifacts fakeFuchsiaArtifacts; + late File pm; + late FakeProcessManager fakeProcessManager; + late FakeFuchsiaArtifacts fakeFuchsiaArtifacts; setUp(() { pm = MemoryFileSystem.test().file('pm'); - fakeFuchsiaArtifacts = FakeFuchsiaArtifacts(pm); fakeProcessManager = FakeProcessManager.empty(); }); diff --git a/packages/flutter_tools/test/general.shard/github_template_test.dart b/packages/flutter_tools/test/general.shard/github_template_test.dart index fe33868e4490..745bec9f15c2 100644 --- a/packages/flutter_tools/test/general.shard/github_template_test.dart +++ b/packages/flutter_tools/test/general.shard/github_template_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/file.dart'; import 'package:file/memory.dart'; import 'package:flutter_tools/src/base/io.dart'; @@ -16,8 +14,9 @@ import '../src/common.dart'; import '../src/context.dart'; void main() { - BufferLogger logger; - FileSystem fs; + late BufferLogger logger; + late FileSystem fs; + setUp(() { logger = BufferLogger.test(); fs = MemoryFileSystem.test(); @@ -144,8 +143,8 @@ void main() { }); group('new issue template URL', () { - StackTrace stackTrace; - Error error; + late StackTrace stackTrace; + late Error error; const String command = 'flutter test'; const String doctorText = ' [✓] Flutter (Channel report'; @@ -220,7 +219,7 @@ project_type: app '''); 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 = ''' ## Command ``` diff --git a/packages/flutter_tools/test/general.shard/integration_test_device_test.dart b/packages/flutter_tools/test/general.shard/integration_test_device_test.dart index f886c5ca328c..a612b3524a58 100644 --- a/packages/flutter_tools/test/general.shard/integration_test_device_test.dart +++ b/packages/flutter_tools/test/general.shard/integration_test_device_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/file.dart'; import 'package:flutter_tools/src/application_package.dart'; import 'package:flutter_tools/src/base/io.dart' as io; @@ -64,8 +62,8 @@ final FakeVmServiceRequest listViewsRequest = FakeVmServiceRequest( final Uri observatoryUri = Uri.parse('http://localhost:1234'); void main() { - FakeVmServiceHost fakeVmServiceHost; - TestDevice testDevice; + late FakeVmServiceHost fakeVmServiceHost; + late TestDevice testDevice; setUp(() { testDevice = IntegrationTestTestDevice( @@ -133,14 +131,14 @@ void main() { }, overrides: { ApplicationPackageFactory: () => FakeApplicationPackageFactory(), VMServiceConnector: () => (Uri httpUri, { - ReloadSources reloadSources, - Restart restart, - CompileExpression compileExpression, - GetSkSLMethod getSkSLMethod, - PrintStructuredErrorLogMethod printStructuredErrorLogMethod, - io.CompressionOptions compression, - Device device, - Logger logger, + ReloadSources? reloadSources, + Restart? restart, + CompileExpression? compileExpression, + GetSkSLMethod? getSkSLMethod, + PrintStructuredErrorLogMethod? printStructuredErrorLogMethod, + io.CompressionOptions? compression, + Device? device, + Logger? logger, }) async => fakeVmServiceHost.vmService, }); @@ -152,14 +150,14 @@ void main() { }, overrides: { ApplicationPackageFactory: () => FakeApplicationPackageFactory(), VMServiceConnector: () => (Uri httpUri, { - ReloadSources reloadSources, - Restart restart, - CompileExpression compileExpression, - GetSkSLMethod getSkSLMethod, - PrintStructuredErrorLogMethod printStructuredErrorLogMethod, - io.CompressionOptions compression, - Device device, - Logger logger, + ReloadSources? reloadSources, + Restart? restart, + CompileExpression? compileExpression, + GetSkSLMethod? getSkSLMethod, + PrintStructuredErrorLogMethod? printStructuredErrorLogMethod, + io.CompressionOptions? compression, + Device? device, + Logger? logger, }) async => fakeVmServiceHost.vmService, }); @@ -181,13 +179,13 @@ void main() { expect(() => testDevice.start('entrypointPath'), throwsA(isA())); }, overrides: { VMServiceConnector: () => (Uri httpUri, { - ReloadSources reloadSources, - Restart restart, - CompileExpression compileExpression, - GetSkSLMethod getSkSLMethod, - PrintStructuredErrorLogMethod printStructuredErrorLogMethod, - io.CompressionOptions compression, - Device device, + ReloadSources? reloadSources, + Restart? restart, + CompileExpression? compileExpression, + GetSkSLMethod? getSkSLMethod, + PrintStructuredErrorLogMethod? printStructuredErrorLogMethod, + io.CompressionOptions? compression, + Device? device, }) async => fakeVmServiceHost.vmService, }); @@ -209,13 +207,13 @@ void main() { expect(() => testDevice.start('entrypointPath'), throwsA(isA())); }, overrides: { VMServiceConnector: () => (Uri httpUri, { - ReloadSources reloadSources, - Restart restart, - CompileExpression compileExpression, - GetSkSLMethod getSkSLMethod, - PrintStructuredErrorLogMethod printStructuredErrorLogMethod, - io.CompressionOptions compression, - Device device, + ReloadSources? reloadSources, + Restart? restart, + CompileExpression? compileExpression, + GetSkSLMethod? getSkSLMethod, + PrintStructuredErrorLogMethod? printStructuredErrorLogMethod, + io.CompressionOptions? compression, + Device? device, }) async => fakeVmServiceHost.vmService, }); @@ -226,14 +224,14 @@ void main() { }, overrides: { ApplicationPackageFactory: () => FakeApplicationPackageFactory(), VMServiceConnector: () => (Uri httpUri, { - ReloadSources reloadSources, - Restart restart, - CompileExpression compileExpression, - GetSkSLMethod getSkSLMethod, - PrintStructuredErrorLogMethod printStructuredErrorLogMethod, - io.CompressionOptions compression, - Device device, - Logger logger, + ReloadSources? reloadSources, + Restart? restart, + CompileExpression? compileExpression, + GetSkSLMethod? getSkSLMethod, + PrintStructuredErrorLogMethod? printStructuredErrorLogMethod, + io.CompressionOptions? compression, + Device? device, + Logger? logger, }) async => fakeVmServiceHost.vmService, }); } @@ -242,8 +240,8 @@ class FakeApplicationPackageFactory extends Fake implements ApplicationPackageFa @override Future getPackageForPlatform( TargetPlatform platform, { - BuildInfo buildInfo, - File applicationBinary, + BuildInfo? buildInfo, + File? applicationBinary, }) async => FakeApplicationPackage(); } diff --git a/packages/flutter_tools/test/general.shard/ios/ios_device_project_test.dart b/packages/flutter_tools/test/general.shard/ios/ios_device_project_test.dart index 8712e701c42f..15da88a6f41d 100644 --- a/packages/flutter_tools/test/general.shard/ios/ios_device_project_test.dart +++ b/packages/flutter_tools/test/general.shard/ios/ios_device_project_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/memory.dart'; import 'package:flutter_tools/src/artifacts.dart'; import 'package:flutter_tools/src/base/file_system.dart'; @@ -22,7 +20,7 @@ import '../../src/context.dart'; // FlutterProject still depends on context. void main() { - FileSystem fileSystem; + late FileSystem fileSystem; // This setup is required to inject the context. setUp(() { diff --git a/packages/flutter_tools/test/general.shard/ios/simulators_test.dart b/packages/flutter_tools/test/general.shard/ios/simulators_test.dart index f943ce552973..2177afa7a66e 100644 --- a/packages/flutter_tools/test/general.shard/ios/simulators_test.dart +++ b/packages/flutter_tools/test/general.shard/ios/simulators_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/memory.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; @@ -34,9 +32,9 @@ final Platform macosPlatform = FakePlatform( ); void main() { - FakePlatform osx; - FileSystemUtils fsUtils; - MemoryFileSystem fileSystem; + late FakePlatform osx; + late FileSystemUtils fsUtils; + late MemoryFileSystem fileSystem; setUp(() { osx = FakePlatform( @@ -48,8 +46,8 @@ void main() { }); group('_IOSSimulatorDevicePortForwarder', () { - FakeSimControl simControl; - Xcode xcode; + late FakeSimControl simControl; + late Xcode xcode; setUp(() { simControl = FakeSimControl(); @@ -100,7 +98,7 @@ void main() { }); group('logFilePath', () { - FakeSimControl simControl; + late FakeSimControl simControl; setUp(() { simControl = FakeSimControl(); @@ -163,7 +161,7 @@ void main() { }); group('sdkMajorVersion', () { - FakeSimControl simControl; + late FakeSimControl simControl; setUp(() { simControl = FakeSimControl(); @@ -205,7 +203,7 @@ void main() { }); group('IOSSimulator.isSupported', () { - FakeSimControl simControl; + late FakeSimControl simControl; setUp(() { simControl = FakeSimControl(); @@ -368,8 +366,8 @@ void main() { }); group('device log tool', () { - FakeProcessManager fakeProcessManager; - FakeSimControl simControl; + late FakeProcessManager fakeProcessManager; + late FakeSimControl simControl; setUp(() { fakeProcessManager = FakeProcessManager.empty(); @@ -472,10 +470,10 @@ void main() { }); group('log reader', () { - FakeProcessManager fakeProcessManager; - FakeIosProject mockIosProject; - FakeSimControl simControl; - Xcode xcode; + late FakeProcessManager fakeProcessManager; + late FakeIosProject mockIosProject; + late FakeSimControl simControl; + late Xcode xcode; setUp(() { fakeProcessManager = FakeProcessManager.empty(); @@ -616,7 +614,7 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text''' }); group('unified logging', () { - BufferLogger logger; + late BufferLogger logger; setUp(() { logger = BufferLogger.test(); @@ -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; - SimControl simControl; + late SimControl simControl; const String deviceId = 'smart-phone'; const String appId = 'flutterApp'; @@ -895,10 +893,10 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text''' }); group('startApp', () { - FakePlistParser testPlistParser; - FakeSimControl simControl; - Xcode xcode; - BufferLogger logger; + late FakePlistParser testPlistParser; + late FakeSimControl simControl; + late Xcode xcode; + late BufferLogger logger; setUp(() { simControl = FakeSimControl(); @@ -1027,8 +1025,8 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text''' }); group('IOSDevice.isSupportedForProject', () { - FakeSimControl simControl; - Xcode xcode; + late FakeSimControl simControl; + late Xcode xcode; setUp(() { simControl = FakeSimControl(); @@ -1113,17 +1111,17 @@ flutter: class FakeIosProject extends Fake implements IosProject { @override - Future productBundleIdentifier(BuildInfo buildInfo) async => 'com.example.test'; + Future productBundleIdentifier(BuildInfo? buildInfo) async => 'com.example.test'; @override - Future hostAppBundleName(BuildInfo buildInfo) async => 'My Super Awesome App.app'; + Future hostAppBundleName(BuildInfo? buildInfo) async => 'My Super Awesome App.app'; } class FakeSimControl extends Fake implements SimControl { final List requests = []; @override - Future launch(String deviceId, String appIdentifier, [ List launchArgs ]) async { + Future launch(String deviceId, String appIdentifier, [ List? launchArgs ]) async { requests.add(LaunchRequest(deviceId, appIdentifier, launchArgs)); return RunResult(ProcessResult(0, 0, '', ''), ['test']); } @@ -1139,5 +1137,5 @@ class LaunchRequest { final String deviceId; final String appIdentifier; - final List launchArgs; + final List? launchArgs; } diff --git a/packages/flutter_tools/test/general.shard/ios/xcodeproj_test.dart b/packages/flutter_tools/test/general.shard/ios/xcodeproj_test.dart index 9b2a0d23f7bc..de496685fa5f 100644 --- a/packages/flutter_tools/test/general.shard/ios/xcodeproj_test.dart +++ b/packages/flutter_tools/test/general.shard/ios/xcodeproj_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/memory.dart'; import 'package:flutter_tools/src/artifacts.dart'; import 'package:flutter_tools/src/base/file_system.dart'; @@ -56,11 +54,11 @@ void main() { stdout: 'hw.optional.arm64: 1', ); - FakeProcessManager fakeProcessManager; - XcodeProjectInterpreter xcodeProjectInterpreter; - FakePlatform platform; - FileSystem fileSystem; - BufferLogger logger; + late FakeProcessManager fakeProcessManager; + late XcodeProjectInterpreter xcodeProjectInterpreter; + late FakePlatform platform; + late FileSystem fileSystem; + late BufferLogger logger; setUp(() { fakeProcessManager = FakeProcessManager.empty(); @@ -660,7 +658,7 @@ Information about project "Runner": expect(info.buildConfigurationFor(const BuildInfo(BuildMode.release, 'Paid', treeShakeIcons: false), 'Paid'), null); }); group('environmentVariablesAsXcodeBuildSettings', () { - FakePlatform platform; + late FakePlatform platform; setUp(() { platform = FakePlatform(); @@ -679,9 +677,9 @@ Information about project "Runner": }); group('updateGeneratedXcodeProperties', () { - Artifacts localIosArtifacts; - FakePlatform macOS; - FileSystem fs; + late Artifacts localIosArtifacts; + late FakePlatform macOS; + late FileSystem fs; setUp(() { fs = MemoryFileSystem.test(); @@ -691,8 +689,8 @@ Information about project "Runner": }); group('arm simulator', () { - FakeProcessManager fakeProcessManager; - XcodeProjectInterpreter xcodeProjectInterpreter; + late FakeProcessManager fakeProcessManager; + late XcodeProjectInterpreter xcodeProjectInterpreter; setUp(() { fakeProcessManager = FakeProcessManager.empty(); @@ -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 properties = file .readAsLinesSync() .where((String line) => line.startsWith('$key=')) @@ -1057,10 +1055,10 @@ Build settings for action build and target plugin2: } Future checkBuildVersion({ - String manifestString, - BuildInfo buildInfo, - String expectedBuildName, - String expectedBuildNumber, + required String manifestString, + required BuildInfo buildInfo, + String? expectedBuildName, + String? expectedBuildNumber, }) async { final File manifestFile = fs.file('path/to/project/pubspec.yaml'); manifestFile.createSync(recursive: true); diff --git a/packages/flutter_tools/test/general.shard/macos/application_package_test.dart b/packages/flutter_tools/test/general.shard/macos/application_package_test.dart index 490f21622c38..57e11ffb6a2b 100644 --- a/packages/flutter_tools/test/general.shard/macos/application_package_test.dart +++ b/packages/flutter_tools/test/general.shard/macos/application_package_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'dart:convert'; import 'package:file/file.dart'; @@ -23,9 +21,9 @@ import '../../src/context.dart'; void main() { group('PrebuiltMacOSApp', () { - FakeOperatingSystemUtils os; - FileSystem fileSystem; - BufferLogger logger; + late FakeOperatingSystemUtils os; + late FileSystem fileSystem; + late BufferLogger logger; final Map overrides = { FileSystem: () => fileSystem, @@ -42,7 +40,7 @@ group('PrebuiltMacOSApp', () { }); 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(logger.errorText, contains('File "not_existing.app" does not exist.')); @@ -50,7 +48,7 @@ group('PrebuiltMacOSApp', () { testUsingContext('Error on non-app-bundle folder', () { 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(logger.errorText, contains('Folder "regular_folder" is not an app bundle.')); @@ -58,7 +56,7 @@ group('PrebuiltMacOSApp', () { testUsingContext('Error on no info.plist', () { 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(logger.errorText, contains('Invalid prebuilt macOS app. Does not contain Info.plist.')); @@ -67,10 +65,9 @@ group('PrebuiltMacOSApp', () { testUsingContext('Error on info.plist missing bundle identifier', () { final String contentsDirectory = fileSystem.path.join('bundle.app', 'Contents'); fileSystem.directory(contentsDirectory).createSync(recursive: true); - fileSystem - .file(fileSystem.path.join('bundle.app', 'Contents', 'Info.plist')) + fileSystem.file(fileSystem.path.join('bundle.app', 'Contents', 'Info.plist')) .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(logger.errorText, contains('Invalid prebuilt macOS app. Info.plist does not contain bundle identifier')); @@ -79,10 +76,9 @@ group('PrebuiltMacOSApp', () { testUsingContext('Error on info.plist missing executable', () { final String contentsDirectory = fileSystem.path.join('bundle.app', 'Contents'); fileSystem.directory(contentsDirectory).createSync(recursive: true); - fileSystem - .file(fileSystem.path.join('bundle.app', 'Contents', 'Info.plist')) + fileSystem.file(fileSystem.path.join('bundle.app', 'Contents', 'Info.plist')) .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(logger.errorText, contains('Invalid prebuilt macOS app. Info.plist does not contain bundle executable')); @@ -91,13 +87,11 @@ group('PrebuiltMacOSApp', () { testUsingContext('Success with app bundle', () { final String appDirectory = fileSystem.path.join('bundle.app', 'Contents', 'MacOS'); fileSystem.directory(appDirectory).createSync(recursive: true); - fileSystem - .file(fileSystem.path.join('bundle.app', 'Contents', 'Info.plist')) + fileSystem.file(fileSystem.path.join('bundle.app', 'Contents', 'Info.plist')) .writeAsStringSync(plistData); - fileSystem - .file(fileSystem.path.join(appDirectory, executableName)) + fileSystem.file(fileSystem.path.join(appDirectory, executableName)) .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(macosApp.uncompressedBundle.path, 'bundle.app'); @@ -107,7 +101,7 @@ group('PrebuiltMacOSApp', () { testUsingContext('Bad zipped app, no payload dir', () { 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(logger.errorText, contains('Archive "app.zip" does not contain a single app bundle.')); @@ -124,7 +118,7 @@ group('PrebuiltMacOSApp', () { fileSystem.directory(bundlePath1).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(logger.errorText, contains('Archive "app.zip" does not contain a single app bundle.')); @@ -138,18 +132,15 @@ group('PrebuiltMacOSApp', () { } final Directory bundleAppContentsDir = fileSystem.directory(fileSystem.path.join(targetDirectory.path, 'bundle.app', 'Contents')); bundleAppContentsDir.createSync(recursive: true); - fileSystem - .file(fileSystem.path.join(bundleAppContentsDir.path, 'Info.plist')) + fileSystem.file(fileSystem.path.join(bundleAppContentsDir.path, 'Info.plist')) .writeAsStringSync(plistData); - fileSystem - .directory(fileSystem.path.join(bundleAppContentsDir.path, 'MacOS')) + fileSystem.directory(fileSystem.path.join(bundleAppContentsDir.path, 'MacOS')) .createSync(); - fileSystem - .file(fileSystem.path + fileSystem.file(fileSystem.path .join(bundleAppContentsDir.path, 'MacOS', executableName)) .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(macosApp.uncompressedBundle.path, endsWith('bundle.app')); @@ -170,7 +161,7 @@ group('PrebuiltMacOSApp', () { class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils { FakeOperatingSystemUtils(); - void Function(File, Directory) unzipOverride; + void Function(File, Directory)? unzipOverride; @override void unzip(File file, Directory targetDirectory) { @@ -181,15 +172,15 @@ class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils { class FakePlistUtils extends Fake implements PlistParser { FakePlistUtils(this.fileSystem); - final FileSystem fileSystem; + final FileSystem? fileSystem; @override - Map parseFile(String plistFilePath) { - final File file = fileSystem.file(plistFilePath); + Map parseFile(String plistFilePath) { + final File file = fileSystem!.file(plistFilePath); if (!file.existsSync()) { - return {}; + return {}; } - return castStringKeyedMap(json.decode(file.readAsStringSync())); + return castStringKeyedMap(json.decode(file.readAsStringSync()))!.cast(); } } diff --git a/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart b/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart index 1f2b90cacb16..3c34f14426e7 100644 --- a/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart +++ b/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/file.dart'; import 'package:file/memory.dart'; import 'package:flutter_tools/src/base/logger.dart'; @@ -22,11 +20,11 @@ import '../../src/context.dart'; import '../../src/fake_process_manager.dart'; void main() { - FileSystem fileSystem; - FakeProcessManager fakeProcessManager; - CocoaPods cocoaPodsUnderTest; - BufferLogger logger; - TestUsage usage; + late FileSystem fileSystem; + late FakeProcessManager fakeProcessManager; + late CocoaPods cocoaPodsUnderTest; + late BufferLogger logger; + late TestUsage usage; void pretendPodVersionFails() { fakeProcessManager.addCommand( @@ -77,17 +75,17 @@ void main() { usage: usage, ); 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) ..writeAsStringSync('Objective-C iOS podfile template'); 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) ..writeAsStringSync('Swift iOS podfile template'); 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) ..writeAsStringSync('macOS podfile template'); @@ -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( xcodeProject: projectUnderTest.ios, buildMode: BuildMode.debug, - dependenciesChanged: true, ); expect(didInstall, isTrue); expect(fakeProcessManager, hasNoRemainingExpectations); @@ -828,7 +825,7 @@ class FakeXcodeProjectInterpreter extends Fake implements XcodeProjectInterprete @override Future> getBuildSettings( String projectPath, { - XcodeProjectBuildContext buildContext, + XcodeProjectBuildContext? buildContext, Duration timeout = const Duration(minutes: 1), }) async => buildSettings; diff --git a/packages/flutter_tools/test/general.shard/macos/xcode_test.dart b/packages/flutter_tools/test/general.shard/macos/xcode_test.dart index ed7a5d7ae2c5..3969151bf011 100644 --- a/packages/flutter_tools/test/general.shard/macos/xcode_test.dart +++ b/packages/flutter_tools/test/general.shard/macos/xcode_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'dart:async'; import 'package:flutter_tools/src/artifacts.dart'; @@ -24,21 +22,21 @@ import '../../src/common.dart'; import '../../src/context.dart'; void main() { - BufferLogger logger; + late BufferLogger logger; setUp(() { logger = BufferLogger.test(); }); group('FakeProcessManager', () { - FakeProcessManager fakeProcessManager; + late FakeProcessManager fakeProcessManager; setUp(() { fakeProcessManager = FakeProcessManager.empty(); }); group('Xcode', () { - FakeXcodeProjectInterpreter xcodeProjectInterpreter; + late FakeXcodeProjectInterpreter xcodeProjectInterpreter; setUp(() { xcodeProjectInterpreter = FakeXcodeProjectInterpreter(); @@ -94,7 +92,7 @@ void main() { }); group('macOS', () { - Xcode xcode; + late Xcode xcode; setUp(() { xcodeProjectInterpreter = FakeXcodeProjectInterpreter(); @@ -276,8 +274,8 @@ void main() { }); group('xcdevice not installed', () { - XCDevice xcdevice; - Xcode xcode; + late XCDevice xcdevice; + late Xcode xcode; setUp(() { xcode = Xcode.test( @@ -310,8 +308,8 @@ void main() { }); group('xcdevice', () { - XCDevice xcdevice; - Xcode xcode; + late XCDevice xcdevice; + late Xcode xcode; setUp(() { xcode = Xcode.test(processManager: FakeProcessManager.any()); @@ -351,7 +349,7 @@ void main() { // Attach: d83d5bc53967baa0ee18626ba87b6254b2ab5418 // Attach: 00008027-00192736010F802E // Detach: d83d5bc53967baa0ee18626ba87b6254b2ab5418 - xcdevice.observedDeviceEvents().listen((Map event) { + xcdevice.observedDeviceEvents()!.listen((Map event) { expect(event.length, 1); if (event.containsKey(XCDeviceEvent.attach)) { if (event[XCDeviceEvent.attach] == 'd83d5bc53967baa0ee18626ba87b6254b2ab5418') { diff --git a/packages/flutter_tools/test/general.shard/plugins_test.dart b/packages/flutter_tools/test/general.shard/plugins_test.dart index d724dd6f6820..71c5fb21b54a 100644 --- a/packages/flutter_tools/test/general.shard/plugins_test.dart +++ b/packages/flutter_tools/test/general.shard/plugins_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'dart:convert'; import 'package:file/file.dart'; @@ -21,7 +19,6 @@ import 'package:flutter_tools/src/ios/xcodeproj.dart'; import 'package:flutter_tools/src/plugins.dart'; import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/version.dart'; -import 'package:meta/meta.dart'; import 'package:test/fake.dart'; import 'package:yaml/yaml.dart'; @@ -42,16 +39,16 @@ class _PluginPlatformInfo { assert(androidPackage == null || pluginClass != null); /// The pluginClass entry, if any. - final String pluginClass; + final String? pluginClass; /// The dartPluginClass entry, if any. - final String dartPluginClass; + final String? dartPluginClass; /// The package entry for an Android plugin implementation using pluginClass. - final String androidPackage; + final String? androidPackage; /// The fileName entry for a web plugin implementation. - final String fileName; + final String? fileName; /// Returns the body of a platform section for a plugin's pubspec, properly /// indented. @@ -72,21 +69,21 @@ class _PluginPlatformInfo { void main() { group('plugins', () { - FileSystem fs; - FakeFlutterProject flutterProject; - FakeFlutterManifest flutterManifest; - FakeIosProject iosProject; - FakeMacOSProject macosProject; - FakeAndroidProject androidProject; - FakeWebProject webProject; - FakeWindowsProject windowsProject; - FakeLinuxProject linuxProject; - FakeSystemClock systemClock; - FlutterVersion flutterVersion; + late FileSystem fs; + late FakeFlutterProject flutterProject; + late FakeFlutterManifest flutterManifest; + late FakeIosProject iosProject; + late FakeMacOSProject macosProject; + late FakeAndroidProject androidProject; + late FakeWebProject webProject; + late FakeWindowsProject windowsProject; + late FakeLinuxProject linuxProject; + late FakeSystemClock systemClock; + late FlutterVersion flutterVersion; // A Windows-style filesystem. This is not populated by default, so tests // using it instead of fs must re-run any necessary setup (e.g., // setUpProject). - FileSystem fsWindows; + late FileSystem fsWindows; // Adds basic properties to the flutterProject and its subprojects. void setUpProject(FileSystem fileSystem) { @@ -372,8 +369,8 @@ flutter: } Directory createLegacyPluginWithDependencies({ - @required String name, - @required List dependencies, + required String name, + required List dependencies, }) { assert(name != null); assert(dependencies != null); @@ -404,8 +401,8 @@ dependencies: } Directory createPlugin({ - @required String name, - @required Map platforms, + required String name, + required Map platforms, List dependencies = const [], }) { assert(name != null); @@ -619,15 +616,15 @@ dependencies: expect(flutterProject.flutterPluginsDependenciesFile.existsSync(), true); final String pluginsString = flutterProject.flutterPluginsDependenciesFile.readAsStringSync(); final Map jsonContent = json.decode(pluginsString) as Map; - final Map plugins = jsonContent['plugins'] as Map; + final Map? plugins = jsonContent['plugins'] as Map?; // Extracts the native_build key (if any) from the first plugin for the // given platform. - bool getNativeBuildValue(String platform) { - final List> platformPlugins = (plugins[platform] + bool? getNativeBuildValue(String platform) { + final List> platformPlugins = (plugins![platform] as List).cast>(); expect(platformPlugins.length, 1); - return platformPlugins[0]['native_build'] as bool; + return platformPlugins[0]['native_build'] as bool?; } expect(getNativeBuildValue('android'), true); expect(getNativeBuildValue('ios'), true); @@ -682,7 +679,7 @@ dependencies: }); group('injectPlugins', () { - FakeXcodeProjectInterpreter xcodeProjectInterpreter; + FakeXcodeProjectInterpreter? xcodeProjectInterpreter; setUp(() { xcodeProjectInterpreter = FakeXcodeProjectInterpreter(); @@ -1402,8 +1399,8 @@ flutter: await injectPlugins(flutterProject, linuxPlatform: true, windowsPlatform: true); - for (final CmakeBasedProject project in [linuxProject, windowsProject]) { - final File pluginCmakefile = project.generatedPluginCmakeFile; + for (final CmakeBasedProject? project in [linuxProject, windowsProject]) { + final File pluginCmakefile = project!.generatedPluginCmakeFile; expect(pluginCmakefile.existsSync(), isTrue); final String contents = pluginCmakefile.readAsStringSync(); @@ -1416,7 +1413,7 @@ flutter: }); group('createPluginSymlinks', () { - FeatureFlags featureFlags; + FeatureFlags? featureFlags; setUp(() { featureFlags = TestFeatureFlags(isLinuxEnabled: true, isWindowsEnabled: true); @@ -1546,8 +1543,8 @@ flutter: }); group('pubspec', () { - Directory projectDir; - Directory tempDir; + late Directory projectDir; + late Directory tempDir; setUp(() { tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_plugin_test.'); @@ -1603,7 +1600,7 @@ flutter: }); testUsingContext('createPlatformsYamlMap should create empty map', () async { - final YamlMap map = Plugin.createPlatformsYamlMap([], null, null); + final YamlMap map = Plugin.createPlatformsYamlMap([], 'foo', 'bar'); expect(map.isEmpty, true); }); @@ -1655,34 +1652,34 @@ class FakeFlutterProject extends Fake implements FlutterProject { bool isModule = false; @override - FlutterManifest manifest; + late FlutterManifest manifest; @override - Directory directory; + late Directory directory; @override - File flutterPluginsFile; + late File flutterPluginsFile; @override - File flutterPluginsDependenciesFile; + late File flutterPluginsDependenciesFile; @override - IosProject ios; + late IosProject ios; @override - AndroidProject android; + late AndroidProject android; @override - WebProject web; + late WebProject web; @override - MacOSProject macos; + late MacOSProject macos; @override - LinuxProject linux; + late LinuxProject linux; @override - WindowsProject windows; + late WindowsProject windows; } class FakeMacOSProject extends Fake implements MacOSProject { @@ -1692,13 +1689,13 @@ class FakeMacOSProject extends Fake implements MacOSProject { bool exists = false; @override - File podfile; + late File podfile; @override - File podManifestLock; + late File podManifestLock; @override - Directory managedDirectory; + late Directory managedDirectory; @override bool existsSync() => exists; @@ -1717,7 +1714,7 @@ class FakeIosProject extends Fake implements IosProject { bool get exists => testExists; @override - Directory pluginRegistrantHost; + late Directory pluginRegistrantHost; @override File get pluginRegistrantHeader => pluginRegistrantHost.childFile('GeneratedPluginRegistrant.h'); @@ -1726,10 +1723,10 @@ class FakeIosProject extends Fake implements IosProject { File get pluginRegistrantImplementation => pluginRegistrantHost.childFile('GeneratedPluginRegistrant.m'); @override - File podfile; + late File podfile; @override - File podManifestLock; + late File podManifestLock; } class FakeAndroidProject extends Fake implements AndroidProject { @@ -1739,15 +1736,15 @@ class FakeAndroidProject extends Fake implements AndroidProject { bool exists = false; @override - Directory pluginRegistrantHost; + late Directory pluginRegistrantHost; @override - Directory hostAppGradleRoot; + late Directory hostAppGradleRoot; @override - File appManifestFile; + late File appManifestFile; - AndroidEmbeddingVersion embeddingVersion; + late AndroidEmbeddingVersion embeddingVersion; @override bool existsSync() => exists; @@ -1768,7 +1765,7 @@ class FakeWebProject extends Fake implements WebProject { String pluginConfigKey = 'web'; @override - Directory libDirectory; + late Directory libDirectory; bool exists = false; @@ -1781,19 +1778,19 @@ class FakeWindowsProject extends Fake implements WindowsProject { String pluginConfigKey = 'windows'; @override - Directory managedDirectory; + late Directory managedDirectory; @override - Directory ephemeralDirectory; + late Directory ephemeralDirectory; @override - Directory pluginSymlinkDirectory; + late Directory pluginSymlinkDirectory; @override - File cmakeFile; + late File cmakeFile; @override - File generatedPluginCmakeFile; + late File generatedPluginCmakeFile; bool exists = false; @override @@ -1805,19 +1802,19 @@ class FakeLinuxProject extends Fake implements LinuxProject { String pluginConfigKey = 'linux'; @override - Directory managedDirectory; + late Directory managedDirectory; @override - Directory ephemeralDirectory; + late Directory ephemeralDirectory; @override - Directory pluginSymlinkDirectory; + late Directory pluginSymlinkDirectory; @override - File cmakeFile; + late File cmakeFile; @override - File generatedPluginCmakeFile; + late File generatedPluginCmakeFile; bool exists = false; @override @@ -1833,7 +1830,7 @@ class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils { } class FakeSystemClock extends Fake implements SystemClock { - DateTime currentTime; + late DateTime currentTime; @override DateTime now() { diff --git a/packages/flutter_tools/test/general.shard/preview_device_test.dart b/packages/flutter_tools/test/general.shard/preview_device_test.dart index 440d6e29856b..f1f44267856f 100644 --- a/packages/flutter_tools/test/general.shard/preview_device_test.dart +++ b/packages/flutter_tools/test/general.shard/preview_device_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'dart:async'; import 'package:file/memory.dart'; @@ -93,15 +91,15 @@ class FakeBundleBuilder extends Fake implements BundleBuilder { @override Future build({ - @required TargetPlatform platform, - @required BuildInfo buildInfo, - FlutterProject project, - String mainPath, + required TargetPlatform platform, + required BuildInfo buildInfo, + FlutterProject? project, + String? mainPath, String manifestPath = defaultManifestPath, - String applicationKernelFilePath, - String depfilePath, - String assetDirPath, - @visibleForTesting BuildSystem buildSystem + String? applicationKernelFilePath, + String? depfilePath, + String? assetDirPath, + @visibleForTesting BuildSystem? buildSystem }) async { final Directory assetDirectory = fileSystem .directory(assetDirPath) diff --git a/packages/flutter_tools/test/general.shard/project_file_invalidator_test.dart b/packages/flutter_tools/test/general.shard/project_file_invalidator_test.dart index 685c550f5514..35c12cabf6bc 100644 --- a/packages/flutter_tools/test/general.shard/project_file_invalidator_test.dart +++ b/packages/flutter_tools/test/general.shard/project_file_invalidator_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/memory.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/logger.dart'; diff --git a/packages/flutter_tools/test/general.shard/resident_devtools_handler_test.dart b/packages/flutter_tools/test/general.shard/resident_devtools_handler_test.dart index ddadcab37dc7..d6c595c747b4 100644 --- a/packages/flutter_tools/test/general.shard/resident_devtools_handler_test.dart +++ b/packages/flutter_tools/test/general.shard/resident_devtools_handler_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'dart:async'; import 'package:flutter_tools/src/base/logger.dart'; @@ -107,8 +105,8 @@ void main() { flutterDevices: [], ); - expect(handler.activeDevToolsServer.host, 'localhost'); - expect(handler.activeDevToolsServer.port, 8181); + expect(handler.activeDevToolsServer!.host, 'localhost'); + expect(handler.activeDevToolsServer!.port, 8181); }); testWithoutContext('serveAndAnnounceDevTools with attached device does not fail on null vm service', () async { @@ -425,13 +423,13 @@ void main() { class FakeDevtoolsLauncher extends Fake implements DevtoolsLauncher { @override - DevToolsServerAddress activeDevToolsServer; + DevToolsServerAddress? activeDevToolsServer; @override - Uri devToolsUrl; + Uri? devToolsUrl; @override - Future serve() async => null; + Future serve() async => null; @override Future get ready => readyCompleter.future; @@ -452,7 +450,7 @@ class FakeFlutterDevice extends Fake implements FlutterDevice { final Device device = FakeDevice(); @override - FlutterVmService vmService; + FlutterVmService? vmService; @override TargetPlatform targetPlatform = TargetPlatform.android_arm; diff --git a/packages/flutter_tools/test/general.shard/terminal_handler_test.dart b/packages/flutter_tools/test/general.shard/terminal_handler_test.dart index e9af1ef59c88..94291fc252da 100644 --- a/packages/flutter_tools/test/general.shard/terminal_handler_test.dart +++ b/packages/flutter_tools/test/general.shard/terminal_handler_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'dart:async'; import 'package:file/file.dart'; @@ -945,14 +943,14 @@ void main() { listViews, FakeVmServiceRequest( method: 'ext.flutter.debugAllowBanner', - args: { + args: { 'isolateId': fakeUnpausedIsolate.id, 'enabled': 'false', }, ), FakeVmServiceRequest( method: 'ext.flutter.debugAllowBanner', - args: { + args: { 'isolateId': fakeUnpausedIsolate.id, 'enabled': 'true', }, @@ -971,7 +969,7 @@ void main() { listViews, FakeVmServiceRequest( method: 'ext.flutter.debugAllowBanner', - args: { + args: { 'isolateId': fakeUnpausedIsolate.id, 'enabled': 'false', }, @@ -985,7 +983,7 @@ void main() { ), FakeVmServiceRequest( method: 'ext.flutter.debugAllowBanner', - args: { + args: { 'isolateId': fakeUnpausedIsolate.id, 'enabled': 'true', }, @@ -1005,7 +1003,7 @@ void main() { listViews, FakeVmServiceRequest( method: 'ext.flutter.debugAllowBanner', - args: { + args: { 'isolateId': fakeUnpausedIsolate.id, 'enabled': 'false', }, @@ -1019,7 +1017,7 @@ void main() { ), FakeVmServiceRequest( method: 'ext.flutter.debugAllowBanner', - args: { + args: { 'isolateId': fakeUnpausedIsolate.id, 'enabled': 'true', }, @@ -1090,7 +1088,7 @@ void main() { listViews, FakeVmServiceRequest( method: 'ext.flutter.debugAllowBanner', - args: { + args: { 'isolateId': fakeUnpausedIsolate.id, 'enabled': 'false', }, @@ -1115,7 +1113,7 @@ void main() { listViews, FakeVmServiceRequest( method: 'ext.flutter.debugAllowBanner', - args: { + args: { 'isolateId': fakeUnpausedIsolate.id, 'enabled': 'false', }, @@ -1127,7 +1125,7 @@ void main() { ), FakeVmServiceRequest( method: 'ext.flutter.debugAllowBanner', - args: { + args: { 'isolateId': fakeUnpausedIsolate.id, 'enabled': 'true', }, @@ -1150,7 +1148,7 @@ void main() { listViews, FakeVmServiceRequest( method: 'ext.flutter.debugAllowBanner', - args: { + args: { 'isolateId': fakeUnpausedIsolate.id, 'enabled': 'false', }, @@ -1162,7 +1160,7 @@ void main() { ), FakeVmServiceRequest( method: 'ext.flutter.debugAllowBanner', - args: { + args: { 'isolateId': fakeUnpausedIsolate.id, 'enabled': 'true', }, @@ -1186,14 +1184,14 @@ void main() { listViews, FakeVmServiceRequest( method: 'ext.flutter.debugAllowBanner', - args: { + args: { 'isolateId': fakeUnpausedIsolate.id, 'enabled': 'false', }, ), FakeVmServiceRequest( method: 'ext.flutter.debugAllowBanner', - args: { + args: { 'isolateId': fakeUnpausedIsolate.id, 'enabled': 'true', }, @@ -1309,7 +1307,7 @@ class FakeResidentRunner extends ResidentHandlers { } @override - void printHelp({bool details}) { + void printHelp({required bool details}) { if (details) { calledPrintWithDetails = true; } else { @@ -1321,7 +1319,7 @@ class FakeResidentRunner extends ResidentHandlers { Future runSourceGenerators() async { } @override - Future restart({bool fullRestart = false, bool pause = false, String reason}) async { + Future restart({bool fullRestart = false, bool pause = false, String? reason}) async { if (fullRestart && !supportsRestart) { throw StateError('illegal restart'); } @@ -1345,7 +1343,7 @@ class FakeResidentDevtoolsHandler extends Fake implements ResidentDevtoolsHandle bool calledLaunchDevToolsInBrowser = false; @override - bool launchDevToolsInBrowser({List flutterDevices}) { + bool launchDevToolsInBrowser({List? flutterDevices}) { return calledLaunchDevToolsInBrowser = true; } } @@ -1382,8 +1380,8 @@ TerminalHandler setUpTerminalHandler(List requests, { bool supportsScreenshot = false, int reloadExitCode = 0, BuildMode buildMode = BuildMode.debug, - Logger logger, - FileSystem fileSystem, + Logger? logger, + FileSystem? fileSystem, }) { final Logger testLogger = logger ?? BufferLogger.test(); final Signals signals = Signals.test(); @@ -1440,7 +1438,7 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler { } class TestRunner extends Fake implements ResidentRunner { bool hasHelpBeenPrinted = false; - String receivedCommand; + String? receivedCommand; @override Future cleanupAfterSignal() async { } @@ -1449,22 +1447,22 @@ class TestRunner extends Fake implements ResidentRunner { Future cleanupAtFinish() async { } @override - void printHelp({ bool details }) { + void printHelp({ bool? details }) { hasHelpBeenPrinted = true; } @override - Future run({ - Completer connectionInfoCompleter, - Completer appStartedCompleter, + Future run({ + Completer? connectionInfoCompleter, + Completer? appStartedCompleter, bool enableDevTools = false, - String route, + String? route, }) async => null; @override - Future attach({ - Completer connectionInfoCompleter, - Completer appStartedCompleter, + Future attach({ + Completer? connectionInfoCompleter, + Completer? appStartedCompleter, bool allowExistingDdsInstance = false, bool enableDevTools = false, bool needsFullRestart = true, @@ -1491,10 +1489,10 @@ class _TestSignals implements Signals { if (!_handlersTable.containsKey(signal)) { return false; } - if (!_handlersTable[signal].containsKey(token)) { + if (!_handlersTable[signal]!.containsKey(token)) { return false; } - _handlersTable[signal].remove(token); + _handlersTable[signal]!.remove(token); return true; } diff --git a/packages/flutter_tools/test/general.shard/test/test_compiler_test.dart b/packages/flutter_tools/test/general.shard/test/test_compiler_test.dart index 415e87795f4a..cb743f8d39ce 100644 --- a/packages/flutter_tools/test/general.shard/test/test_compiler_test.dart +++ b/packages/flutter_tools/test/general.shard/test/test_compiler_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/memory.dart'; import 'package:file_testing/file_testing.dart'; import 'package:flutter_tools/src/base/file_system.dart'; @@ -33,8 +31,8 @@ final BuildInfo debugBuild = BuildInfo( ); void main() { - FakeResidentCompiler residentCompiler; - FileSystem fileSystem; + late FakeResidentCompiler residentCompiler; + late FileSystem fileSystem; setUp(() { fileSystem = MemoryFileSystem.test(); @@ -149,8 +147,7 @@ environment: await testCompiler.compile(Uri.parse('test/foo.dart')); - final File generatedMain = fileSystem - .directory('.dart_tool') + final File generatedMain = fileSystem.directory('.dart_tool') .childDirectory('flutter_build') .childFile('dart_plugin_registrant.dart'); @@ -170,17 +167,17 @@ environment: /// Override the creation of the Resident Compiler to simplify testing. class FakeTestCompiler extends TestCompiler { FakeTestCompiler( - BuildInfo buildInfo, - FlutterProject flutterProject, + super.buildInfo, + super.flutterProject, this.residentCompiler, { - String precompiledDillPath, + super.precompiledDillPath, } - ) : super(buildInfo, flutterProject, precompiledDillPath: precompiledDillPath); + ); - final FakeResidentCompiler residentCompiler; + final FakeResidentCompiler? residentCompiler; @override - Future createCompiler() async { + Future createCompiler() async { return residentCompiler; } } @@ -188,24 +185,24 @@ class FakeTestCompiler extends TestCompiler { class FakeResidentCompiler extends Fake implements ResidentCompiler { FakeResidentCompiler(this.fileSystem); - final FileSystem fileSystem; + final FileSystem? fileSystem; - CompilerOutput compilerOutput; + CompilerOutput? compilerOutput; bool didShutdown = false; @override - Future recompile( + Future recompile( Uri mainUri, - List invalidatedFiles, { - String outputPath, - PackageConfig packageConfig, - String projectRootPath, - FileSystem fs, + List? invalidatedFiles, { + String? outputPath, + PackageConfig? packageConfig, + String? projectRootPath, + FileSystem? fs, bool suppressErrors = false, bool checkDartPluginRegistry = false, }) async { if (compilerOutput != null) { - fileSystem.file(compilerOutput.outputFilename).createSync(recursive: true); + fileSystem!.file(compilerOutput!.outputFilename).createSync(recursive: true); } return compilerOutput; } @@ -217,7 +214,8 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler { void reset() { } @override - Future shutdown() async { + Future shutdown() async { didShutdown = true; + return Object(); } } diff --git a/packages/flutter_tools/test/general.shard/testbed_test.dart b/packages/flutter_tools/test/general.shard/testbed_test.dart index d34211df7d1f..135bb54a7802 100644 --- a/packages/flutter_tools/test/general.shard/testbed_test.dart +++ b/packages/flutter_tools/test/general.shard/testbed_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'dart:async'; import 'dart:io'; @@ -24,7 +22,7 @@ void main() { test('Can provide default interfaces', () async { final Testbed testbed = Testbed(); - FileSystem localFileSystem; + late FileSystem localFileSystem; await testbed.run(() { localFileSystem = globals.fs; }); @@ -39,7 +37,7 @@ void main() { A: () => A(), }); - A instance; + A? instance; await testbed.run(() { instance = context.get(); }); @@ -52,7 +50,7 @@ void main() { A: () => A(), }); - A instance; + A? instance; await testbed.run(() { instance = context.get(); }, overrides: { diff --git a/packages/flutter_tools/test/general.shard/version_test.dart b/packages/flutter_tools/test/general.shard/version_test.dart index 41c60867a22a..38febc6b6e59 100644 --- a/packages/flutter_tools/test/general.shard/version_test.dart +++ b/packages/flutter_tools/test/general.shard/version_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'dart:convert'; import 'package:flutter_tools/src/base/logger.dart'; @@ -24,8 +22,8 @@ final DateTime _stampUpToDate = _testClock.ago(VersionFreshnessValidator.checkAg final DateTime _stampOutOfDate = _testClock.ago(VersionFreshnessValidator.checkAgeConsideredUpToDate * 2); void main() { - FakeCache cache; - FakeProcessManager processManager; + late FakeCache cache; + late FakeProcessManager processManager; setUp(() { processManager = FakeProcessManager.empty(); @@ -323,15 +321,15 @@ void main() { const String flutterNonStandardUrlDotGit = 'https://githubmirror.com/flutter/flutter.git'; const String flutterStandardSshUrlDotGit = 'git@github.com:flutter/flutter.git'; - VersionCheckError runUpstreamValidator({ - String versionUpstreamUrl, - String flutterGitUrl, + VersionCheckError? runUpstreamValidator({ + String? versionUpstreamUrl, + String? flutterGitUrl, }){ final Platform testPlatform = FakePlatform(environment: { if (flutterGitUrl != null) 'FLUTTER_GIT_URL': flutterGitUrl, }); return VersionUpstreamValidator( - version: FakeFlutterVersion(repositoryUrl: versionUpstreamUrl), + version: FakeFlutterVersion(repositoryUrl: versionUpstreamUrl, channel: 'master'), platform: testPlatform, ).run(); } @@ -339,7 +337,7 @@ void main() { testWithoutContext('returns error if repository url is null', () { final VersionCheckError error = runUpstreamValidator( // repositoryUrl is null by default - ); + )!; expect(error, isNotNull); expect( error.message, @@ -352,7 +350,7 @@ void main() { }); 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.message, @@ -375,7 +373,7 @@ void main() { final VersionCheckError error = runUpstreamValidator( versionUpstreamUrl: flutterStandardUrlDotGit, flutterGitUrl: flutterNonStandardUrlDotGit, - ); + )!; expect(error, isNotNull); expect( error.message, @@ -673,7 +671,7 @@ void main() { } class FakeCache extends Fake implements Cache { - String versionStamp; + String? versionStamp; bool setVersionStamp = false; @override @@ -689,7 +687,7 @@ class FakeCache extends Fake implements Cache { void checkLockAcquired() { } @override - String getStampFor(String artifactName) { + String? getStampFor(String artifactName) { if (artifactName == VersionCheckStamp.flutterVersionCheckStampFile) { return versionStamp; } @@ -705,11 +703,11 @@ class FakeCache extends Fake implements Cache { } class FakeFlutterVersion extends Fake implements FlutterVersion { - FakeFlutterVersion({this.channel, this.repositoryUrl}); + FakeFlutterVersion({required this.channel, this.repositoryUrl}); @override final String channel; @override - final String repositoryUrl; + final String? repositoryUrl; } diff --git a/packages/flutter_tools/test/general.shard/windows/application_package_test.dart b/packages/flutter_tools/test/general.shard/windows/application_package_test.dart index 6af3a4b75aeb..29857b4b1b92 100644 --- a/packages/flutter_tools/test/general.shard/windows/application_package_test.dart +++ b/packages/flutter_tools/test/general.shard/windows/application_package_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/file.dart'; import 'package:file/memory.dart'; import 'package:flutter_tools/src/base/file_system.dart'; @@ -17,9 +15,9 @@ import '../../src/context.dart'; void main() { group('PrebuiltWindowsApp', () { - FakeOperatingSystemUtils os; - FileSystem fileSystem; - BufferLogger logger; + late FakeOperatingSystemUtils os; + late FileSystem fileSystem; + late BufferLogger logger; final Map overrides = { FileSystem: () => fileSystem, @@ -35,7 +33,7 @@ void main() { }); 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(logger.errorText, contains('File "not_existing.exe" does not exist.')); @@ -43,13 +41,13 @@ void main() { testUsingContext('Success on exe file', () { 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'); }, overrides: overrides); 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(logger.errorText, contains('File "not_existing.zip" does not exist.')); @@ -57,7 +55,7 @@ void main() { testUsingContext('Bad zipped app, no payload dir', () { 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(logger.errorText, contains('Cannot find .exe files in the zip archive.')); @@ -74,7 +72,7 @@ void main() { fileSystem.directory(exePath1).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(logger.errorText, contains('Archive "app.zip" contains more than one .exe files.')); @@ -82,7 +80,7 @@ void main() { testUsingContext('Success with zipped app', () { fileSystem.file('app.zip').createSync(); - String exePath; + String? exePath; os.unzipOverride = (File zipFile, Directory targetDirectory) { if (zipFile.path != 'app.zip') { return; @@ -90,7 +88,7 @@ void main() { exePath = fileSystem.path.join(targetDirectory.path, 'app.exe'); 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(windowsApp.name, exePath); @@ -99,7 +97,7 @@ void main() { testUsingContext('Error on unknown file type', () { 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(logger.errorText, contains('Unknown windows application type.')); @@ -110,7 +108,7 @@ void main() { class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils { FakeOperatingSystemUtils(); - void Function(File, Directory) unzipOverride; + void Function(File, Directory)? unzipOverride; @override void unzip(File file, Directory targetDirectory) { diff --git a/packages/flutter_tools/test/integration.shard/expression_evaluation_test.dart b/packages/flutter_tools/test/integration.shard/expression_evaluation_test.dart index 28b853b44959..90ab661ad303 100644 --- a/packages/flutter_tools/test/integration.shard/expression_evaluation_test.dart +++ b/packages/flutter_tools/test/integration.shard/expression_evaluation_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/file.dart'; import 'package:vm_service/vm_service.dart'; @@ -16,8 +14,8 @@ import 'test_utils.dart'; void batch1() { final BasicProject project = BasicProject(); - Directory tempDir; - FlutterRunTestDriver flutter; + late Directory tempDir; + late FlutterRunTestDriver flutter; Future initProject() async { tempDir = createResolvedTempDirectorySync('run_expression_eval_test.'); @@ -95,8 +93,8 @@ void batch1() { void batch2() { final TestsProject project = TestsProject(); - Directory tempDir; - FlutterTestTestDriver flutter; + late Directory tempDir; + late FlutterTestTestDriver flutter; Future initProject() async { tempDir = createResolvedTempDirectorySync('test_expression_eval_test.'); @@ -105,7 +103,7 @@ void batch2() { } Future cleanProject() async { - await flutter?.waitForCompletion(); + await flutter.waitForCompletion(); tryToDelete(tempDir); } @@ -165,14 +163,14 @@ Future evaluateComplexReturningExpressions(FlutterTestDriver flutter) asyn final DateTime date = DateTime(2000); final ObjRef resp = await flutter.evaluateInFrame('new DateTime(2000)'); 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}'); } void expectInstanceOfClass(ObjRef result, String name) { expect(result, const TypeMatcher() - .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) { diff --git a/packages/flutter_tools/test/integration.shard/migrate_config_test.dart b/packages/flutter_tools/test/integration.shard/migrate_config_test.dart index 9973356dfbdc..0792d30e2cc6 100644 --- a/packages/flutter_tools/test/integration.shard/migrate_config_test.dart +++ b/packages/flutter_tools/test/integration.shard/migrate_config_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file/file.dart'; import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/flutter_project_metadata.dart'; @@ -17,9 +15,9 @@ import 'test_utils.dart'; void main() { - Directory tempDir; - FlutterRunTestDriver flutter; - Logger logger; + late Directory tempDir; + late FlutterRunTestDriver flutter; + late Logger logger; setUp(() async { tempDir = createResolvedTempDirectorySync('run_test.'); @@ -71,11 +69,11 @@ migration: ''', flush: true); FlutterProjectMetadata metadata = FlutterProjectMetadata(metadataFile, logger); - expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.root].createRevision, equals('fj19vkla9vnlka9vni3n808v3nch8cd')); - expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.root].baseRevision, equals('93kf9v3njfa90vnidfjvn39nvi3vnie')); + expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.root]!.createRevision, equals('fj19vkla9vnlka9vni3n808v3nch8cd')); + expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.root]!.baseRevision, equals('93kf9v3njfa90vnidfjvn39nvi3vnie')); - expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.android].createRevision, equals('abfj19vkla9vnlka9vni3n808v3nch8cd')); - expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.android].baseRevision, equals('ab93kf9v3njfa90vnidfjvn39nvi3vnie')); + expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.android]!.createRevision, equals('abfj19vkla9vnlka9vni3n808v3nch8cd')); + expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.android]!.baseRevision, equals('ab93kf9v3njfa90vnidfjvn39nvi3vnie')); expect(metadata.migrateConfig.unmanagedFiles[0], equals('lib/main.dart')); expect(metadata.migrateConfig.unmanagedFiles[1], equals('ios/Runner.xcodeproj/project.pbxproj')); @@ -169,8 +167,6 @@ migration: projectDirectory: tempDir, currentRevision: currentRevision, createRevision: createRevision, - create: true, - update: true, logger: logger, ); @@ -179,16 +175,16 @@ migration: final List keyList = List.from(metadata.migrateConfig.platformConfigs.keys); expect(keyList[0], equals(SupportedPlatform.root)); - expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.root].baseRevision, equals(currentRevision)); - expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.root].createRevision, equals(createRevision)); + expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.root]!.baseRevision, equals(currentRevision)); + expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.root]!.createRevision, equals(createRevision)); expect(keyList[1], equals(SupportedPlatform.android)); - expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.android].baseRevision, equals(currentRevision)); - expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.android].createRevision, equals(createRevision)); + expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.android]!.baseRevision, equals(currentRevision)); + expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.android]!.createRevision, equals(createRevision)); expect(keyList[2], equals(SupportedPlatform.ios)); - expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.ios].baseRevision, equals(currentRevision)); - expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.ios].createRevision, equals(createRevision)); + expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.ios]!.baseRevision, equals(currentRevision)); + expect(metadata.migrateConfig.platformConfigs[SupportedPlatform.ios]!.createRevision, equals(createRevision)); final File metadataFileOutput = tempDir.childFile('.metadata_output'); metadata.writeFile(outputFile: metadataFileOutput); diff --git a/packages/flutter_tools/test/integration.shard/project_validator_integration_test.dart b/packages/flutter_tools/test/integration.shard/project_validator_integration_test.dart index f2a84d9a0033..33a372724c20 100644 --- a/packages/flutter_tools/test/integration.shard/project_validator_integration_test.dart +++ b/packages/flutter_tools/test/integration.shard/project_validator_integration_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:args/command_runner.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/logger.dart'; @@ -15,7 +13,7 @@ import '../src/context.dart'; import '../src/test_flutter_command_runner.dart'; void main() { - FileSystem fileSystem; + late FileSystem fileSystem; group('analyze project command', () { diff --git a/packages/flutter_tools/test/integration.shard/test_driver.dart b/packages/flutter_tools/test/integration.shard/test_driver.dart index fb0ffa08cfc4..654efbd1593b 100644 --- a/packages/flutter_tools/test/integration.shard/test_driver.dart +++ b/packages/flutter_tools/test/integration.shard/test_driver.dart @@ -849,9 +849,9 @@ class FlutterTestTestDriver extends FlutterTestDriver { await resume(); - final Future timeoutFuture = - Future.delayed(defaultTimeout); - await Future.any(>[done.future, timeoutFuture]); + final Future timeoutFuture = + Future.delayed(defaultTimeout); + await Future.any(>[done.future, timeoutFuture]); await subscription.cancel(); if (!done.isCompleted) { await quit(); diff --git a/packages/flutter_tools/test/integration.shard/web_plugin_registrant_test.dart b/packages/flutter_tools/test/integration.shard/web_plugin_registrant_test.dart index 1de865c7599c..48e0b287ee5b 100644 --- a/packages/flutter_tools/test/integration.shard/web_plugin_registrant_test.dart +++ b/packages/flutter_tools/test/integration.shard/web_plugin_registrant_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'dart:async'; import 'package:args/command_runner.dart'; @@ -21,8 +19,8 @@ import '../src/context.dart'; import '../src/test_flutter_command_runner.dart'; void main() { - Directory tempDir; - Directory projectDir; + late Directory tempDir; + late Directory projectDir; setUpAll(() async { Cache.disableLocking(); @@ -195,8 +193,8 @@ Future _createProject(Directory dir, List createArgs) async { Future _addDependency( Directory projectDir, String package, { - String version, - String path, + String? version, + String? path, }) async { assert(version != null || path != null, 'Need to define a source for the package.'); @@ -249,7 +247,7 @@ Future _analyzeEntity(FileSystemEntity target) async { ]; final ProcessResult exec = await Process.run( - globals.artifacts.getHostArtifact(HostArtifact.engineDartBinary).path, + globals.artifacts!.getHostArtifact(HostArtifact.engineDartBinary).path, args, workingDirectory: target is Directory ? target.path : target.dirname, ); @@ -277,7 +275,7 @@ Future _buildWebProject(Directory workingDir) async { ]; final ProcessResult exec = await Process.run( - globals.artifacts.getHostArtifact(HostArtifact.engineDartBinary).path, + globals.artifacts!.getHostArtifact(HostArtifact.engineDartBinary).path, args, workingDirectory: workingDir.path, );