@@ -82,24 +82,27 @@ class CreateCommand extends FlutterCommand {
82
82
83
83
Directory projectDir = new Directory (argResults.rest.first);
84
84
String dirPath = path.normalize (projectDir.absolute.path);
85
+ String relativePath = path.relative (dirPath);
85
86
String projectName = _normalizeProjectName (path.basename (dirPath));
86
87
87
88
if (_validateProjectDir (dirPath) != null ) {
88
89
printError (_validateProjectDir (dirPath));
89
90
return 1 ;
90
91
}
92
+
91
93
if (_validateProjectName (projectName) != null ) {
92
94
printError (_validateProjectName (projectName));
93
95
return 1 ;
94
96
}
95
97
96
- _renderTemplates (
98
+ int generatedCount = _renderTemplates (
97
99
projectName,
98
100
argResults['description' ],
99
101
dirPath,
100
102
flutterPackagesDirectory,
101
103
renderDriverTest: argResults['with-driver-test' ]
102
104
);
105
+ printStatus ('Wrote $generatedCount files.' );
103
106
104
107
printStatus ('' );
105
108
@@ -119,8 +122,8 @@ class CreateCommand extends FlutterCommand {
119
122
printStatus ('''
120
123
All done! In order to run your application, type:
121
124
122
- \$ cd $dirPath
123
- \$ flutter run
125
+ \$ cd $relativePath
126
+ \$ flutter run lib/main.dart
124
127
''' );
125
128
} else {
126
129
printStatus ("You'll need to install additional components before you can run "
@@ -132,21 +135,21 @@ All done! In order to run your application, type:
132
135
printStatus ('' );
133
136
printStatus ("After installing components, run 'flutter doctor' in order to "
134
137
"re-validate your setup." );
135
- printStatus ("When complete, type 'flutter run' from the '$dirPath ' "
138
+ printStatus ("When complete, type 'flutter run lib/main.dart ' from the '$relativePath ' "
136
139
"directory in order to launch your app." );
137
140
}
138
141
139
142
return 0 ;
140
143
}
141
144
142
- void _renderTemplates (String projectName, String projectDescription, String dirPath,
145
+ int _renderTemplates (String projectName, String projectDescription, String dirPath,
143
146
String flutterPackagesDirectory, { bool renderDriverTest: false }) {
144
147
new Directory (dirPath).createSync (recursive: true );
145
148
146
149
flutterPackagesDirectory = path.normalize (flutterPackagesDirectory);
147
150
flutterPackagesDirectory = _relativePath (from: dirPath, to: flutterPackagesDirectory);
148
151
149
- printStatus ('Creating project ${path .basename ( projectName )}: ' );
152
+ printStatus ('Creating project ${path .relative ( dirPath )}... ' );
150
153
151
154
Map <String , dynamic > templateContext = < String , dynamic > {
152
155
'projectName' : projectName,
@@ -157,18 +160,22 @@ All done! In order to run your application, type:
157
160
'androidMinApiLevel' : android.minApiLevel
158
161
};
159
162
163
+ int fileCount = 0 ;
164
+
160
165
if (renderDriverTest)
161
166
templateContext['withDriverTest?' ] = < String , dynamic > {};
162
167
163
168
Template createTemplate = new Template .fromName ('create' );
164
- createTemplate.render (new Directory (dirPath), templateContext,
169
+ fileCount += createTemplate.render (new Directory (dirPath), templateContext,
165
170
overwriteExisting: false );
166
171
167
172
if (renderDriverTest) {
168
173
Template driverTemplate = new Template .fromName ('driver' );
169
- driverTemplate.render (new Directory (path.join (dirPath, 'test_driver' )),
174
+ fileCount += driverTemplate.render (new Directory (path.join (dirPath, 'test_driver' )),
170
175
templateContext, overwriteExisting: false );
171
176
}
177
+
178
+ return fileCount;
172
179
}
173
180
}
174
181
0 commit comments