getTopmostContext static method
Implementation
static BuildContext getTopmostContext(BuildContext context) {
BuildContext currentContext = context;
while (true) {
final parentContext = currentContext.findAncestorStateOfType<NavigatorState>()?.context;
if (parentContext == null) {
// We've reached the topmost context
break;
}
currentContext = parentContext;
}
return currentContext;
}