currentPage method

FlutterPage? currentPage({
  1. Element? element,
})

Implementation

FlutterPage? currentPage({Element? element}) {
  var currentPages = <FlutterPage>[];
  _flutterPageMap.forEach((key, value) {
    if (element != null) {
      if (value.widget != null &&
          GrowingElementParserUtil.isWidgetEqual(
              element.widget, value.widget!)) {
        currentPages.add(value);
        return;
      }
    } else if (key.isCurrent) {
      currentPages.add(value);
    }
  });

  FlutterPage? tempPage;

  /// find the deepest page
  for (var page in currentPages) {
    var hasNaviChilds = page.containsNaviNodes.isNotEmpty;
    if (tempPage == null) {
      tempPage = page;
    } else if (!hasNaviChilds) {
      tempPage = page;
    }
  }

  if (tempPage == null && element == null) {
    return _flutterPageMap.values.last;
  }
  return tempPage;
}