Consider the following case:
MyInheritedWidget(
identity: "a",
child: MyInheritedWidget(
identity: "b",
child: MyChildWidget(),
),
)
Inside MyChildWidget, I can use context.dependOnInheritedWidgetOfExactType<MyInheritedWiget>() to get the nearest instance of MyInheritedWiget in my ancestors. Namely, the b in this case. However, I hope there exist an approach such that I can depend on the non-nearest one, a in this case.
For example, hope such API exists:
context.dependOnInheritedWidgetOfExactType<MyInheritedWiget>((widget) => widget.identity == 'a')
Or such API may also be OK:
context.findAllInheritedWidgetsOfExactType<MyInheritedWiget>().where((widget) => widget.identity == 'a')
And so on. But I cannot find an appropriate API like this...
Thanks for any suggestions!