diff --git a/packages/flutter_tools/lib/src/commands/generate_localizations.dart b/packages/flutter_tools/lib/src/commands/generate_localizations.dart index 17bf069712..a34c87d0b2 100644 --- a/packages/flutter_tools/lib/src/commands/generate_localizations.dart +++ b/packages/flutter_tools/lib/src/commands/generate_localizations.dart @@ -175,7 +175,7 @@ class GenerateLocalizationsCommand extends FlutterCommand { '\n' 'By default, this value is set to true so that ' 'Localizations.of(context) returns a nullable value ' - 'for backwards compatibility. If this value is set to true, then ' + 'for backwards compatibility. If this value is set to false, then ' 'a null check is performed on the returned value of ' 'Localizations.of(context), removing the need for null checking in ' 'user code.' diff --git a/packages/flutter_tools/test/commands.shard/hermetic/generate_localizations_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/generate_localizations_test.dart index f3b9d6e9a8..89d19d5328 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/generate_localizations_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/generate_localizations_test.dart @@ -152,4 +152,29 @@ void main() { FileSystem: () => fileSystem, ProcessManager: () => FakeProcessManager.any(), }); + + testUsingContext('nullable-getter help message is expected string', () async { + final BufferLogger logger = BufferLogger.test(); + final File arbFile = fileSystem.file(fileSystem.path.join('lib', 'l10n', 'app_en.arb')) + ..createSync(recursive: true); + arbFile.writeAsStringSync(''' +{ + "helloWorld": "Hello, World!", + "@helloWorld": { + "description": "Sample description" + } +}'''); + fileSystem.file('l10n.yaml').createSync(); + final File pubspecFile = fileSystem.file('pubspec.yaml')..createSync(); + pubspecFile.writeAsStringSync(BasicProjectWithFlutterGen().pubspec); + final GenerateLocalizationsCommand command = GenerateLocalizationsCommand( + fileSystem: fileSystem, + logger: logger, + ); + await createTestCommandRunner(command).run(['gen-l10n']); + expect(command.usage, contains(' If this value is set to false, then ')); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => FakeProcessManager.any(), + }); }