@@ -192,6 +192,7 @@ class CreateCommand extends CreateBase {
192192 }
193193
194194 validateOutputDirectoryArg ();
195+
195196 String ? sampleCode;
196197 final String ? sampleArgument = stringArg ('sample' );
197198 if (sampleArgument != null ) {
@@ -254,29 +255,7 @@ class CreateCommand extends CreateBase {
254255 }
255256
256257 final String dartSdk = globals.cache.dartSdkBuild;
257- final bool includeIos;
258- final bool includeAndroid;
259- final bool includeWeb;
260- final bool includeLinux;
261- final bool includeMacos;
262- final bool includeWindows;
263- if (template == FlutterProjectType .module) {
264- // The module template only supports iOS and Android.
265- includeIos = true ;
266- includeAndroid = true ;
267- includeWeb = false ;
268- includeLinux = false ;
269- includeMacos = false ;
270- includeWindows = false ;
271- } else {
272- includeIos = featureFlags.isIOSEnabled && platforms.contains ('ios' );
273- includeAndroid = featureFlags.isAndroidEnabled && platforms.contains ('android' );
274- includeWeb = featureFlags.isWebEnabled && platforms.contains ('web' );
275- includeLinux = featureFlags.isLinuxEnabled && platforms.contains ('linux' );
276- includeMacos = featureFlags.isMacOSEnabled && platforms.contains ('macos' );
277- includeWindows = featureFlags.isWindowsEnabled && platforms.contains ('windows' );
278- }
279-
258+ final bool includeIos = featureFlags.isIOSEnabled && platforms.contains ('ios' );
280259 String ? developmentTeam;
281260 if (includeIos) {
282261 developmentTeam = await getCodeSigningIdentityDevelopmentTeam (
@@ -303,11 +282,11 @@ class CreateCommand extends CreateBase {
303282 iosLanguage: stringArgDeprecated ('ios-language' ),
304283 iosDevelopmentTeam: developmentTeam,
305284 ios: includeIos,
306- android: includeAndroid ,
307- web: includeWeb ,
308- linux: includeLinux ,
309- macos: includeMacos ,
310- windows: includeWindows ,
285+ android: featureFlags.isAndroidEnabled && platforms. contains ( 'android' ) ,
286+ web: featureFlags.isWebEnabled && platforms. contains ( 'web' ) ,
287+ linux: featureFlags.isLinuxEnabled && platforms. contains ( 'linux' ) ,
288+ macos: featureFlags.isMacOSEnabled && platforms. contains ( 'macos' ) ,
289+ windows: featureFlags.isWindowsEnabled && platforms. contains ( 'windows' ) ,
311290 // Enable null safety everywhere.
312291 dartSdkVersionBounds: "'>=$dartSdk <3.0.0'" ,
313292 implementationTests: boolArgDeprecated ('implementation-tests' ),
@@ -330,7 +309,6 @@ class CreateCommand extends CreateBase {
330309
331310 final Directory relativeDir = globals.fs.directory (projectDirPath);
332311 int generatedFileCount = 0 ;
333- final PubContext pubContext;
334312 switch (template) {
335313 case FlutterProjectType .app:
336314 generatedFileCount += await generateApp (
@@ -341,7 +319,6 @@ class CreateCommand extends CreateBase {
341319 printStatusWhenWriting: ! creatingNewProject,
342320 projectType: template,
343321 );
344- pubContext = PubContext .create;
345322 break ;
346323 case FlutterProjectType .skeleton:
347324 generatedFileCount += await generateApp (
@@ -352,7 +329,6 @@ class CreateCommand extends CreateBase {
352329 printStatusWhenWriting: ! creatingNewProject,
353330 generateMetadata: false ,
354331 );
355- pubContext = PubContext .create;
356332 break ;
357333 case FlutterProjectType .module:
358334 generatedFileCount += await _generateModule (
@@ -361,7 +337,6 @@ class CreateCommand extends CreateBase {
361337 overwrite: overwrite,
362338 printStatusWhenWriting: ! creatingNewProject,
363339 );
364- pubContext = PubContext .create;
365340 break ;
366341 case FlutterProjectType .package:
367342 generatedFileCount += await _generatePackage (
@@ -370,7 +345,6 @@ class CreateCommand extends CreateBase {
370345 overwrite: overwrite,
371346 printStatusWhenWriting: ! creatingNewProject,
372347 );
373- pubContext = PubContext .createPackage;
374348 break ;
375349 case FlutterProjectType .plugin:
376350 generatedFileCount += await _generateMethodChannelPlugin (
@@ -380,7 +354,6 @@ class CreateCommand extends CreateBase {
380354 printStatusWhenWriting: ! creatingNewProject,
381355 projectType: template,
382356 );
383- pubContext = PubContext .createPlugin;
384357 break ;
385358 case FlutterProjectType .ffiPlugin:
386359 generatedFileCount += await _generateFfiPlugin (
@@ -390,26 +363,8 @@ class CreateCommand extends CreateBase {
390363 printStatusWhenWriting: ! creatingNewProject,
391364 projectType: template,
392365 );
393- pubContext = PubContext .createPlugin;
394366 break ;
395367 }
396-
397- if (boolArgDeprecated ('pub' )) {
398- final FlutterProject project = FlutterProject .fromDirectory (relativeDir);
399- await pub.get (
400- context: pubContext,
401- project: project,
402- offline: boolArgDeprecated ('offline' ),
403- );
404- await project.ensureReadyForPlatformSpecificTooling (
405- androidPlatform: includeAndroid,
406- iosPlatform: includeIos,
407- linuxPlatform: includeLinux,
408- macOSPlatform: includeMacos,
409- windowsPlatform: includeWindows,
410- webPlatform: includeWeb,
411- );
412- }
413368 if (sampleCode != null ) {
414369 generatedFileCount += _applySample (relativeDir, sampleCode);
415370 }
@@ -492,6 +447,18 @@ Your $application code is in $relativeAppMain.
492447 overwrite: overwrite,
493448 printStatusWhenWriting: printStatusWhenWriting,
494449 );
450+ if (boolArgDeprecated ('pub' )) {
451+ await pub.get (
452+ context: PubContext .create,
453+ directory: directory.path,
454+ offline: boolArgDeprecated ('offline' ),
455+ );
456+ final FlutterProject project = FlutterProject .fromDirectory (directory);
457+ await project.ensureReadyForPlatformSpecificTooling (
458+ androidPlatform: true ,
459+ iosPlatform: true ,
460+ );
461+ }
495462 return generatedCount;
496463 }
497464
@@ -513,6 +480,13 @@ Your $application code is in $relativeAppMain.
513480 overwrite: overwrite,
514481 printStatusWhenWriting: printStatusWhenWriting,
515482 );
483+ if (boolArgDeprecated ('pub' )) {
484+ await pub.get (
485+ context: PubContext .createPackage,
486+ directory: directory.path,
487+ offline: boolArgDeprecated ('offline' ),
488+ );
489+ }
516490 return generatedCount;
517491 }
518492
@@ -552,6 +526,14 @@ Your $application code is in $relativeAppMain.
552526 printStatusWhenWriting: printStatusWhenWriting,
553527 );
554528
529+ if (boolArgDeprecated ('pub' )) {
530+ await pub.get (
531+ context: PubContext .createPlugin,
532+ directory: directory.path,
533+ offline: boolArgDeprecated ('offline' ),
534+ );
535+ }
536+
555537 final FlutterProject project = FlutterProject .fromDirectory (directory);
556538 final bool generateAndroid = templateContext['android' ] == true ;
557539 if (generateAndroid) {
@@ -622,6 +604,14 @@ Your $application code is in $relativeAppMain.
622604 printStatusWhenWriting: printStatusWhenWriting,
623605 );
624606
607+ if (boolArgDeprecated ('pub' )) {
608+ await pub.get (
609+ context: PubContext .createPlugin,
610+ directory: directory.path,
611+ offline: boolArgDeprecated ('offline' ),
612+ );
613+ }
614+
625615 final FlutterProject project = FlutterProject .fromDirectory (directory);
626616 final bool generateAndroid = templateContext['android' ] == true ;
627617 if (generateAndroid) {
0 commit comments