You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Used in Triple Pattern in StreamStore and NotifierStore classes.
33
+
34
+
:::tip TIP
35
+
36
+
In addition to the **context.watch()** method, the read-only **context.read()** method has been added.
37
+
It's the same as using **Modular.get()**, but this addition helps projects that are being migrated
38
+
**Provider**.
39
+
40
+
:::
41
+
42
+
## With selectors
43
+
44
+
Sometimes binds are not a supported reactivity, but one of their properties can be.
45
+
As in the case of BLoC, where the Stream is available through a `bloc.stream` property;
46
+
47
+
We can add a selection through an anonymous function indicating which property is a supported reactivity to be watched:
48
+
49
+
```dart
50
+
class Body extends StatelessWidget {
51
+
Widget build(BuildContext context){
52
+
final bloc = context.watch<CounterBloc>((bloc) => bloc.stream);
53
+
return Text('${bloc.state}')
54
+
}
55
+
}
56
+
```
57
+
58
+
Note that the use of the selector does not change on bind return.
59
+
60
+
We can also use selectors for Triple objects, which have their own selectors for each of their segments:
61
+
See the Triple documentation for more details [by clicking here](https://triple.flutterando.com.br/docs/getting-started/using-flutter-triple#selectors):
62
+
63
+
```dart
64
+
class OnlyErrorWidget extends StatelessWidget {
65
+
Widget build(BuildContext context){
66
+
// changes with store.setError();
67
+
final store = context.watch<MyTripleStore>((store) => store.selectError);
Copy file name to clipboardExpand all lines: flutter_modular/lib/src/presenter/widgets/modular_app.dart
+125-5Lines changed: 125 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -26,8 +26,7 @@ class ModularApp extends StatefulWidget {
26
26
/// Prohibits taking any bind of parent modules, forcing the imports of the same in the current module to be accessed. This is the same behavior as the system. Default is false;
0 commit comments