diff --git a/packages/flutter_tools/lib/src/build_system/targets/localizations.dart b/packages/flutter_tools/lib/src/build_system/targets/localizations.dart index 6767ca308ed..05c0e7fd382 100644 --- a/packages/flutter_tools/lib/src/build_system/targets/localizations.dart +++ b/packages/flutter_tools/lib/src/build_system/targets/localizations.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 '../../base/file_system.dart'; import '../../convert.dart'; import '../../localizations/gen_l10n.dart'; @@ -69,15 +67,19 @@ class GenerateLocalizationsTarget extends Target { final Map dependencies = json.decode( environment.buildDir.childFile(_kDependenciesFileName).readAsStringSync() ) as Map; + final List? inputs = dependencies['inputs'] as List?; + final List? outputs = dependencies['outputs'] as List?; final Depfile depfile = Depfile( [ configFile, - for (dynamic inputFile in dependencies['inputs'] as List) - environment.fileSystem.file(inputFile) + if (inputs != null) + for (Object inputFile in inputs.whereType()) + environment.fileSystem.file(inputFile) ], [ - for (dynamic outputFile in dependencies['outputs'] as List) - environment.fileSystem.file(outputFile) + if (outputs != null) + for (Object outputFile in outputs.whereType()) + environment.fileSystem.file(outputFile) ], ); depfileService.writeToFile( diff --git a/packages/flutter_tools/lib/src/dart/generate_synthetic_packages.dart b/packages/flutter_tools/lib/src/dart/generate_synthetic_packages.dart index 66ca9b38ef2..039add90642 100644 --- a/packages/flutter_tools/lib/src/dart/generate_synthetic_packages.dart +++ b/packages/flutter_tools/lib/src/dart/generate_synthetic_packages.dart @@ -2,9 +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:meta/meta.dart'; import 'package:yaml/yaml.dart'; import '../base/common.dart'; @@ -14,8 +11,8 @@ import '../build_system/build_system.dart'; import '../build_system/targets/localizations.dart'; Future generateLocalizationsSyntheticPackage({ - @required Environment environment, - @required BuildSystem buildSystem, + required Environment environment, + required BuildSystem buildSystem, }) async { assert(environment != null); assert(buildSystem != null); @@ -42,7 +39,7 @@ Future generateLocalizationsSyntheticPackage({ // it. if (yamlNode.value != null) { final YamlMap yamlMap = yamlNode as YamlMap; - final Object value = yamlMap['synthetic-package']; + final Object? value = yamlMap['synthetic-package']; if (value is! bool && value != null) { throwToolExit( 'Expected "synthetic-package" to have a bool value, ' @@ -52,8 +49,8 @@ Future generateLocalizationsSyntheticPackage({ // Generate gen_l10n synthetic package only if synthetic-package: true or // synthetic-package is null. - final bool isSyntheticL10nPackage = value as bool ?? true; - if (!isSyntheticL10nPackage) { + final bool? isSyntheticL10nPackage = value as bool?; + if (isSyntheticL10nPackage == false) { return; } } @@ -70,7 +67,7 @@ Future generateLocalizationsSyntheticPackage({ throwToolExit( 'Generating synthetic localizations package failed with ${result.exceptions.length} ${pluralize('error', result.exceptions.length)}:' '\n\n' - '${result.exceptions.values.map((ExceptionMeasurement e) => e.exception).join('\n\n')}', + '${result.exceptions.values.map((ExceptionMeasurement e) => e.exception).join('\n\n')}', ); } } diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/localizations_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/localizations_test.dart index 64e053e47d1..4e07a525c85 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/localizations_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/localizations_test.dart @@ -2,9 +2,8 @@ // 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'; import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/build_system/build_system.dart'; @@ -19,7 +18,7 @@ void main() { final FileSystem fileSystem = MemoryFileSystem.test(); final Environment environment = Environment.test( fileSystem.currentDirectory, - artifacts: null, + artifacts: Artifacts.test(), fileSystem: fileSystem, logger: BufferLogger.test(), processManager: FakeProcessManager.any(), diff --git a/packages/flutter_tools/test/general.shard/dart/generate_synthetic_packages_test.dart b/packages/flutter_tools/test/general.shard/dart/generate_synthetic_packages_test.dart index 81bbb0e20d6..e086e171321 100644 --- a/packages/flutter_tools/test/general.shard/dart/generate_synthetic_packages_test.dart +++ b/packages/flutter_tools/test/general.shard/dart/generate_synthetic_packages_test.dart @@ -2,7 +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'; @@ -45,7 +44,7 @@ void main() { ); final Completer completer = Completer(); final BuildResult exception = BuildResult(success: false, exceptions: { - 'hello': ExceptionMeasurement('hello', const FormatException('illegal character in input string'), null), + 'hello': ExceptionMeasurement('hello', const FormatException('illegal character in input string'), StackTrace.current), }); final TestBuildSystem buildSystem = TestBuildSystem.all(exception, (Target target, Environment environment) { expect(target, const GenerateLocalizationsTarget()); @@ -94,7 +93,7 @@ void main() { ); final Completer completer = Completer(); final BuildResult exception = BuildResult(success: false, exceptions: { - 'hello': ExceptionMeasurement('hello', const FormatException('illegal character in input string'), null), + 'hello': ExceptionMeasurement('hello', const FormatException('illegal character in input string'), StackTrace.current), }); final TestBuildSystem buildSystem = TestBuildSystem.all(exception, (Target target, Environment environment) { expect(target, const GenerateLocalizationsTarget()); @@ -141,7 +140,7 @@ void main() { ); final Completer completer = Completer(); final BuildResult exception = BuildResult(success: false, exceptions: { - 'hello': ExceptionMeasurement('hello', const FormatException('illegal character in input string'), null), + 'hello': ExceptionMeasurement('hello', const FormatException('illegal character in input string'), StackTrace.current), }); final TestBuildSystem buildSystem = TestBuildSystem.all(exception, (Target target, Environment environment) { expect(target, const GenerateLocalizationsTarget());