Sharing dependencies in a Flutter application
As mentioned previously, one common pattern for sharing information in a Flutter application is to pass information down as a property from the top down from parent to child, and through each nested child until you reach the widget that depends on that information. We will refer to this process as property forwarding.
While this strategy is certainly fine in limited instances, it is not ideal when sharing information in several components or several nested tree layers. It is also not efficient because if it’s not handled properly, a state change in one of the properties can potentially trigger a rebuild of large portions of the widget tree.
Let’s look at the following diagram to get a better understanding of this problem:
Figure 3.1 – A Flutter application widget tree
Here, we have several nested layers of widgets. At the top level, our App widget contains some business data that a descendant...