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
How to prevent unnecessary re-rendering while using provider? #115
Comments
@muhammadwfa I agree with you.and You can look at flutter_redux.dart,It maps a new stream,It generated new data types from a bloc instance ,like this:
but,Come back here. |
related issues: |
Hi,I get it.I found a solution, @muhammadwfa
now, only ValueListenableBuilder and Text rebuild . |
The typical solution is that, instead of: ListView.builder(
itemBuilder: (context, index) {
final models = Provider.of<List<Model>>(context);
return MyListItem(models[index]);
}
) We'd want to use something like that instead: ListView.builder(
itemBuilder: (context, index) {
return ProxyProvider<List<Model>, ModelItem>(
builder: (_, models, __) => model[index],
child: const MyListItem(),
);
}
) where This will automatically update only what's needed. |
I am using provider in my app, but I faced with unnecessary building.
Example
Now if I update only
widget2
thewidget1 & widget3
gets build too, which i dont want.Here I am wory about performance.
So my expectation is:
I am going to update(build) only the widget I want. because I think if I avoid unnecessary building this may boost the performance.
Now if there is a solution please share it with an example.
think like react-native, as it has
shouldComponentUpdate(nextProps, nextState)
function, which can be used to avoid unnecessary rendering and boost performance.The text was updated successfully, but these errors were encountered: