globalContext top-level property

BuildContext? globalContext
final

This is global build context which can be used outside of an Sateless and Stateful Widget

Before using this you need to set globalKey

 MaterialApp(
   navigatorKey: globalKey, //put here
 )

Implementation

final globalContext = globalKey.currentContext;