Fix flutter gen-l10n help message (#98147)

This commit is contained in:
Taha Tesser
2022-02-11 11:40:14 +02:00
committed by GitHub
parent 84fcb158e8
commit d6d3283c8d
2 changed files with 26 additions and 1 deletions

View File

@@ -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.'

View File

@@ -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(<String>['gen-l10n']);
expect(command.usage, contains(' If this value is set to false, then '));
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.any(),
});
}