mirror of
https://github.com/hanskokx/arcane_framework.git
synced 2026-05-14 10:29:06 +02:00
Remove 'of' and 'requiredOf' locators
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -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 {}
|
||||
|
||||
Reference in New Issue
Block a user