-1

when using the provider package in flutter ,you can warp the scaffold with a consumer but then on every notifylisteners call the whole screen will rebuild so I used consumer only for the widgets that depend on the provider, but I was told that doing so will create multiple listeners which will affect performance, so my question is:

Does using multiple consumers on the same screen affect the performance? if yes then how can I avoid unnecessary rebuilds? if the answer is to use the child parameter in the consumer then how can I mark multiple widgets so that they won't rebuild? as the child parameter only offers one widget to be marked.

another question :

when using notifylisteners all the corresponding consumers are triggered to rebuild is there is a way to rebuild only specific consumers?.

1 Answers1

0

Most important thing is to wrap only the widgets that depends on a provider into a Consumer, so that only those are rebuild.

user18309290
  • 5,777
  • 2
  • 4
  • 22
  • will doing so affect the performance? as you are creating multiple consumers so there are multiple listeners actively listening for any value change. – youssif gamal Feb 25 '22 at 15:15
  • Rebuilding of course affects to the performance, but minimising involved widgets is important. It is ok to use multiple Consumers, if the design requires that. – user18309290 Feb 25 '22 at 15:28
  • 1
    sorry, but this doesn't answer my question, I am not asking whether I should use multiple consumers or not I am asking whether using multiple consumers affects the performance or not. – youssif gamal Feb 25 '22 at 17:02