provider
provider copied to clipboard
`context.select` in `ProxyProvider0.update` not allowed?
Discussed in https://github.com/rrousselGit/provider/discussions/873
Originally posted by taosimple April 19, 2024
ProxyProvider0<TransformedCounter>(
update: (context, value) {
final value = context.select<Counter, int>((counter) => counter.value);
return TransformedCounter(value * 2);
},
),
ProxyProvider0<TransformedCounter>(
update: (context, value) {
final counter = context.watch<Counter>();
return TransformedCounter(counter.value * 2);
},
),
Above codes use context.select
will throw a exception: Tried to use context.select
outside of the build
method of a widget., but use context.watch
is fine, why context.select
is not allowed, it more efficient than context.watch
.
Technical limitation. We could possibly support it, but that's not a thing yet.