The popular use_build_context_synchronously lint suggests to check for mounted before using the context after an asynchronous gap. However, mounted only exists on StatefullWidgets. At the same time, StatelessWidgets suffer under the same problem: The context can become invalid after an asynchronous gap and there is currently no way to check whether it is still valid since there is no mounted property. A work-around is to turn the StatelessWidget into a StatefulWidget.
We should expose some kind of a property on BuildContext directly to check whether the context is still valid to simplify usage of context after an asynchronous gaps in these use cases.
The popular
use_build_context_synchronouslylint suggests to check formountedbefore using thecontextafter an asynchronous gap. However,mountedonly exists onStatefullWidgets. At the same time,StatelessWidgets suffer under the same problem: Thecontextcan become invalid after an asynchronous gap and there is currently no way to check whether it is still valid since there is nomountedproperty. A work-around is to turn theStatelessWidgetinto aStatefulWidget.We should expose some kind of a property on
BuildContextdirectly to check whether the context is still valid to simplify usage ofcontextafter an asynchronous gaps in these use cases.