'Any way to read a Provider from outside?
I have a List<Provider> providers and I would like to, at some point, do:
for(var p in providers){
if(p.value is Whatever) p.doWhatever();
}
But it seems this is not possible? I can not see any way to read the providers from the outside.
Solution 1:[1]
Looks like I can just do this:
class WhateverValueProvider<T extends Whatever> extends Provider {
WhateverValueProvider(this.value, {Key? key}) : super.value(key: key, value: value);
final T value;
}
Then use this in place of Provider, and access .value, knowing it is Whatever. Seems odd that provider doesn't just expose a .value getter.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | shawnblais |
