From d1daf0e39f71994e2f27ade218a693512e3a0522 Mon Sep 17 00:00:00 2001 From: Hans Kokx Date: Tue, 29 Apr 2025 17:25:27 +0200 Subject: [PATCH] Renamed getters on ArcaneService Signed-off-by: Hans Kokx --- CHANGELOG.md | 3 +-- lib/src/providers/service_provider.dart | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e134e19..ef1806a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` has been deprecated in favor of `context.service`. - [NEW] `context.requiredService` has been added to provide a mechanism for ensuring a particular service has been registered. -- [NEW] `ArcaneService.of(context)` has been added for easy access to service instances. It returns a nullable service instance. -- [NEW] `ArcaneService.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(context)` and `ArcaneService.requiredOfType(context)` locators, returning a nullable and non-nullable instance of a given service, respectively. ### Authentication Service (ArcaneAuth) diff --git a/lib/src/providers/service_provider.dart b/lib/src/providers/service_provider.dart index 3a0cb21..33d105e 100644 --- a/lib/src/providers/service_provider.dart +++ b/lib/src/providers/service_provider.dart @@ -169,9 +169,9 @@ abstract class ArcaneService with ChangeNotifier { /// /// Example: /// ```dart - /// final myService = ArcaneService.of(context); + /// final myService = ArcaneService.ofType(context); /// ``` - static T? of(BuildContext context) => + static T? ofType(BuildContext context) => context.service(); /// 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(context); + /// final myService = ArcaneService.requiredOfType(context); /// ``` - static T requiredOf(BuildContext context) => + static T requiredOfType(BuildContext context) => context.requiredService(); }