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);
},
),
Discussed in #873
Originally posted by taosimple April 19, 2024
Above codes use
context.selectwill throw a exception: Tried to usecontext.selectoutside of thebuildmethod of a widget., but usecontext.watchis fine, whycontext.selectis not allowed, it more efficient thancontext.watch.