MCPcopy Create free account
hub / github.com/Dart-Code/Dart-Code / flutterCreate

Method flutterCreate

src/extension/commands/flutter.ts:176–242  ·  view source on GitHub ↗
({ packageName, packagePath, triggerData, platform }: FlutterCreateCommandArgs)

Source from the content-addressed store, hash-verified

174 }
175
176 private async flutterCreate({ packageName, packagePath, triggerData, platform }: FlutterCreateCommandArgs) {
177 if (!packagePath) {
178 packagePath = await getFolderToRunCommandIn(this.logger, `Select the folder to run "flutter create" in`, { flutterOnly: true });
179 if (!packagePath)
180 return;
181 }
182
183 const template = triggerData?.template;
184 const templateAllowsPlatform = template === undefined || flutterCreateTemplatesSupportingPlatforms.includes(template);
185 const defaultPlatforms = config.flutterCreatePlatforms;
186 // Use "--empty" if either the user selected the empty option, or are we enabling a platform.
187 const useEmpty = (template && triggerData?.empty) || (templateAllowsPlatform && platform);
188
189 const args = ["create"];
190 if (config.flutterCreateOffline || config.offline) {
191 args.push("--offline");
192 }
193 if (templateAllowsPlatform) {
194 if (platform) {
195 args.push("--platforms");
196 args.push(platform);
197 } else if (defaultPlatforms) {
198 for (const platform of defaultPlatforms) {
199 args.push("--platforms");
200 args.push(platform);
201 }
202 }
203 }
204 if (packageName) {
205 args.push("--project-name");
206 args.push(packageName);
207 }
208 if (config.flutterCreateOrganization) {
209 args.push("--org");
210 args.push(config.flutterCreateOrganization);
211 }
212 if (config.flutterCreateIOSLanguage && config.flutterCreateIOSLanguage !== "swift" && this.flutterCapabilities.supportsIOSLanguage) {
213 args.push("--ios-language");
214 args.push(config.flutterCreateIOSLanguage);
215 }
216 if (config.flutterCreateAndroidLanguage && config.flutterCreateAndroidLanguage !== "kotlin") {
217 args.push("--android-language");
218 args.push(config.flutterCreateAndroidLanguage);
219 }
220 if (triggerData?.sample) {
221 args.push("--sample");
222 args.push(triggerData.sample);
223 args.push("--overwrite");
224 }
225 if (template) {
226 args.push("--template");
227 args.push(template);
228 args.push("--overwrite");
229 }
230 if (useEmpty)
231 args.push("--empty");
232 args.push(".");
233

Callers

nothing calls this directly

Calls 4

getFolderToRunCommandInFunction · 0.90
runFlutterInFolderMethod · 0.65

Tested by

no test coverage detected