currentContext property
BuildContext
get
currentContext
Gets the current BuildContext from the navigator key.
This should only be called after the MaterialApp or CupertinoApp
with the navigatorKey has been built.
Implementation
static BuildContext get currentContext {
final context = navigatorKey.currentContext;
if (context == null) {
throw StateError(
'Navigator context is not available. Ensure navigatorKey is assigned to MaterialApp/CupertinoApp.');
}
return context;
}