diff --git a/AUTHORS b/AUTHORS index f43f4d12e45..5816fad945f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -74,3 +74,4 @@ Andrey Kabylin vimerzhao Pedro Massango Hidenori Matsubayashi +Perqin Xie 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 815691f1853..a0d33bf454d 100644 --- a/packages/flutter_tools/lib/src/dart/generate_synthetic_packages.dart +++ b/packages/flutter_tools/lib/src/dart/generate_synthetic_packages.dart @@ -37,15 +37,9 @@ Future generateLocalizationsSyntheticPackage({ ); } - BuildResult result; - // If an l10n.yaml file exists but is empty, attempt to build synthetic - // package with default settings. - if (yamlNode.value == null) { - result = await buildSystem.build( - const GenerateLocalizationsTarget(), - environment, - ); - } else { + // If an l10n.yaml file exists and is not empty, attempt to parse settings in + // it. + if (yamlNode.value != null) { final YamlMap yamlMap = yamlNode as YamlMap; final Object value = yamlMap['synthetic-package']; if (value is! bool && value != null) { @@ -63,7 +57,7 @@ Future generateLocalizationsSyntheticPackage({ } } - result = await buildSystem.build( + final BuildResult result = await buildSystem.build( const GenerateLocalizationsTarget(), environment, ); 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 1b203713eb2..b0e1362ba24 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 @@ -18,7 +18,7 @@ import '../../src/context.dart'; import '../../src/fake_process_manager.dart'; void main() { - testWithoutContext('calls buildSystem.build with blank l10n.yaml file', () { + testWithoutContext('calls buildSystem.build with blank l10n.yaml file', () async { // Project directory setup for gen_l10n logic final MemoryFileSystem fileSystem = MemoryFileSystem.test(); @@ -44,7 +44,7 @@ void main() { ); final BuildSystem buildSystem = MockBuildSystem(); - expect( + await expectLater( () => generateLocalizationsSyntheticPackage( environment: environment, buildSystem: buildSystem, @@ -58,7 +58,7 @@ void main() { )).called(1); }); - testWithoutContext('calls buildSystem.build with l10n.yaml synthetic-package: true', () { + testWithoutContext('calls buildSystem.build with l10n.yaml synthetic-package: true', () async { // Project directory setup for gen_l10n logic final MemoryFileSystem fileSystem = MemoryFileSystem.test(); @@ -85,7 +85,7 @@ void main() { ); final BuildSystem buildSystem = MockBuildSystem(); - expect( + await expectLater( () => generateLocalizationsSyntheticPackage( environment: environment, buildSystem: buildSystem, @@ -99,7 +99,7 @@ void main() { )).called(1); }); - testWithoutContext('calls buildSystem.build with l10n.yaml synthetic-package: null', () { + testWithoutContext('calls buildSystem.build with l10n.yaml synthetic-package: null', () async { // Project directory setup for gen_l10n logic final MemoryFileSystem fileSystem = MemoryFileSystem.test(); @@ -124,7 +124,7 @@ void main() { ); final BuildSystem buildSystem = MockBuildSystem(); - expect( + await expectLater( () => generateLocalizationsSyntheticPackage( environment: environment, buildSystem: buildSystem, @@ -171,7 +171,7 @@ void main() { )); }); - testWithoutContext('does not call buildSystem.build with incorrect l10n.yaml format', () { + testWithoutContext('does not call buildSystem.build with incorrect l10n.yaml format', () async { // Project directory setup for gen_l10n logic final MemoryFileSystem fileSystem = MemoryFileSystem.test(); @@ -196,7 +196,7 @@ void main() { ); final BuildSystem buildSystem = MockBuildSystem(); - expect( + await expectLater( () => generateLocalizationsSyntheticPackage( environment: environment, buildSystem: buildSystem, @@ -210,7 +210,7 @@ void main() { )); }); - testWithoutContext('does not call buildSystem.build with non-bool "synthetic-package" value', () { + testWithoutContext('does not call buildSystem.build with non-bool "synthetic-package" value', () async { // Project directory setup for gen_l10n logic final MemoryFileSystem fileSystem = MemoryFileSystem.test(); @@ -235,7 +235,7 @@ void main() { ); final BuildSystem buildSystem = MockBuildSystem(); - expect( + await expectLater( () => generateLocalizationsSyntheticPackage( environment: environment, buildSystem: buildSystem,