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
Copy file name to clipboardExpand all lines: CHANGELOG.md
+6-2Lines changed: 6 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -5,8 +5,12 @@
5
5
* Works with Dart 2 (no longer supports Dart 1)
6
6
* Stronger Type info Required
7
7
* Breaking Changes:
8
-
*`StoreProvider` now requires generic type info: `StoreProvider<AppState>`
9
-
*`new StoreProvider.of(context).store` is now `StoreProvider.of<AppState>(context)`
8
+
*`StoreProvider` now requires generic type info: `new StoreProvider<AppState>`
9
+
*`new StoreProvider.of(context).store` is now `StoreProvider.of<AppState>(context)`
10
+
11
+
## 0.3.6
12
+
13
+
* Add `onWillChange`. This function will be called before the builder and can be used for working with Imperative APIs, such as Navigator, TextEditingController, or TabController.
Copy file name to clipboardExpand all lines: README.md
+30-26Lines changed: 30 additions & 26 deletions
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,13 @@ This package is built to work with [Redux.dart](https://pub.dartlang.org/package
16
16
17
17
* Dart 1: 0.3.x
18
18
* Dart 2: 0.4.0+. See the migration guide below!
19
+
20
+
## Dart 2 Migration Guide
21
+
22
+
Dart 2 requires more strict typing (yay!), and gives us the option to make getting the Store from the StoreProvider more convenient!
23
+
24
+
1. Change `new StoreProvider(...)` to `new StoreProvider<StateClass>(...)` in your Widget tree.
25
+
2. Change `new StoreProvider.of(context).store` to `StoreProvider.of<StateClass>(context)` if you're directly fetching the `Store<AppState>` yourself from the `StoreProvider<AppState>`. No need to access the `store` field directly any more since Dart 2 can now infer the proper type with a static function :)
19
26
20
27
## Examples
21
28
@@ -71,21 +78,21 @@ class FlutterReduxApp extends StatelessWidget {
71
78
@override
72
79
Widget build(BuildContext context) {
73
80
return MaterialApp(
74
-
theme: ThemeData.dark(),
81
+
theme: new ThemeData.dark(),
75
82
title: title,
76
-
home: StoreProvider<int>(
83
+
home: new StoreProvider<int>(
77
84
// Pass the store to the StoreProvider. Any ancestor `StoreConnector`
78
85
// Widgets will find and use this value as the `Store`.
79
86
store: store,
80
-
child: Scaffold(
81
-
appBar: AppBar(
82
-
title: Text(title),
87
+
child: new Scaffold(
88
+
appBar: new AppBar(
89
+
title: new Text(title),
83
90
),
84
-
body: Center(
85
-
child: Column(
91
+
body: new Center(
92
+
child: new Column(
86
93
mainAxisAlignment: MainAxisAlignment.center,
87
94
children: [
88
-
Text(
95
+
new Text(
89
96
'You have pushed the button this many times:',
90
97
),
91
98
// Connect the Store to a Text Widget that renders the current
@@ -103,10 +110,12 @@ class FlutterReduxApp extends StatelessWidget {
103
110
// count. No need to manually manage subscriptions or Streams!
104
111
new StoreConnector<int, String>(
105
112
converter: (store) => store.state.toString(),
106
-
builder: (context, count) => Text(
107
-
count,
108
-
style: Theme.of(context).textTheme.display1,
109
-
),
113
+
builder: (context, count) {
114
+
return new Text(
115
+
count,
116
+
style: Theme.of(context).textTheme.display1,
117
+
);
118
+
},
110
119
)
111
120
],
112
121
),
@@ -122,26 +131,21 @@ class FlutterReduxApp extends StatelessWidget {
122
131
// with no parameters. It only dispatches an Increment action.
// Attach the `callback` to the `onPressed` attribute
127
-
onPressed: callback,
128
-
tooltip: 'Increment',
129
-
child: Icon(Icons.add),
130
-
),
134
+
builder: (context, callback) {
135
+
return new FloatingActionButton(
136
+
// Attach the `callback` to the `onPressed` attribute
137
+
onPressed: callback,
138
+
tooltip: 'Increment',
139
+
child: new Icon(Icons.add),
140
+
);
141
+
},
131
142
),
132
143
),
133
144
),
134
145
);
135
146
}
136
147
}
137
-
```
138
-
139
-
## Dart 2 Migration
140
-
141
-
Dart 2 requires more strict typing (yay!), and gives us the option to make getting the Store from the StoreProvider more convenient!
142
-
143
-
1. Change `new StoreProvider(...)` to `StoreProvider<StateClass>(...)` in your Widget tree.
144
-
2. Change `new StoreProvider.of(context).store` to `StoreProvider.of<StateClass>(context)` if you're directly fetching the `Store<AppState>` yourself from the `StoreProvider<AppState>`. No need to access the `store` field directly any more since Dart 2 can now infer the proper type with a static function :)
0 commit comments