Update ServiceProvider to make service instances optional

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2025-05-13 15:00:58 +02:00
parent 0c5568ab74
commit 7bf5a6d33d
@@ -21,14 +21,14 @@ class ArcaneServiceProvider
extends InheritedNotifier<ValueNotifier<List<ArcaneService>>> { extends InheritedNotifier<ValueNotifier<List<ArcaneService>>> {
/// A list of `ArcaneService` instances available through the provider. /// A list of `ArcaneService` instances available through the provider.
List<ArcaneService> get registeredServices => List<ArcaneService> get registeredServices =>
List<ArcaneService>.from(notifier?.value ?? []); List<ArcaneService>.from([...?notifier?.value]);
/// Creates an `ArcaneServiceProvider` that provides [serviceInstances] to the widget tree. /// Creates an `ArcaneServiceProvider` that provides [serviceInstances] to the widget tree.
/// ///
/// The [child] widget will be the root of the widget subtree that has access to the services. /// The [child] widget will be the root of the widget subtree that has access to the services.
ArcaneServiceProvider({ ArcaneServiceProvider({
required List<ArcaneService> serviceInstances,
required super.child, required super.child,
List<ArcaneService> serviceInstances = const [],
super.key, super.key,
}) : super( }) : super(
notifier: ValueNotifier<List<ArcaneService>>(serviceInstances), notifier: ValueNotifier<List<ArcaneService>>(serviceInstances),