areViewsPresent static method
void
areViewsPresent()
Implementation
static void areViewsPresent(String listenerId, searchElements,
double pixRatio, int screenWidth, int screenHeight) {
try {
plotlineDebugLog("PlotlineDebug: areViewsPresent: $listenerId, $searchElements, $pixRatio, $screenWidth, $screenHeight");
screenHeight = (MediaQuery.of(_ctx).size.height * pixRatio).round();
screenWidth = (MediaQuery.of(_ctx).size.width * pixRatio).round();
List<Map<String, dynamic>> presentElements = [];
for (int i = 0; i < searchElements.length; i++) {
var key = searchElements[i]["clientElementId"];
if (!key.contains("<'") && !key.contains("'>")) {
key = "[<'$key'>]";
}
if(visibilityMap[key] == 100.0) {
plotlineDebugLog("PlotlineDebug: areViewsPresent: visibility=100: $listenerId, $searchElements, $pixRatio, $screenWidth, $screenHeight");
BuildContext? element = findViewByKey(key, _ctx);
if (element != null) {
plotlineDebugLog("PlotlineDebug: areViewsPresent: element != null: $listenerId, $searchElements, $pixRatio, $screenWidth, $screenHeight");
RenderBox box = element.findRenderObject() as RenderBox;
Offset position = box.localToGlobal(Offset.zero);
if (isWithinBounds(
element, position, pixRatio, screenWidth, screenHeight)) {
plotlineDebugLog("PlotlineDebug: areViewsPresent: isWithinBounds: $listenerId, $searchElements, $pixRatio, $screenWidth, $screenHeight");
presentElements.add(searchElements[i]);
}
}
} else {
plotlineDebugLog("PlotlineDebug: areViewsPresent: visibility of element with key $key = ${visibilityMap[key]} END: $listenerId, $searchElements, $pixRatio, $screenWidth, $screenHeight}");
plotlineDebugLog("PlotlineDebug: areViewsPresent: visibilityMap is $visibilityMap END: $listenerId, $searchElements, $pixRatio, $screenWidth, $screenHeight");
}
}
plotlineChannel.invokeMethod('areViewsPresent', <String, dynamic>{
"listenerId": listenerId,
"presentElements": presentElements
});
} catch (e) {
debugPrint("Error in areViewsPresent: $e");
}
}