Example Using Provider So, first to get the String value created in the main. dart , all we have to do is call Provider. of< String>(context) , the of() method here will obtain the nearest Provider up its widget tree and returns its value.
Read moreWhat does the provider do in Flutter?
One of the main reasons to prefer Provider over Statefulwidget s is that, using Provider , you will rebuild only the widgets that needs that value (the Consumers ) while the other will not be rebuilt . Instead when you call setState the whole build function of the widget will be called.19 May 2021
Read more