我看到我可以在build()方法中访问InheritedWidgets,如下所示:final inheritedWidget = ChronoApp.of(context);但是如果我想在其他地方访问它,比如在initState()中没有上下文.我该怎么做?
解决方法
根据此文档,上下文应该在initState中使用上下文getter.
https://docs.flutter.io/flutter/widgets/State/context.html
The framework associates State objects with a BuildContext after creating them with StatefulWidget.createState and before calling initState.