forked from firka/flutter
Migrate localizations and generate_synthetic_packages to null safety (#83310)
This commit is contained in:
@@ -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<String, Object> dependencies = json.decode(
|
||||
environment.buildDir.childFile(_kDependenciesFileName).readAsStringSync()
|
||||
) as Map<String, Object>;
|
||||
final List<Object?>? inputs = dependencies['inputs'] as List<Object?>?;
|
||||
final List<Object?>? outputs = dependencies['outputs'] as List<Object?>?;
|
||||
final Depfile depfile = Depfile(
|
||||
<File>[
|
||||
configFile,
|
||||
for (dynamic inputFile in dependencies['inputs'] as List<dynamic>)
|
||||
environment.fileSystem.file(inputFile)
|
||||
if (inputs != null)
|
||||
for (Object inputFile in inputs.whereType<Object>())
|
||||
environment.fileSystem.file(inputFile)
|
||||
],
|
||||
<File>[
|
||||
for (dynamic outputFile in dependencies['outputs'] as List<dynamic>)
|
||||
environment.fileSystem.file(outputFile)
|
||||
if (outputs != null)
|
||||
for (Object outputFile in outputs.whereType<Object>())
|
||||
environment.fileSystem.file(outputFile)
|
||||
],
|
||||
);
|
||||
depfileService.writeToFile(
|
||||
|
||||
@@ -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<void> 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<void> 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<void> 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<void> generateLocalizationsSyntheticPackage({
|
||||
throwToolExit(
|
||||
'Generating synthetic localizations package failed with ${result.exceptions.length} ${pluralize('error', result.exceptions.length)}:'
|
||||
'\n\n'
|
||||
'${result.exceptions.values.map<Object>((ExceptionMeasurement e) => e.exception).join('\n\n')}',
|
||||
'${result.exceptions.values.map<Object?>((ExceptionMeasurement e) => e.exception).join('\n\n')}',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user