Make flutter create --smaple null-safe (#74844)

This commit is contained in:
Michael Goderbauer
2021-01-27 14:44:03 -08:00
committed by GitHub
parent d11fe85676
commit 63267e9016
6 changed files with 21 additions and 3 deletions

View File

@@ -1602,6 +1602,20 @@ void main() {
HttpClientFactory: () => () => MockHttpClient(200, result: 'void main() {}'),
});
testUsingContext('null-safe sample-based project have no analyzer errors', () async {
await _createAndAnalyzeProject(
projectDir,
<String>['--no-pub', '--sample=foo.bar.Baz'],
<String>['lib/main.dart'],
);
expect(
projectDir.childDirectory('lib').childFile('main.dart').readAsStringSync(),
contains('String?'), // uses null-safe syntax
);
}, overrides: <Type, Generator>{
HttpClientFactory: () => () => MockHttpClient(200, result: 'void main() { String? foo; print(foo); }'),
});
testUsingContext('can write samples index to disk', () async {
final String outputFile = globals.fs.path.join(tempDir.path, 'flutter_samples.json');
final CreateCommand command = CreateCommand();