Skip to content
Back to archipelago.banuacoder.com

Shared Packages

shared_dependencies Free ​

Tier
Freeversion 1.0.12
Command
archipelago generate shared_dependencies
Generates
  • shared/dependencies
  • shared/dependencies_core

Centralized dependency management with barrel exports for DI, state management, routing, and common packages.

Variables ​

VariableTypeDefaultDescription
appNamestringMyAppThe name of your application
stateManagementenum (bloc, cubit, provider, riverpod)blocState management solution to use
isForMonorepobooleantrueWhether this is being generated as part of a monorepo

Usage ​

Interactive ​

bash
archipelago generate shared_dependencies

Non-interactive (CI) ​

bash
archipelago generate shared_dependencies --config my_config.json

Config Template ​

json
{
  "@appName": "The name of your application",
  "appName": "MyApp",
  "@stateManagement": "State management solution to use (bloc | cubit | provider | riverpod)",
  "stateManagement": "bloc",
  "@isForMonorepo": "Whether this is being generated as part of a monorepo",
  "isForMonorepo": true
}

Generated Structure ​

text
shared/
└── dependencies/
    ├── lib/
    │   ├── auto_route.dart                # Auto-route re-exports
    │   ├── dependencies.dart              # Barrel export (auto_route + di + equality + l10n [+ state])
    │   ├── di.dart                        # get_it + injectable re-exports (from dependencies_core)
    │   ├── equality.dart                  # equatable re-exports (from dependencies_core)
    │   ├── l10n.dart                      # slang + slang_flutter re-exports
    │   ├── meta.dart                      # meta re-exports (from dependencies_core)
    │   ├── network.dart                   # dio re-export — NOT included in dependencies.dart, see below
    │   └── state.dart                     # State management re-exports (only if hasStateManagement)
    ├── analysis_options.yaml
    └── pubspec.yaml
└── dependencies_core/                     # Flutter-free half
    ├── lib/
    │   ├── bloc.dart                      # bloc (only exports for bloc/cubit)
    │   ├── dependencies_core.dart         # Barrel export
    │   ├── di.dart                        # get_it + injectable
    │   ├── equality.dart                  # equatable
    │   └── meta.dart                      # meta
    ├── analysis_options.yaml
    └── pubspec.yaml

Which package to depend on ​

*_api contracts and pure-Dart packages depend on shared/dependencies_core, which needs no Flutter SDK. Flutter packages depend on shared/dependencies, which re-exports it. A package never imports or declares equatable, injectable, get_it, meta, flutter_bloc, auto_route or slang itself; import the specific barrel (equality.dart, di.dart, meta.dart, state.dart, auto_route.dart, l10n.dart). A brick released with dependencies_core generates it itself in an existing project: only the core package is added and shared/dependencies is left as it is until you run this brick again (also when you run that leaf brick with ARCHIPELAGO_FORCE=1; the force applies to the leaf brick only).

network.dart is not in the umbrella barrel ​

dependencies.dart exports auto_route.dart, di.dart, equality.dart, l10n.dart, and (conditionally) state.dart — but not network.dart. Every other file in this package is wired into the umbrella barrel; dio's re-export is the one exception. Import it directly where needed:

dart
import 'package:dependencies/network.dart'; // for dio

This looks like an oversight rather than a deliberate split (nothing else in the package follows a "core vs. opt-in" pattern) — worth filing as a brick inconsistency if network.dart was meant to ship inside the umbrella import.

state.dart Exports by State Management Choice ​

The state.dart barrel file exports different packages depending on the stateManagement variable. A derived boolean usesBloc is computed in pre_gen.dart and is true when stateManagement is either bloc or cubit.

stateManagementDerived flagExports
bloc or cubitusesBloc = trueflutter_bloc/flutter_bloc.dart
providerisProvider = trueprovider/provider.dart + ChangeNotifier from flutter/foundation.dart
riverpodisRiverpod = trueflutter_riverpod + riverpod_annotation

The riverpod barrels (state.dart, dependencies.dart) carry // ignore_for_file: invalid_export_of_internal_element. riverpod_annotation exports $-prefixed bases marked @internal, and riverpod_generator's .g.dart parts reach them through this barrel, so they cannot be hidden.

Dependencies ​

This package's own pubspec.yaml pins the versions every workspace package resolves against: dio: ^5.11.0, auto_route: ^11.1.0, equatable: ^2.1.0, get_it: ^9.2.1, injectable: ^3.0.0 (these three sit in dependencies_core), slang/slang_flutter: ^4.18.0, plus whichever state-management package matches stateManagement (flutter_bloc: ^9.1.1, provider: ^6.1.5+1, or flutter_riverpod: ^3.1.0 + riverpod_annotation: ^4.0.0). No self-generation and no hard dependency on another brick — this is a leaf package that every other feature/infra package depends on.

Known Limitations ​

  • No native platform setup — pure Dart barrel exports.
  • network.dart (dio) is generated but excluded from the dependencies.dart umbrella barrel — see above.
  • Changing stateManagement after generation regenerates state.dart's conditional exports but doesn't retroactively migrate feature code already written against the previous choice.

Changelog ​

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