checkElement method

  1. @override
void checkElement(
  1. Element element
)
override

Check a single element during the unified tree walk.

Called once per element in depth-first order. Detectors inspect the element's widget/render object and accumulate findings. Local nested walks (e.g. counting children) are permitted within this method.

Implementation

@override
void checkElement(Element element) {
  final widget = element.widget;
  if (widget is Image) {
    _imageFrames.add((image: element, paired: false));
    return;
  }
  if (widget is RawImage && _imageFrames.isNotEmpty) {
    final frame = _imageFrames.last;
    if (frame.paired) return;
    // Paired once measured; a RawImage that cannot be measured yet (no
    // decode, no layout, no device pixel ratio) leaves the pair open.
    if (_measure(frame.image, element, widget)) {
      _imageFrames.last = (image: frame.image, paired: true);
    }
  }
}