Skip to content
Back to archipelago.banuacoder.com

Shared Packages

app_utilities Free ​

Tier
Freeversion 1.0.7
Command
archipelago generate app_utilities
Generates
  • utilities/app_utilities

Shared utilities package: a Log wrapper around the logger package, a third-party DI module, and safe (never-throwing) crash-reporting helper functions.

What it is ​

Every generated monorepo needs one place that every other package can depend on for logging without pulling in logger directly, plus a landing spot for crash-reporting calls before real monitoring DI is wired up. app_utilities is that package — it is normally generated once, early, as part of flutter_modular_monorepo scaffolding, and every feature package depends on it for Log.

Variables ​

VariableTypeDefaultDescription
appNamestringMyAppThe name of your application
isForMonorepobooleantrueWhether this is being generated as part of a monorepo

Note: unlike most shared packages, isForMonorepo does not change the output path here — the package always lands at utilities/app_utilities/. It only controls whether post_gen.dart registers the package into the melos workspace (see below). appName is declared but not referenced anywhere in __brick__/ — it has no observable effect on the generated output.

Usage ​

Interactive ​

bash
archipelago generate app_utilities

Non-interactive (CI) ​

bash
archipelago generate app_utilities --config my_config.json

Generated Structure ​

text
utilities/
└── app_utilities/
    ├── analysis_options.yaml
    ├── build.yaml
    ├── lib/
    │   ├── app_utilities.dart                # Barrel export
    │   └── src/
    │       ├── di/
    │       │   ├── injector.dart             # @microPackageInit entrypoint
    │       │   └── third_party_module.dart   # Provides the shared Logger
    │       ├── error/
    │       │   └── safe_crash_reporter.dart  # Never-throwing crash-report helpers
    │       └── log/
    │           ├── log.dart                  # Log wrapper class + LogType enum
    │           ├── filter/
    │           │   └── release_log_filter.dart
    │           └── printer/
    │               └── simple_log_printer.dart
    └── pubspec.yaml

Public API ​

Log ​

An injectable (@LazySingleton) wrapper around package:logger, exposing leveled methods plus a lazy variant that skips string construction unless logging actually happens:

dart
@injectable
class MyService {
  MyService(this._log);
  final Log _log;

  void doWork() {
    _log.i('Starting work');
    _log.consoleLazy(() => 'Expensive message: ${computeDetails()}');
  }
}

Log exposes t/d/i/w/e/f (trace/debug/info/warning/error/fatal), plus console(message, type: LogType.info) and consoleLazy(() => message, type: LogType.info) for enum-based level selection. LogType has verbose, debug, info, warning, error, fatal.

Safe crash reporters ​

safe_crash_reporter.dart exposes three top-level functions that are safe to call at any point in the app lifecycle (never throw): safeReportFatalCrash(Object error, StackTrace stackTrace), safeReportFlutterFatalCrash(FlutterErrorDetails details) (silently drops spurious CupertinoLocalizations/localization-delegate errors), and safeReportNonFatalCrash(Object error, StackTrace stackTrace). In debug mode they print to console; in release, bootstrap.dart wires the real monitoring call through GetIt after DI initializes, so these act as a lightweight fallback surface before that wiring exists.

DI ​

ThirdPartyModule (@module) provides the shared Logger instance (configured with ReleaseLogFilter + SimpleLogPrinter). injectUtilityModule() (@microPackageInit) is the package's DI-init entrypoint; the app's root injector registers the generated AppUtilitiesPackageModule as an external module.

Wiring ​

hooks/post_gen.dart calls WorkspaceHelper.addToWorkspace(rootPath, 'utilities/app_utilities') (from shared_hooks) when isForMonorepo is true, registering the package into the melos workspace. When isForMonorepo is false, generation completes standalone with no workspace patch.

Dependencies ​

Depends on the workspace's shared/dependencies package (path dependency) plus get_it, injectable, and logger. No dependency on other Archipelago bricks.

Limitations ​

No native/platform setup — this is a pure Dart/Flutter package with no platform channels.

Changelog ​

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