findRoute method
Implementation
RouteInfo? findRoute() {
Element? topElement;
var context = DoKitApp.appKey.currentContext;
if (context == null) return null;
final ModalRoute<dynamic>? rootRoute = ModalRoute.of(context);
void listTopView(Element element) {
if (element.widget is! PositionedDirectional) {
if (element is RenderObjectElement &&
element.renderObject is RenderBox) {
final ModalRoute<dynamic>? route = ModalRoute.of(element);
if (route != null && route != rootRoute) {
topElement = element;
}
}
element.visitChildren(listTopView);
}
}
context.visitChildElements(listTopView);
if (topElement != null) {
final RouteInfo routeInfo = RouteInfo();
routeInfo.current = ModalRoute.of(topElement!);
buildNavigatorTree(topElement!, routeInfo);
return routeInfo;
}
return null;
}