I have an InheritedWidget
at the root of my application, basically at the top of the first build function of my first Scaffold
. I can reference the widget using the .of(context)
function just fine from all sub-widgets of the first page. if I push another page on the Navigator
stack, the InheritedWidget.of()
call fails, as I assume it should. Is there a way to share access to this widget? I'm trying to avoid passing widgets down the tree unnecessarily. ScopedModel has the same limitation. I was thinking about passing the context variable down the tree, but that doesn't sound right and it doesn't solve the issue either.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You should wrap your root widget with it, for example your MaterialApp
MyInheritedWidget(
child: MaterialApp(
home: home))