Skip to content

Commit 9e37b12

Browse files
authored
Merge branch 'main' into pr_fix_stacktrace
2 parents 0d2acde + fdfb466 commit 9e37b12

File tree

18 files changed

+205
-184
lines changed

18 files changed

+205
-184
lines changed

.all-contributorsrc

+9
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,15 @@
608608
"code",
609609
"bug"
610610
]
611+
},
612+
{
613+
"login": "altynbek132",
614+
"name": "Altynbek Aidarbekov",
615+
"avatar_url": "https://avatars.githubusercontent.com/u/48729942?v=4",
616+
"profile": "https://github.com/altynbek132",
617+
"contributions": [
618+
"code"
619+
]
611620
}
612621
],
613622
"contributorsPerLine": 7,

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,7 @@ the growing community of `MobX.dart`.
410410
## Contributors ✨
411411

412412
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
413-
414-
[![All Contributors](https://img.shields.io/badge/all_contributors-63-orange.svg?style=flat-square)](#contributors-)
415-
413+
[![All Contributors](https://img.shields.io/badge/all_contributors-64-orange.svg?style=flat-square)](#contributors-)
416414
<!-- ALL-CONTRIBUTORS-BADGE:END -->
417415

418416
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
@@ -503,6 +501,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
503501
<td align="center" valign="top" width="14.28%"><a href="https://github.com/yatharth25"><img src="https://avatars.githubusercontent.com/u/54071856?v=4?s=64" width="64px;" alt="Yatharth Chauhan"/><br /><sub><b>Yatharth Chauhan</b></sub></a><br /><a href="https://github.com/mobxjs/mobx.dart/commits?author=yatharth25" title="Documentation">📖</a></td>
504502
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ParthBaraiya"><img src="https://avatars.githubusercontent.com/u/36261739?v=4?s=64" width="64px;" alt="Parth Baraiya"/><br /><sub><b>Parth Baraiya</b></sub></a><br /><a href="https://github.com/mobxjs/mobx.dart/commits?author=ParthBaraiya" title="Code">💻</a> <a href="https://github.com/mobxjs/mobx.dart/issues?q=author%3AParthBaraiya" title="Bug reports">🐛</a></td>
505503
</tr>
504+
<tr>
505+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/altynbek132"><img src="https://avatars.githubusercontent.com/u/48729942?v=4?s=64" width="64px;" alt="Altynbek Aidarbekov"/><br /><sub><b>Altynbek Aidarbekov</b></sub></a><br /><a href="https://github.com/mobxjs/mobx.dart/commits?author=altynbek132" title="Code">💻</a></td>
506+
</tr>
506507
</tbody>
507508
</table>
508509

docs/docs/development/release.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ To format your files following
1313
This will format your code accordingly regardless of your IDE settings.
1414

1515
```
16-
dartfmt -w .
16+
dart format .
1717
```
1818

1919
### 2. pubspec.yaml

docs/docs/guides/mobx-utils.mdx

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: MobX-utils
3+
sidebar_label: MobX-utils {🚀}
4+
hide_title: true
5+
---
6+
7+
<script async type="text/javascript" src="//cdn.carbonads.com/carbon.js?serve=CEBD4KQ7&placement=mobxjsorg" id="_carbonads_js"></script>
8+
9+
# MobX-utils {🚀}
10+
11+
[mobx_utils](https://pub.dev/packages/mobx_utils) provides an extensive series of additional utility functions, observables and common patterns for MobX.

docs/pnpm-lock.yaml

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/sidebars.js

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ module.exports = {
2828
'guides/organizing-stores',
2929
'guides/when-does-mobx-react',
3030
'guides/mobx-vs-inherited-model',
31+
'guides/mobx-utils',
3132
],
3233
},
3334
'community',

flutter_mobx/lib/src/observer.dart

+10-10
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,14 @@ class Observer extends StatelessObserverWidget {
6464

6565
@override
6666
String getName() =>
67-
super.getName() +
68-
(debugConstructingStackFrame != null
69-
? '\n$debugConstructingStackFrame'
70-
: '');
67+
super.getName() +
68+
(debugConstructingStackFrame != null
69+
? '\n$debugConstructingStackFrame'
70+
: '');
7171

7272
@override
73-
Widget build(BuildContext context) => builderWithChild?.call(context, child) ?? builder!.call(context);
73+
Widget build(BuildContext context) =>
74+
builderWithChild?.call(context, child) ?? builder!.call(context);
7475

7576
/// Matches constructor stack frames, in both VM and web environments.
7677
static final _constructorStackFramePattern = RegExp(r'\bnew\b');
@@ -99,15 +100,14 @@ class Observer extends StatelessObserverWidget {
99100
.skip(3)
100101
// Search for the first non-constructor frame
101102
.firstWhere(
102-
(frame) =>
103-
!_constructorStackFramePattern.hasMatch(frame),
103+
(frame) => !_constructorStackFramePattern.hasMatch(frame),
104104
orElse: () => '');
105105

106106
final stackFrameCore =
107-
_stackFrameCleanUpPattern.firstMatch(rawStackFrame)?.group(1);
107+
_stackFrameCleanUpPattern.firstMatch(rawStackFrame)?.group(1);
108108
final cleanedStackFrame = stackFrameCore == null
109-
? null
110-
: 'Observer constructed from: $stackFrameCore';
109+
? null
110+
: 'Observer constructed from: $stackFrameCore';
111111

112112
stackFrame = cleanedStackFrame;
113113
}

flutter_mobx/test/flutter_mobx_test.dart

+42-38
Original file line numberDiff line numberDiff line change
@@ -59,45 +59,49 @@ void main() {
5959
expect(renderCount, equals(1));
6060
});
6161

62-
testWidgets("Observer.withBuiltChild's child doesn't re-render", (tester) async {
62+
testWidgets("Observer.withBuiltChild's child doesn't re-render",
63+
(tester) async {
6364
final message = Observable('Click');
64-
final key1 = UniqueKey();
65-
final key2 = UniqueKey();
66-
final key3 = UniqueKey();
67-
68-
await tester.pumpWidget(
69-
MaterialApp(
70-
home: Observer.withBuiltChild(
71-
builderWithChild: (context, child) {
72-
return Column(
73-
children: [
74-
ElevatedButton(onPressed: () => message.value = 'Clicked', child: Container()),
75-
Text(message.value, key: key1),
76-
child!,
77-
Builder(
78-
builder: (context) {
79-
return Text(message.value, key: key3);
80-
}
81-
),
82-
],
83-
);
84-
},
85-
child: Text(message.value, key: key2),
86-
),
87-
),
88-
);
89-
90-
expect(tester.widget<Text>(find.byKey(key1)).data, equals('Click'));
91-
expect(tester.widget<Text>(find.byKey(key2)).data, equals('Click'));
92-
expect(tester.widget<Text>(find.byKey(key3)).data, equals('Click'));
93-
94-
await tester.tap(find.byType(ElevatedButton));
95-
expect(message.value, equals('Clicked'));
96-
97-
await tester.pump();
98-
expect(tester.widget<Text>(find.byKey(key1)).data, equals('Clicked')); // Observer rebuilt the Text1
99-
expect(tester.widget<Text>(find.byKey(key2)).data, equals('Click')); // child Text2 did not change
100-
expect(tester.widget<Text>(find.byKey(key3)).data, equals('Clicked')); // Builder does not preserve from rebuild
65+
final key1 = UniqueKey();
66+
final key2 = UniqueKey();
67+
final key3 = UniqueKey();
68+
69+
await tester.pumpWidget(
70+
MaterialApp(
71+
home: Observer.withBuiltChild(
72+
builderWithChild: (context, child) {
73+
return Column(
74+
children: [
75+
ElevatedButton(
76+
onPressed: () => message.value = 'Clicked',
77+
child: Container()),
78+
Text(message.value, key: key1),
79+
child!,
80+
Builder(builder: (context) {
81+
return Text(message.value, key: key3);
82+
}),
83+
],
84+
);
85+
},
86+
child: Text(message.value, key: key2),
87+
),
88+
),
89+
);
90+
91+
expect(tester.widget<Text>(find.byKey(key1)).data, equals('Click'));
92+
expect(tester.widget<Text>(find.byKey(key2)).data, equals('Click'));
93+
expect(tester.widget<Text>(find.byKey(key3)).data, equals('Click'));
94+
95+
await tester.tap(find.byType(ElevatedButton));
96+
expect(message.value, equals('Clicked'));
97+
98+
await tester.pump();
99+
expect(tester.widget<Text>(find.byKey(key1)).data,
100+
equals('Clicked')); // Observer rebuilt the Text1
101+
expect(tester.widget<Text>(find.byKey(key2)).data,
102+
equals('Click')); // child Text2 did not change
103+
expect(tester.widget<Text>(find.byKey(key3)).data,
104+
equals('Clicked')); // Builder does not preserve from rebuild
101105
});
102106

103107
testWidgets('Observer build should call reaction.track', (tester) async {

melos.yaml

+1-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ packages:
66
- mobx_codegen
77
- mobx_examples
88
- mobx_lint
9+
- mobx_lint_flutter_test
910

1011
scripts:
1112
analyze:
@@ -16,7 +17,3 @@ scripts:
1617
exec: dart run $MELOS_ROOT_PATH/tool/expose_version.dart
1718
generate:
1819
run: cd mobx_examples && dart run build_runner watch --delete-conflicting-outputs
19-
20-
command:
21-
bootstrap:
22-
usePubspecOverrides: true

mobx/lib/src/api/annotations.dart

+5-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ class StoreConfig {
2525
/// String withEquals = 'world';
2626
/// ```
2727
class MakeObservable {
28-
const MakeObservable({this.readOnly = false, this.equals, this.useDeepEquality = true});
28+
const MakeObservable(
29+
{this.readOnly = false, this.equals, this.useDeepEquality = true});
2930

3031
final bool readOnly;
32+
3133
/// A [Function] to use check whether the value of an observable has changed.
3234
///
3335
/// Must be a top-level or static [Function] that takes two arguments and
@@ -58,7 +60,8 @@ const MakeObservable observable = MakeObservable();
5860
const MakeObservable readonly = MakeObservable(readOnly: true);
5961

6062
/// Allows a reaction to be fired even if the value hasn't changed.
61-
const MakeObservable alwaysNotify = MakeObservable(equals: observableAlwaysNotEqual);
63+
const MakeObservable alwaysNotify =
64+
MakeObservable(equals: observableAlwaysNotEqual);
6265

6366
/// Internal class only used for code-generation with `mobx_codegen`.
6467
///

0 commit comments

Comments
 (0)