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
+12Lines changed: 12 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,17 @@
1
1
# Changelog
2
2
3
+
## 0.4.0
4
+
5
+
* Works with Dart 2 (no longer supports Dart 1)
6
+
* Stronger Type info Required
7
+
* Breaking Changes:
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.
14
+
3
15
## 0.3.6
4
16
5
17
* 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
+47-23Lines changed: 47 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -5,13 +5,25 @@
5
5
A set of utilities that allow you to easily consume a [Redux](https://pub.dartlang.org/packages/redux) Store to build Flutter Widgets.
6
6
7
7
This package is built to work with [Redux.dart](https://pub.dartlang.org/packages/redux).
8
-
8
+
9
9
## Redux Widgets
10
10
11
11
*`StoreProvider` - The base Widget. It will pass the given Redux Store to all descendants that request it.
12
12
*`StoreBuilder` - A descendant Widget that gets the Store from a `StoreProvider` and passes it to a Widget `builder` function.
13
13
*`StoreConnector` - A descendant Widget that gets the Store from the nearest `StoreProvider` ancestor, converts the `Store` into a `ViewModel` with the given `converter` function, and passes the `ViewModel` to a `builder` function. Any time the Store emits a change event, the Widget will automatically be rebuilt. No need to manage subscriptions!
14
14
15
+
## Dart Support
16
+
17
+
* Dart 1: 0.3.x
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 :)
26
+
15
27
## Examples
16
28
17
29
*[Simple example](https://gitlab.com/brianegan/flutter_redux/tree/master/example) - a port of the standard "Counter Button" example from Flutter
@@ -26,17 +38,19 @@ This package is built to work with [Redux.dart](https://pub.dartlang.org/package
26
38
27
39
Let's demo the basic usage with the all-time favorite: A counter example!
28
40
41
+
Note: This example requires flutter_redux 0.4.0+ and Dart 2! If you're using Dart 1, [see the old example](https://github.com/brianegan/flutter_redux/blob/eb4289795a5a70517686ccd1d161abdb8cc08af5/example/lib/main.dart).
// Pass the store to the StoreProvider. Any descendant `StoreConnector`
83
+
home: new StoreProvider<int>(
84
+
// Pass the store to the StoreProvider. Any ancestor `StoreConnector`
65
85
// Widgets will find and use this value as the `Store`.
66
86
store: store,
67
87
child: new Scaffold(
@@ -90,10 +110,12 @@ class FlutterReduxApp extends StatelessWidget {
90
110
// count. No need to manually manage subscriptions or Streams!
91
111
new StoreConnector<int, String>(
92
112
converter: (store) => store.state.toString(),
93
-
builder: (context, count) => new Text(
94
-
count,
95
-
style: Theme.of(context).textTheme.display1,
96
-
),
113
+
builder: (context, count) {
114
+
return new Text(
115
+
count,
116
+
style: Theme.of(context).textTheme.display1,
117
+
);
118
+
},
97
119
)
98
120
],
99
121
),
@@ -109,21 +131,23 @@ class FlutterReduxApp extends StatelessWidget {
109
131
// with no parameters. It only dispatches an Increment action.
110
132
return () => store.dispatch(Actions.Increment);
111
133
},
112
-
builder: (context, callback) => new FloatingActionButton(
113
-
// Attach the `callback` to the `onPressed` attribute
114
-
onPressed: callback,
115
-
tooltip: 'Increment',
116
-
child: new Icon(Icons.add),
117
-
),
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
+
},
118
142
),
119
143
),
120
144
),
121
145
);
122
146
}
123
147
}
124
-
```
148
+
```
125
149
126
-
###Purpose
150
+
## Purpose
127
151
128
152
One question that [reasonable people might ask](https://www.reddit.com/r/FlutterDev/comments/6vscdy/a_set_of_utilities_that_allow_you_to_easily/dm3ll7d/): Why do you need all of this if `StatefulWidget` exists?
0 commit comments