@@ -66,6 +66,12 @@ const String samplesIndexJson = '''
6666 { "id": "sample2" }
6767]''' ;
6868
69+ /// These files are generated for all project types.
70+ const List <String > flutterPluginsIgnores = < String > [
71+ '.flutter-plugins' ,
72+ '.flutter-plugins-dependencies' ,
73+ ];
74+
6975void main () {
7076 late Directory tempDir;
7177 late Directory projectDir;
@@ -177,6 +183,7 @@ void main() {
177183 'ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png' ,
178184 'lib/main.dart' ,
179185 ],
186+ expectedGitignoreLines: flutterPluginsIgnores,
180187 );
181188 expect (logger.statusText, contains ('In order to run your application, type:' ));
182189 // Check that we're telling them about documentation
@@ -246,6 +253,7 @@ void main() {
246253 'pubspec.yaml' ,
247254 'README.md' ,
248255 ],
256+ expectedGitignoreLines: flutterPluginsIgnores,
249257 );
250258 return _runFlutterTest (projectDir);
251259 }, overrides: < Type , Generator > {
@@ -288,22 +296,28 @@ void main() {
288296 });
289297
290298 testUsingContext ('creates a module project correctly' , () async {
291- await _createAndAnalyzeProject (projectDir, < String > [
292- '--template=module' ,
293- ], < String > [
294- '.android/app/' ,
295- '.gitignore' ,
296- '.ios/Flutter' ,
297- '.metadata' ,
298- 'analysis_options.yaml' ,
299- 'lib/main.dart' ,
300- 'pubspec.yaml' ,
301- 'README.md' ,
302- 'test/widget_test.dart' ,
303- ], unexpectedPaths: < String > [
304- 'android/' ,
305- 'ios/' ,
306- ]);
299+ await _createAndAnalyzeProject (
300+ projectDir,
301+ < String > [
302+ '--template=module' ,
303+ ],
304+ < String > [
305+ '.android/app/' ,
306+ '.gitignore' ,
307+ '.ios/Flutter' ,
308+ '.metadata' ,
309+ 'analysis_options.yaml' ,
310+ 'lib/main.dart' ,
311+ 'pubspec.yaml' ,
312+ 'README.md' ,
313+ 'test/widget_test.dart' ,
314+ ],
315+ unexpectedPaths: < String > [
316+ 'android/' ,
317+ 'ios/' ,
318+ ],
319+ expectedGitignoreLines: flutterPluginsIgnores,
320+ );
307321 return _runFlutterTest (projectDir);
308322 }, overrides: < Type , Generator > {
309323 Pub : () => Pub .test (
@@ -568,6 +582,7 @@ void main() {
568582 'linux/flutter/generated_plugins.cmake' ,
569583 'macos/Flutter/GeneratedPluginRegistrant.swift' ,
570584 ],
585+ expectedGitignoreLines: flutterPluginsIgnores,
571586 );
572587 return _runFlutterTest (projectDir);
573588 }, overrides: < Type , Generator > {
@@ -599,6 +614,7 @@ void main() {
599614 'example/android/app/src/main/java/com/example/flutter_project_example/MainActivity.java' ,
600615 'lib/flutter_project_web.dart' ,
601616 ],
617+ expectedGitignoreLines: flutterPluginsIgnores,
602618 );
603619 return _runFlutterTest (projectDir.childDirectory ('example' ));
604620 }, overrides: < Type , Generator > {
@@ -2148,6 +2164,7 @@ void main() {
21482164 'ios/Flutter/AppFrameworkInfo.plist' ,
21492165 ],
21502166 unexpectedPaths: < String > ['test' ],
2167+ expectedGitignoreLines: flutterPluginsIgnores,
21512168 );
21522169 expect (projectDir.childDirectory ('lib' ).childFile ('main.dart' ).readAsStringSync (),
21532170 contains ("Text('Hello World!')" ));
@@ -2236,6 +2253,7 @@ void main() {
22362253 'ios/Flutter/AppFrameworkInfo.plist' ,
22372254 ],
22382255 unexpectedPaths: < String > ['test' ],
2256+ expectedGitignoreLines: flutterPluginsIgnores,
22392257 );
22402258 expect (projectDir.childDirectory ('lib' ).childFile ('main.dart' ).readAsStringSync (),
22412259 contains ('void main() {}' ));
@@ -3915,6 +3933,7 @@ Future<void> _createProject(
39153933 List <String > createArgs,
39163934 List <String > expectedPaths, {
39173935 List <String > unexpectedPaths = const < String > [],
3936+ List <String > expectedGitignoreLines = const < String > [],
39183937}) async {
39193938 Cache .flutterRoot = '../..' ;
39203939 final CreateCommand command = CreateCommand ();
@@ -3930,24 +3949,41 @@ Future<void> _createProject(
39303949 return globals.fs.typeSync (fullPath) != FileSystemEntityType .notFound;
39313950 }
39323951
3933- final List <String > failures = < String > [
3952+ final List <String > pathFailures = < String > [
39343953 for (final String path in expectedPaths)
39353954 if (! pathExists (path))
39363955 'Path "$path " does not exist.' ,
39373956 for (final String path in unexpectedPaths)
39383957 if (pathExists (path))
39393958 'Path "$path " exists when it shouldn\' t.' ,
39403959 ];
3941- expect (failures, isEmpty, reason: failures.join ('\n ' ));
3960+ expect (pathFailures, isEmpty, reason: pathFailures.join ('\n ' ));
3961+
3962+ final String gitignorePath = globals.fs.path.join (dir.path, '.gitignore' );
3963+ final List <String > gitignore = globals.fs.file (gitignorePath).readAsLinesSync ();
3964+
3965+ final List <String > gitignoreFailures = < String > [
3966+ for (final String line in expectedGitignoreLines)
3967+ if (! gitignore.contains (line))
3968+ 'Expected .gitignore to contain "$line ".' ,
3969+ ];
3970+ expect (gitignoreFailures, isEmpty, reason: gitignoreFailures.join ('\n ' ));
39423971}
39433972
39443973Future <void > _createAndAnalyzeProject (
39453974 Directory dir,
39463975 List <String > createArgs,
39473976 List <String > expectedPaths, {
39483977 List <String > unexpectedPaths = const < String > [],
3978+ List <String > expectedGitignoreLines = const < String > [],
39493979}) async {
3950- await _createProject (dir, createArgs, expectedPaths, unexpectedPaths: unexpectedPaths);
3980+ await _createProject (
3981+ dir,
3982+ createArgs,
3983+ expectedPaths,
3984+ unexpectedPaths: unexpectedPaths,
3985+ expectedGitignoreLines: expectedGitignoreLines,
3986+ );
39513987 await _analyzeProject (dir.path);
39523988}
39533989
0 commit comments