You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have created a generic StateNotifier with class members as well, something like this:
// Here `IMap` is basically a locked Map, with `==` and `hashCode` definedclassTempNotifier<T> extendsStateNotifier<IMap<String, T>> {
finalTempConfig<T> config;
// few more members similarlyTempNotifier(this.config):super(_initialStateFromConfig(config)) {
_postConstructorCallback();
}
voidnotifierMethod(T value) {
// update `state` based on `this.config` and `value`.
}
// Rest of the implementations...
}
And I have created multiple providers for it as follows:
final tempIntProvider =StateNotifierProviderFamily<TempNotifier<int>, IMap<String, int>, TempProviderParams>((ref, params) {
// do some processingreturnTempNotifier<int>(config);
}
But unfortunately, I cannot use this provider with the other providers I created with the generator like this:
@Riverpod(keepAlive:true)
IMap<String, int> selectedTempIntValue(SelectedTempIntValueRef ref) {
// some processingreturn ref.watch(tempIntProvider(params)); // throws the error that ProviderListenable passed, when expected AlwaysAliveProviderListenable
}
So I have multiple questions based on this:
Can I create a generic notifier like TempNotifier with the Riverpod Generator?
If the above is not possible, how can I make my current tempIntProvider the "AlwaysAlive" type?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have created a generic StateNotifier with class members as well, something like this:
And I have created multiple providers for it as follows:
But unfortunately, I cannot use this provider with the other providers I created with the generator like this:
So I have multiple questions based on this:
Beta Was this translation helpful? Give feedback.
All reactions