handleDrawFrame method

void handleDrawFrame()

Implementation

void handleDrawFrame() {
  List<FlutterPage> pageEventList = [];
  _flutterPageCache.removeWhere((route, page) {
    Widget? cacheWidget = page.widget;
    BuildContext? cacheContext = page.context;

    if (cacheWidget.runtimeType.toString() == '_DisposableWidget') {
      dynamic tmp = cacheWidget;
      cacheWidget = tmp.child(cacheContext, null);
    }

    var pageEvent = GrowingPageEvent();
    if (page.needFindChild) {
      cacheWidget = GrowingElementParserUtil.findRouteChild(
              cacheContext as Element?,
              routeType: page.routeType) ??
          cacheWidget;
    }
    if (cacheWidget != null &&
        CustomLocationHelper.isLocalWidget(cacheWidget)) {
      Map<String, String> locationMap =
          CustomLocationHelper.getLocationInfo(cacheWidget);
      if (locationMap["file"] != null) {
        pageEvent.fileName =
            locationMap["file"]!.replaceAll(locationMap["rootUrl"]!, "");
      }
      pageEvent.importUri = locationMap["importUri"];
    }

    pageEvent.title =
        GrowingElementParserUtil.findPageTitle(cacheContext as Element?);
    pageEvent.routeName = page.routeName;
    pageEvent.widgetName = cacheWidget?.runtimeType.toString();

    _checkWithGrowingPage(pageEvent, cacheWidget);
    page.pageEvent = pageEvent;
    page.widget = cacheWidget;
    page.needFindChild = false;
    pageEventList.add(page);
    GrowingAutotrackerManager.getInstance().updateWithPage(page);
    return true;
  });

  GrowingWebCircleManager.getInstance().updateNativeCircleData();
  if (pageEventList.isNotEmpty) {
    var priorityPage = _computePriorityFlutterPage(pageEventList);
    for (var element in priorityPage) {
      GrowingPluginDispatcher.getInstance()
          .trackFlutterPage(element.pageEvent!.toNativeMap());
    }
  }
}