Skip to content

context.select in ProxyProvider0.update not allowed? #875

@taosimple

Description

@taosimple

Discussed in #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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions