From 1a217a7ad7d179e7dcf731a965b629755511567c Mon Sep 17 00:00:00 2001 From: Feichtmeier Date: Sat, 13 Jun 2026 20:19:05 +0200 Subject: [PATCH 1/3] feat: allow params of factories to be used with watchValue and registerHandler --- lib/src/watch_it.dart | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/src/watch_it.dart b/lib/src/watch_it.dart index ff7b317..290e4be 100644 --- a/lib/src/watch_it.dart +++ b/lib/src/watch_it.dart @@ -133,11 +133,14 @@ R watchValue( bool allowObservableChange = false, String? instanceName, GetIt? getIt, + dynamic? param1, + dynamic? param2, }) { assert(_activeWatchItState != null, 'watchValue can only be called inside a build function within a WatchingWidget or a widget using the WatchItMixin'); final getItInstance = getIt ?? di; - final parentObject = getItInstance(instanceName: instanceName); + final parentObject = getItInstance(instanceName: instanceName, + param1: param1, param2: param2); final observedObject = _activeWatchItState!.watchListenable( parentOrListenable: parentObject, selector: selectProperty, @@ -330,12 +333,15 @@ void registerHandler({ bool executeImmediately = false, String? instanceName, GetIt? getIt, + dynamic? param1, + dynamic? param2, }) { assert(_activeWatchItState != null, 'registerHandler can only be called inside a build function within a WatchingWidget or a widget using the WatchItMixin'); final getItInstance = getIt ?? di; - final parentObject = target ?? getItInstance(instanceName: instanceName); + final parentObject = target ?? getItInstance(instanceName: instanceName, + param1: param1, param2: param2); // Validate target type when no select function is provided if (select == null && parentObject is! Listenable) { From 4e4f02899c9453f49d52821cbdf67c3e50305483 Mon Sep 17 00:00:00 2001 From: Feichtmeier Date: Sat, 13 Jun 2026 20:46:37 +0200 Subject: [PATCH 2/3] no ? needed --- lib/src/watch_it.dart | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/src/watch_it.dart b/lib/src/watch_it.dart index 290e4be..13e11cd 100644 --- a/lib/src/watch_it.dart +++ b/lib/src/watch_it.dart @@ -133,14 +133,14 @@ R watchValue( bool allowObservableChange = false, String? instanceName, GetIt? getIt, - dynamic? param1, - dynamic? param2, + dynamic param1, + dynamic param2, }) { assert(_activeWatchItState != null, 'watchValue can only be called inside a build function within a WatchingWidget or a widget using the WatchItMixin'); final getItInstance = getIt ?? di; - final parentObject = getItInstance(instanceName: instanceName, - param1: param1, param2: param2); + final parentObject = getItInstance( + instanceName: instanceName, param1: param1, param2: param2); final observedObject = _activeWatchItState!.watchListenable( parentOrListenable: parentObject, selector: selectProperty, @@ -333,15 +333,16 @@ void registerHandler({ bool executeImmediately = false, String? instanceName, GetIt? getIt, - dynamic? param1, - dynamic? param2, + dynamic param1, + dynamic param2, }) { assert(_activeWatchItState != null, 'registerHandler can only be called inside a build function within a WatchingWidget or a widget using the WatchItMixin'); final getItInstance = getIt ?? di; - final parentObject = target ?? getItInstance(instanceName: instanceName, - param1: param1, param2: param2); + final parentObject = target ?? + getItInstance( + instanceName: instanceName, param1: param1, param2: param2); // Validate target type when no select function is provided if (select == null && parentObject is! Listenable) { From 8992c04aef1703f81d90c59eed36bff83ce33edf Mon Sep 17 00:00:00 2001 From: Feichtmeier Date: Sun, 14 Jun 2026 09:17:07 +0200 Subject: [PATCH 3/3] feat: adapt watchPropertyValue, watchStream, watchFuture, registerChangeNotifierHandler, registerStreamHandler, and registerFutureHandler --- lib/src/watch_it.dart | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/lib/src/watch_it.dart b/lib/src/watch_it.dart index 13e11cd..8841188 100644 --- a/lib/src/watch_it.dart +++ b/lib/src/watch_it.dart @@ -174,13 +174,17 @@ R watchPropertyValue( T? target, String? instanceName, GetIt? getIt, + dynamic param1, + dynamic param2, }) { assert(_activeWatchItState != null, 'watchPropertyValue can only be called inside a build function within a WatchingWidget or a widget using the WatchItMixin'); late final T observedObject; final getItInstance = getIt ?? di; - final parentObject = target ?? getItInstance(instanceName: instanceName); + final parentObject = target ?? + getItInstance( + instanceName: instanceName, param1: param1, param2: param2); final R observedProperty = selectProperty(parentObject); assert( (observedProperty != null && observedProperty is! Listenable) || @@ -222,12 +226,16 @@ AsyncSnapshot watchStream( bool allowStreamChange = false, String? instanceName, GetIt? getIt, + dynamic param1, + dynamic param2, }) { assert(_activeWatchItState != null, 'watchStream can only be called inside a build function within a WatchingWidget or a widget using the WatchItMixin'); final getItInstance = getIt ?? di; - final parentObject = target ?? getItInstance(instanceName: instanceName); + final parentObject = target ?? + getItInstance( + instanceName: instanceName, param1: param1, param2: param2); // Validate target type when no select function is provided if (select == null && parentObject is! Stream) { @@ -274,12 +282,16 @@ AsyncSnapshot watchFuture( bool preserveState = true, bool allowFutureChange = false, GetIt? getIt, + dynamic param1, + dynamic param2, }) { assert(_activeWatchItState != null, 'watchFuture can only be called inside a build function within a WatchingWidget or a widget using the WatchItMixin'); final getItInstance = getIt ?? di; - final parentObject = target ?? getItInstance(instanceName: instanceName); + final parentObject = target ?? + getItInstance( + instanceName: instanceName, param1: param1, param2: param2); // Validate target type when no select function is provided if (select == null && parentObject is! Future) { @@ -382,12 +394,16 @@ void registerChangeNotifierHandler({ bool executeImmediately = false, String? instanceName, GetIt? getIt, + dynamic param1, + dynamic param2, }) { assert(_activeWatchItState != null, 'registerHandler can only be called inside a build function within a WatchingWidget or a widget using the WatchItMixin'); final getItInstance = getIt ?? di; - final parentObject = target ?? getItInstance(instanceName: instanceName); + final parentObject = target ?? + getItInstance( + instanceName: instanceName, param1: param1, param2: param2); _activeWatchItState!.watchListenable( parentOrListenable: parentObject, @@ -423,12 +439,16 @@ void registerStreamHandler({ T? target, String? instanceName, GetIt? getIt, + dynamic param1, + dynamic param2, }) { assert(_activeWatchItState != null, 'registerStreamHandler can only be called inside a build function within a WatchingWidget or a widget using the WatchItMixin'); final getItInstance = getIt ?? di; - final parentObject = target ?? getItInstance(instanceName: instanceName); + final parentObject = target ?? + getItInstance( + instanceName: instanceName, param1: param1, param2: param2); // Validate target type when no select function is provided if (select == null && parentObject is! Stream) { @@ -480,12 +500,16 @@ void registerFutureHandler({ bool callHandlerOnlyOnce = false, bool allowFutureChange = false, GetIt? getIt, + dynamic param1, + dynamic param2, }) { assert(_activeWatchItState != null, 'registerFutureHandler can only be called inside a build function within a WatchingWidget or a widget using the WatchItMixin'); final getItInstance = getIt ?? di; - final parentObject = target ?? getItInstance(instanceName: instanceName); + final parentObject = target ?? + getItInstance( + instanceName: instanceName, param1: param1, param2: param2); // Validate target type when no select function is provided if (select == null && parentObject is! Future) {