which is more expensive Provider vs setstate?

Issue

Is it a good practice to use provider in place of setstate talking for MVVM architecture and in general also? Does provider rebuilds the whole app widget tree like if i trigger it in second page than will 1st page also be rebuilt, if so then how can we use it more effectevly?

Solution

Provider state management offer Consumer. That Consumer has a build function itself. So you can use consumer in which widget you want to rebuild. You don’t need to rebuild the whole widget tree. Consumer will listen your provider method and it will rebuild a specific widget where you want to change. Thanks

Answered By – Mir Fahim Rahman

Answer Checked By – Candace Johnson (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *