Closed subzero911 closed 10 months ago
Merging #952 (bf2623f) into master (7510ee4) will increase coverage by
0.00%
. The diff coverage is100.00%
.
@pavanpodila done. I renamed .optimized
to .withChild
and builderOptimized
to builderWithChild
I have no idea how to implement "withChildren" constructor to "exclude subtrees by map keys", and I don't think we actually need it. You can use a Column(children: [...])
as a child
, or you can use a composition of Observers.
I applied the same technique which was used in AnimatedBuilder, and provider
's Consumer
and Selector
- they all have the child
parameter only. Refer to https://api.flutter.dev/flutter/widgets/AnimatedBuilder-class.html , "Performance optimizations" for details. They don't have any multiple children version.
@all-contributors add @subzero911 for code
@pavanpodila
@subzero911 already contributed before to code
I already did a PR https://github.com/mobxjs/mobx.dart/pull/909 but I accidentally deleted the forked repo. So I made it again and a little bit better.
Mostly you try to make Observer as small as possible. But sometimes you'll want to exclude the widget subtree from re-render and improve the performance.
Real world examples: 1) You have a colored Container with some heavy widgets inside (like
ListView
withshrinkWrap: true
). You want to change the color by Observable, but don't want to rebuild the whole ListView. 2) You have some fancy animation driven by Observable. You want to animate the widget and want to preserve its children from being rebuilt.I introduce the new
Observer.optimized
which allows you to exclude thechild
branch. Usage:Solves https://github.com/mobxjs/mobx.dart/issues/551
@amondnet @fzyzcjy
Pull Request Checklist
pubspec.yaml
is updated.major
/minor
/patch
/patch-count
, depending on the complexity of changemelos run set_version
command from the root directory