Skip to content

Commit

Permalink
withBuiltChild
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Molchanovsky committed Nov 23, 2023
1 parent 2fdcbcf commit 4e67b13
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions flutter_mobx/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
## 2.2.0+1
- renamed `Observer.withChild` to `Observer.excludedChild`
- renamed `Observer.withChild` to `Observer.withBuiltChild`
`
## 2.2.0
- `Observer` is updated with the new `Observer.excludedChild` constructor, so you can exclude child branch from the re-rendering. - [@subzero911](https://github.com/subzero911) \
In case if you use `Observer.excludedChild`, you should provide two parameters: `builderWithChild` and `child`:
- `Observer` is updated with the new `Observer.withBuiltChild` constructor, so you can exclude child branch from the re-rendering. - [@subzero911](https://github.com/subzero911) \
In case if you use `Observer.withBuiltChild`, you should provide two parameters: `builderWithChild` and `child`:
```dart
Observer.excludedChild(
builderWithChild: (context, child) => FooWidget(foo: foo, child: child),
child: BarWidget(), // is not rebuilt
Observer.withBuiltChild(
builderWithChild: (context, child) => FooWidget(foo: foo, bar: child),
child: BarWidget(), // won't rebuild
),
```

Expand Down
4 changes: 2 additions & 2 deletions flutter_mobx/lib/src/observer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ class Observer extends StatelessObserverWidget {
warnWhenNoObservables: warnWhenNoObservables,
);

/// Observer which excludes the child branch
/// Observer which excludes the child branch from being rebuilt
// ignore: prefer_const_constructors_in_immutables
Observer.excludedChild({
Observer.withBuiltChild({
Key? key,
required this.builderWithChild,
required this.child,
Expand Down
4 changes: 2 additions & 2 deletions flutter_mobx/test/flutter_mobx_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ void main() {
expect(renderCount, equals(1));
});

testWidgets("Observer.excludedChild's child doesn't re-render", (tester) async {
testWidgets("Observer.withBuiltChild's child doesn't re-render", (tester) async {
final message = Observable('Click');
final key1 = UniqueKey();
final key2 = UniqueKey();
final key3 = UniqueKey();

await tester.pumpWidget(
MaterialApp(
home: Observer.excludedChild(
home: Observer.withBuiltChild(
builderWithChild: (context, child) {
return Column(
children: [
Expand Down

0 comments on commit 4e67b13

Please sign in to comment.