Skip to content
Back to archipelago.banuacoder.com

Scaffolding

initializer_skeleton Free ​

Tier
Freeversion 1.0.6
Command
archipelago generate initializer_skeleton
Generates
one app initializer file in the app’s host/initializers folder

Generate a pre-launch or post-launch app initializer with the standard Initializer base class pattern.

Variables ​

VariableTypeDefaultDescription
appNamestringMyAppThe name of your application
initializerTypeenum (pre_launch, post_launch)pre_launchWhether this is a pre-launch or post-launch initializer
initializerNamestringMyInitializerThe name of the initializer (e.g., analytics, payment)

Install ​

Interactive ​

bash
archipelago generate initializer_skeleton

Non-interactive (CI) ​

bash
archipelago generate initializer_skeleton --config my_config.json

Run inside an app generated by app_scaffold/flutter_modular_monorepo — it templates one file relative to apps/{appName}/lib/host/initializers/ and does not create the app shell itself. pre_gen derives isPreLaunch/isPostLaunch boolean flags from the initializerType enum for the template's mustache conditionals (these derived flags are not declared in brick.yaml, per repo convention).

Config Template ​

json
{
  "@appName": "The name of your application",
  "appName": "MyApp",
  "@initializerType": "Whether this is a pre-launch or post-launch initializer (pre_launch | post_launch)",
  "initializerType": "pre_launch",
  "@initializerName": "The name of the initializer (e.g., analytics, payment)",
  "initializerName": "MyInitializer"
}

Generated Structure ​

text
apps/
└── {app_name}/
    └── lib/
        └── host/
            └── initializers/
                └── {initializer_name}_app_initializer.dart

Public API ​

The generated class extends Initializer (from app_scaffold's lib/host/initializers/initializer.dart):

dart
class {InitializerName}AppInitializer extends Initializer {
  const {InitializerName}AppInitializer();

  // pre_launch only — post_launch initializers don't get this override:
  @override
  bool get canRunInParallel => false;

  @override
  Future<InitializerResult> initialize() async {
    try {
      // TODO: Add {initializer_name} initialization logic
      return const InitializerResult.success();
    } catch (e) {
      return InitializerResult.failure(e);
    }
  }

  @override
  Future<bool> dispose() async => true;
}

canRunInParallel defaults to true on the base Initializer class; the pre-launch template overrides it to false (sequential) since pre-launch setup is more likely to have ordering dependencies. Post-launch initializers keep the default.

DI & Wiring ​

post_gen registers the initializer for you. It adds the import to the // archipelago:<phase>_imports:start/end region and {InitializerName}AppInitializer(), to the // archipelago:<phase>_initializers:start/end region of pre_launch_initializer.dart or post_launch_initializer.dart (<phase> is pre_launch or post_launch). Run the brick again with the same name and nothing changes. You only add the real logic inside initialize().

If the host file has no such markers (an app made before they existed), the file is still generated and post_gen prints a warning naming the import and list entry to add by hand. It never edits a file it cannot match.

Removing an initializer ​

  1. Delete apps/{appName}/lib/host/initializers/{initializer_name}_app_initializer.dart.
  2. Delete its import line from the <phase>_imports region and its {InitializerName}AppInitializer(), line from the <phase>_initializers region.

Do both: the import without the file breaks analysis, and a second generation re-adds whatever is missing.

Dependencies ​

None beyond the host app itself — this brick generates a single file with no new pubspec dependencies.

Platform Setup ​

None required.

Limitations ​

  • Registration needs the archipelago:<phase>_imports and archipelago:<phase>_initializers markers in the host shell. Apps generated before these markers existed (post-launch ones in particular) must add them or register by hand.
  • Entries are appended in generation order. If order matters between initializers, reorder the lines yourself.

Changelog ​

Run archipelago brick info initializer_skeleton to see the latest published version. Enterprise customers can read the full CHANGELOG.md in the brick source repository.