Renamed getters on ArcaneService

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2025-04-29 17:25:27 +02:00
parent 304c6c8094
commit d1daf0e39f
2 changed files with 5 additions and 6 deletions
+1 -2
View File
@@ -21,8 +21,7 @@
- [NEW] A `setServices` method was added to `ArcaneServiceProvider`. Invoking this method with a list of `ArcaneService` instances will replace all existing services in the `ArcaneServiceProvider`.
- [DEPRECATED] `context.serviceOfType<T>` has been deprecated in favor of `context.service<T>`.
- [NEW] `context.requiredService<T>` has been added to provide a mechanism for ensuring a particular service has been registered.
- [NEW] `ArcaneService<T>.of(context)` has been added for easy access to service instances. It returns a nullable service instance.
- [NEW] `ArcaneService<T>.requiredOf(context)` has been added. It returns a non-nullable service instance, and throws an exception if the service instance has not been registered.
- [NEW] Added `ArcaneService.ofType<T>(context)` and `ArcaneService.requiredOfType<T>(context)` locators, returning a nullable and non-nullable instance of a given service, respectively.
### Authentication Service (ArcaneAuth)
+4 -4
View File
@@ -169,9 +169,9 @@ abstract class ArcaneService with ChangeNotifier {
///
/// Example:
/// ```dart
/// final myService = ArcaneService.of<MyService>(context);
/// final myService = ArcaneService.ofType<MyService>(context);
/// ```
static T? of<T extends ArcaneService>(BuildContext context) =>
static T? ofType<T extends ArcaneService>(BuildContext context) =>
context.service<T>();
/// Retrieves a service of the specified type from the context.
@@ -180,8 +180,8 @@ abstract class ArcaneService with ChangeNotifier {
///
/// Example:
/// ```dart
/// final myService = ArcaneService.requiredOf<MyService>(context);
/// final myService = ArcaneService.requiredOfType<MyService>(context);
/// ```
static T requiredOf<T extends ArcaneService>(BuildContext context) =>
static T requiredOfType<T extends ArcaneService>(BuildContext context) =>
context.requiredService<T>();
}