@@ -32,6 +32,7 @@ import '../stubs/install_stubs.dart';
3232/// | `--without-events` | Skip events setup |
3333/// | `--without-localization` | Skip `assets/lang/` directory |
3434/// | `--without-logging` | Skip `config/logging.dart` |
35+ /// | `--without-broadcasting` | Skip broadcasting setup |
3536class InstallCommand extends Command {
3637 @override
3738 String get name => 'install' ;
@@ -48,11 +49,7 @@ class InstallCommand extends Command {
4849
4950 @override
5051 void configure (ArgParser parser) {
51- parser.addFlag (
52- 'without-auth' ,
53- help: 'Skip auth setup' ,
54- negatable: false ,
55- );
52+ parser.addFlag ('without-auth' , help: 'Skip auth setup' , negatable: false );
5653 parser.addFlag (
5754 'without-database' ,
5855 help: 'Skip database setup' ,
@@ -63,11 +60,7 @@ class InstallCommand extends Command {
6360 help: 'Skip network setup' ,
6461 negatable: false ,
6562 );
66- parser.addFlag (
67- 'without-cache' ,
68- help: 'Skip cache setup' ,
69- negatable: false ,
70- );
63+ parser.addFlag ('without-cache' , help: 'Skip cache setup' , negatable: false );
7164 parser.addFlag (
7265 'without-events' ,
7366 help: 'Skip events setup' ,
@@ -83,6 +76,11 @@ class InstallCommand extends Command {
8376 help: 'Skip logging setup' ,
8477 negatable: false ,
8578 );
79+ parser.addFlag (
80+ 'without-broadcasting' ,
81+ help: 'Skip broadcasting setup' ,
82+ negatable: false ,
83+ );
8684 }
8785
8886 @override
@@ -96,6 +94,7 @@ class InstallCommand extends Command {
9694 final withoutEvents = arguments['without-events' ] as bool ;
9795 final withoutLocalization = arguments['without-localization' ] as bool ;
9896 final withoutLogging = arguments['without-logging' ] as bool ;
97+ final withoutBroadcasting = arguments['without-broadcasting' ] as bool ;
9998
10099 _createDirectories (
101100 root,
@@ -112,6 +111,7 @@ class InstallCommand extends Command {
112111 withoutCache: withoutCache,
113112 withoutLogging: withoutLogging,
114113 withoutLocalization: withoutLocalization,
114+ withoutBroadcasting: withoutBroadcasting,
115115 );
116116
117117 _createStarterFiles (root);
@@ -123,10 +123,11 @@ class InstallCommand extends Command {
123123 withoutNetwork: withoutNetwork,
124124 withoutCache: withoutCache,
125125 withoutLogging: withoutLogging,
126+ withoutBroadcasting: withoutBroadcasting,
126127 );
127128
128129 _patchDefaultWidgetTest (root);
129- _createEnvFiles (root);
130+ _createEnvFiles (root, withoutBroadcasting : withoutBroadcasting );
130131
131132 _registerEnvAsset (root);
132133
@@ -167,10 +168,7 @@ class InstallCommand extends Command {
167168 ];
168169
169170 if (! withoutEvents) {
170- appDirs.addAll ([
171- 'lib/app/listeners' ,
172- 'lib/app/events' ,
173- ]);
171+ appDirs.addAll (['lib/app/listeners' , 'lib/app/events' ]);
174172 }
175173
176174 for (final dir in appDirs) {
@@ -209,6 +207,7 @@ class InstallCommand extends Command {
209207 required bool withoutCache,
210208 required bool withoutLogging,
211209 required bool withoutLocalization,
210+ required bool withoutBroadcasting,
212211 }) {
213212 final providerImports = < String > [];
214213 final providerEntries = < String > [];
@@ -239,6 +238,9 @@ class InstallCommand extends Command {
239238 if (! withoutAuth) {
240239 providerEntries.add ('(app) => VaultServiceProvider(app),' );
241240 }
241+ if (! withoutBroadcasting) {
242+ providerEntries.add ('(app) => BroadcastServiceProvider(app),' );
243+ }
242244
243245 // Auth providers boot AFTER AppServiceProvider (which registers
244246 // userFactory via setUserFactory). AuthServiceProvider.boot()
@@ -291,6 +293,12 @@ class InstallCommand extends Command {
291293 InstallStubs .loggingConfigContent (),
292294 );
293295 }
296+ if (! withoutBroadcasting) {
297+ _writeIfNotExists (
298+ path.join (root, 'lib/config/broadcasting.dart' ),
299+ InstallStubs .broadcastingConfigContent (),
300+ );
301+ }
294302 }
295303
296304 /// Writes the framework starter files that are always created:
@@ -342,6 +350,7 @@ class InstallCommand extends Command {
342350 required bool withoutNetwork,
343351 required bool withoutCache,
344352 required bool withoutLogging,
353+ required bool withoutBroadcasting,
345354 }) {
346355 final mainPath = path.join (root, 'lib/main.dart' );
347356
@@ -358,10 +367,7 @@ class InstallCommand extends Command {
358367 "import 'config/view.dart';" ,
359368 ];
360369
361- final configFactories = < String > [
362- '() => appConfig' ,
363- '() => viewConfig' ,
364- ];
370+ final configFactories = < String > ['() => appConfig' , '() => viewConfig' ];
365371
366372 if (! withoutAuth) {
367373 configImports.add ("import 'config/auth.dart';" );
@@ -383,6 +389,10 @@ class InstallCommand extends Command {
383389 configImports.add ("import 'config/logging.dart';" );
384390 configFactories.add ('() => loggingConfig' );
385391 }
392+ if (! withoutBroadcasting) {
393+ configImports.add ("import 'config/broadcasting.dart';" );
394+ configFactories.add ('() => broadcastingConfig' );
395+ }
386396
387397 final appName = _getAppName (root);
388398
@@ -420,26 +430,29 @@ class InstallCommand extends Command {
420430 return ;
421431 }
422432
423- FileHelper .writeFile (
424- widgetTestPath,
425- InstallStubs .widgetTestContent (),
426- );
433+ FileHelper .writeFile (widgetTestPath, InstallStubs .widgetTestContent ());
427434 }
428435
429436 /// Writes `.env` and `.env.example` to [root] if they do not already exist.
430437 ///
431438 /// [root] — absolute path to the Flutter project root.
432- void _createEnvFiles (String root) {
439+ /// [withoutBroadcasting] — when `true` , omits broadcasting env vars.
440+ void _createEnvFiles (String root, {required bool withoutBroadcasting}) {
433441 final appName = _getAppName (root);
434442
435443 _writeIfNotExists (
436444 path.join (root, '.env' ),
437- InstallStubs .envContent (appName: appName),
445+ InstallStubs .envContent (
446+ appName: appName,
447+ withoutBroadcasting: withoutBroadcasting,
448+ ),
438449 );
439450
440451 _writeIfNotExists (
441452 path.join (root, '.env.example' ),
442- InstallStubs .envExampleContent (),
453+ InstallStubs .envExampleContent (
454+ withoutBroadcasting: withoutBroadcasting,
455+ ),
443456 );
444457 }
445458
0 commit comments