-
Notifications
You must be signed in to change notification settings - Fork 215
ScrollController is not working with Redux #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Found out why. The controller should be working with StatefulWidget only like animations. class HomePage extends StatelessWidget {
HomePage({
Key key,
this.category
})
: super(key: key);
final GankCategory category;
@override
Widget build(BuildContext context) {
return Scaffold(
body: StoreBuilder<AppState>(
builder: (context, store) {
return _HomeGridViewWidget(
ganks: ganksSelector(store.state),
currentPage: currentPageSelector(store.state),
);
},
),
);
}
}
class _HomeGridViewWidget extends StatefulWidget {
final List<Gank> ganks;
final int currentPage;
const _HomeGridViewWidget({Key key, this.ganks, this.currentPage}) : super(key: key);
@override
State<StatefulWidget> createState() => _HomeGridViewState();
}
class _HomeGridViewState extends State<_HomeGridViewWidget> {
ScrollController _scrollController = ScrollController();
...
} |
@brianegan One more question, like the code snippet above, I just use the StoreBuilder and subselect the needed sub app state down to the stateful _HomeGridViewWidget. Should I use a converter here like StoreConnector? If not, are there any difference with StoreBuilder and StoreConnector? I guess StoreBuilder will rebuild itself when any sub app states change and StoreConnector will rebuild itself only when the converted sub app states change? |
Yep! In the first example, you'll be creating the controller over and over, which might cause some problems. I tend to like StoreConnector's because it allows you to separate "Smart Widgets" from "Dumb Widgets." The Smart Widgets connect to the Store and prepare the data for the "Dumb Widgets." You can then re-use the Dumb widgets in more places without them needing to know anything about the Store / data source. In addition, you can use the StoreConnector to optimize rendering as you suggest. If you use a StoreConverter, set |
@brianegan Thanks you for your reply. |
Yep! StoreBuilder will always pass the same object to the I'll go ahead and close this out for now, but please feel free to file another issue if ya need more help :) |
@brianegan I've got it. Thank you for your help. I think I need to make a live template of Android Studio for the _ViewModel, or it will be tedious to write the _ViewModel class by hand every time. |
Hi, I'm new to flutter and I'm building a learning app which needs to listen to scroll view and do loading more function. And also, flutter_redux is included in my project cause it's awesome for decoupling data and view. But now I come across the problem that the listener added to ScrollController used by GridView is not working. Following is the code, pls help me out if I'm using it wrong. Hope someone could help me, thanks.
The text was updated successfully, but these errors were encountered: