bloom_core library

Flutter-independent core primitives for Bloom applications and servers.

This barrel exports foundational utilities that have zero dependencies on the Flutter SDK or dart:ui:

  • Environment Configuration: BloomEnv for type-safe .env parsing, system variable resolution, and --dart-define compilation values.
  • Structured Logging: BloomLogger and BloomLogLevel for colorized, context-tagged console output and custom log writers.
  • Dependency Injection: BloomContainer and BloomTestScope for hierarchical service resolution, transient/singleton factories, and isolated unit test mocking.

Why Two Barrel Files?

Bloom provides two separate server-side entry points:

  1. package:bloom_server/bloom_core.dart (this barrel): Lightweight core utilities with no HTTP server bindings. Ideal for CLI tools, background workers, isomorphic libraries, or standalone pure-Dart business logic.
  2. package:bloom_server/bloom_server.dart: The complete full-stack server runtime, which re-exports bloom_core.dart along with HTTP routing (BloomApiRouter), request/response models (BloomRequest, BloomResponse), middleware, SSR, and RPC.

Neither barrel imports package:flutter, making them safe to execute in any standard dart run or dart compile exe process.

Example

import 'package:bloom_server/bloom_core.dart';

void main() {
  // Configure environment
  BloomEnv.loadContent('PORT=8080\nDEBUG=true');

  // Register dependencies
  provideSingleton<BloomLogger>(() => BloomLogger(context: 'APP'));

  // Resolve and use
  final appLogger = inject<BloomLogger>();
  appLogger.info('Core runtime initialized on port ${BloomEnv.getInt('PORT')}');
}

Classes

BloomContainer
Lightweight, high-performance Dependency Injection container for Bloom.
BloomEnv
Environment configuration parser, store, and type-safe reader.
BloomLogger
Standardized structured logging system for Bloom servers, apps, and microservices.
BloomTestOverride<T>
Represents a typed test override instance to be injected into a BloomTestScope.
BloomTestScope
A scoped DI harness for running unit and integration tests with isolated overrides.

Enums

BloomLogLevel
Log severity levels for Bloom applications.

Properties

globalContainer → BloomContainer
Accesses the global active Bloom DI container.
no setter
logger → BloomLogger
Global standard logger instance for Bloom framework and applications.
final

Functions

inject<T>() → T
Resolves a dependency of type T from the global active Bloom container.
injectOrNull<T>() → T?
Resolves an optional dependency of type T from the global active Bloom container, or returns null if not registered.
provide<T>(FactoryFunc<T> factory) → void
Registers a transient factory on the global active Bloom container.
provideSingleton<T>(FactoryFunc<T> factory, {bool lazy = true}) → void
Registers a singleton factory on the global active Bloom container.
provideValue<T>(T value) → void
Registers an existing instance value on the global active Bloom container.
resetActiveContainer() → void
Resets the global active container to a fresh, empty BloomContainer instance.
setActiveContainer(BloomContainer container) → void
Sets the currently active global container (used by BloomTestScope for test isolation).

Typedefs

BloomLogWriter = void Function(String message)
Callback signature for handling formatted log line outputs.
FactoryFunc<T> = T Function()
Factory function callback that instantiates a dependency of type T.