evaluate method

  1. @override
Future<Evaluation> evaluate(
  1. WidgetTester tester
)
override

Evaluate whether the current state of the tester conforms to the rule.

Implementation

@override
Future<Evaluation> evaluate(WidgetTester tester) async {
  Evaluation result = const Evaluation.pass();
  for (final RenderView renderView in tester.binding.renderViews) {
    final OffsetLayer layer = renderView.debugLayer! as OffsetLayer;
    final SemanticsNode root = renderView.owner!.semanticsOwner!.rootSemanticsNode!;

    late ui.Image image;
    final ByteData? byteData = await tester.binding.runAsync<ByteData?>(
      () async {
        // Needs to be the same pixel ratio otherwise our dimensions won't match
        // the last transform layer.
        final double ratio = 1 / renderView.flutterView.devicePixelRatio;
        image = await layer.toImage(renderView.paintBounds, pixelRatio: ratio);
        final ByteData? data = await image.toByteData();
        image.dispose();
        return data;
      },
    );

    result += await _evaluateNode(root, tester, image, byteData!, renderView);
  }

  return result;
}