Remove 'of' and 'requiredOf' locators

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2025-04-29 16:43:21 +02:00
parent c3eb677b05
commit d069eb0fd3
2 changed files with 3 additions and 32 deletions
+1 -30
View File
@@ -157,33 +157,4 @@ extension ServiceProviderExtension on BuildContext {
}
/// An abstract class representing a service in the Arcane architecture.
///
/// Classes that extend `ArcaneService` can use `ChangeNotifier` functionality
/// to notify listeners of changes. Services are typically registered in
/// `ArcaneServiceProvider` and can be accessed using the `service`
/// method on `BuildContext`.
abstract class ArcaneService with ChangeNotifier, ArcaneServiceLocators {}
mixin ArcaneServiceLocators<T> {
/// Retrieves a service of the specified type from the context.
///
/// Returns null if no service of type `T` is found.
///
/// Example:
/// ```dart
/// final myService = ArcaneService.of<MyService>(context);
/// ```
static T? of<T extends ArcaneService>(BuildContext context) =>
context.service<T>();
/// Retrieves a service of the specified type from the context.
///
/// Throws an assertion error if no service of type `T` is found.
///
/// Example:
/// ```dart
/// final myService = ArcaneService.requiredOf<MyService>(context);
/// ```
static T requiredOf<T extends ArcaneService>(BuildContext context) =>
context.requiredService<T>();
}
abstract class ArcaneService with ChangeNotifier {}