Skip to content

Should selector add a method shouldUpdate that we can control ourselves, and if we don't implement it we'll still implement selected! = value, so we can control the List refresh, #221

Description

@2534290808

Should selector add a method shouldUpdate that we can control ourselves, and if we don't implement it we'll still implement selected! = value, so we can control the List refresh, as follows:

@override
  Widget build(BuildContext context) {
    final selected = widget.selector(context);

    if (oldWidget != widget || shouldUpdate!=null ? shouldUpdate(selected,value) : selected != value ) {
      value = selected;
      oldWidget = widget;
      cache = widget.builder(
        context,
        selected,
        widget.child,
      );
    }
    return cache;
  }
Selector < A, List<B> > (
     selector (_, A) = > a. list,
     builder: (_) = > SizedBox (),
     shouldUpdate: (newList, oldList) = > newList! = oldList || newList. length! = oldList. Length
)

Originally posted by @2534290808 in #205 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions