Files
arcane_framework/lib/src/arcane.dart
T
hans ac82e93b9d [UNTESTED] Fixes notifiers and adds some additional methods. Adds tests.
Changes:
// ArcaneEnvironment
breaking: context.read<ArcaneEnvironment>() -> ArcaneEnvironment.of(context)
breaking: context.read<ArcaneEnvironment>().state -> ArcaneEnvironment.of(context).environment;

// Feature flag service
added: reset()

// Logging service
added: registerInterface()
added: unregisterInterfaces()
added: unregisterAllInterfaces()

// ArcaneReactiveTheme
fixed: currentMode, dark, light now actually emit new values when changed
added: getters for lightTheme, darkTheme, and systemTheme
TODO: test systemTheme

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
2025-04-29 14:16:17 +02:00

81 lines
2.9 KiB
Dart

import "package:arcane_framework/arcane_framework.dart";
/// A singleton class that acts as the central hub for various services in the
/// Arcane framework.
///
/// `Arcane` provides access to important services like logging, feature flags,
/// authentication, theming, secure storage, and ID management. It also offers a
/// convenient method for logging messages using the integrated logger.
abstract class Arcane {
/// Provides access to the singleton instance of the logger service.
///
/// The `ArcaneLogger` is used for logging messages throughout the app.
static ArcaneLogger get logger => ArcaneLogger.I;
/// Provides access to the singleton instance of the feature flags service.
///
/// `ArcaneFeatureFlags` manages feature toggles, allowing you to enable or
/// disable features dynamically.
static ArcaneFeatureFlags get features => ArcaneFeatureFlags.I;
/// Provides access to the singleton instance of the authentication service.
///
/// `ArcaneAuthenticationService` manages user authentication, login, and
/// signup processes.
static ArcaneAuthenticationService get auth => ArcaneAuthenticationService.I;
/// Provides access to the singleton instance of the theme management service.
///
/// `ArcaneReactiveTheme` allows switching between light and dark themes and
/// customizing them.
static ArcaneReactiveTheme get theme => ArcaneReactiveTheme.I;
/// Returns a list of all services available in the Arcane framework.
///
/// This list includes the feature flags, authentication, theme, and ID services.
static List<ArcaneService> get services => [
features,
auth,
theme,
];
/// Logs a message using the integrated logger.
///
/// This method is a convenient way to log messages with optional module,
/// method, log level, stack trace, and additional metadata. The default log
/// level is `Level.debug`.
///
/// Example:
/// ```dart
/// Arcane.log("This is a log message", module: "MyModule", method: "MyMethod");
/// ```
///
/// - [message]: The message to log.
/// - [module]: Optional name of the module from which the log originated.
/// - [method]: Optional name of the method from which the log originated.
/// - [level]: The log level (e.g., `Level.debug`, `Level.error`), defaults to
/// `Level.debug`.
/// - [stackTrace]: Optional stack trace information.
/// - [metadata]: Optional additional metadata in key-value pairs.
/// - [extra]: Optional data passed to the logger.
static void log(
String message, {
String? module,
String? method,
Level level = Level.debug,
StackTrace? stackTrace,
Map<String, String>? metadata,
Object? extra,
}) {
ArcaneLogger.I.log(
message,
module: module,
method: method,
level: level,
stackTrace: stackTrace,
metadata: metadata,
extra: extra,
);
}
}