Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Flutter 3.13.1 - Custom RenderObjects are not visible anymore on golden images #97

Closed
1 task done
karvulf opened this issue Aug 30, 2023 · 5 comments · Fixed by #98
Closed
1 task done
Labels
bug Something isn't working

Comments

@karvulf
Copy link

karvulf commented Aug 30, 2023

Is there an existing issue for this?

  • I have searched the existing issues.

Version

0.6.1

Description

When updating to the newest flutter version 3.13.1, the golden tests are failing when widgets with custom RenderObjects are tested.
Previously the text and icons were visible in the golden images. Now nothing is displayed (see the screenshots).

Steps to reproduce

import 'package:alchemist/alchemist.dart';
import 'package:flutter/material.dart';

void main() {
// ignore: discarded_futures,
  goldenTest(
    'golden test',
    fileName: 'h4u_adaptive_text',
    builder: () => const SizedBox(
      height: 800,
      width: 400,
      child: CustomExampleRenderObject(),
    ),
  );
}

class CustomExampleRenderObject extends LeafRenderObjectWidget {
  const CustomExampleRenderObject({super.key});

  @override
  CustomExampleRenderBox createRenderObject(BuildContext context) {
    return CustomExampleRenderBox();
  }
}

class CustomExampleRenderBox extends RenderBox {
  @override
  void paint(PaintingContext context, Offset offset) {
    final canvas = context.canvas;
    canvas.save();
    canvas.translate(offset.dx, offset.dy);

    final textPainter = TextPainter(
      text: const TextSpan(
        text: 'text',
        style: TextStyle(),
      ),
      textDirection: TextDirection.ltr,
    );
    textPainter.layout();
    textPainter.paint(canvas, Offset.zero);

    canvas.restore();
  }

  @override
  void performLayout() {
    this.size = this.computeDryLayout(this.constraints);
  }

  @override
  Size computeDryLayout(BoxConstraints constraints) {
    return constraints.constrain(Size(
      200.0,
      constraints.maxHeight,
    ));
  }
}

Expected behavior

In the example, I would expect that my text is still shown in the images and in general I would expect that it still works with Custom RenderObjects.

Screenshots

CI Image with Flutter Version 3.10.6:
Bildschirmfoto 2023-08-30 um 07 42 26

CI Image with Flutter Version 3.13.1:
Bildschirmfoto 2023-08-30 um 07 30 30

Additional context and comments

No response

@karvulf karvulf added the bug Something isn't working label Aug 30, 2023
@karvulf karvulf changed the title fix: Custom RenderObjects are not visible anymore on golden images fix: Flutter 3.13.1 - Custom RenderObjects are not visible anymore on golden images Aug 30, 2023
@timokz
Copy link

timokz commented Sep 3, 2023

Can reproduce with similar conditions.
Until #95 is merged, you will need to revert your projects sdk, as I have done

@karvulf
Copy link
Author

karvulf commented Sep 3, 2023

When I testet it with the pr the issue still remained @timokz

@timokz
Copy link

timokz commented Sep 3, 2023

When I testet it with the pr the issue still remained @timokz

Well that's really bad 😅

@timokz
Copy link

timokz commented Sep 4, 2023

Can you confirm encountering the same error? @karvulf

/Pub/Cache/hosted/pub.dev/alchemist-0.6.1/lib/src/golden_test_adapter.dart:53:38: Error: A value of type 'void Function(String, Future<void> Function(WidgetTester), {int? retry, bool semanticsEnabled, bool? skip, dynamic tags, Timeout? timeout, TestVariant<Object?> variant})' can't be assigned to a variable of type 'FutureOr<void> Function(String, Future<void> Function(WidgetTester), {Duration? initialTimeout, bool semanticsEnabled, bool? skip, dynamic tags, Timeout? timeout, TestVariant<Object?> variant})'.
 - 'Future' is from 'dart:async'.
 - 'WidgetTester' is from 'package:flutter_test/src/widget_tester.dart' ('/timok/fvm/versions/3.13.0/packages/flutter_test/lib/src/widget_tester.dart').
 - 'Timeout' is from 'package:test_api/src/backend/configuration/timeout.dart' ('/timok/AppData/Local/Pub/Cache/hosted/pub.dev/test_api-0.6.0/lib/src/backend/configuration/timeout.dart').
 - 'TestVariant' is from 'package:flutter_test/src/widget_tester.dart' ('/timok/fvm/versions/3.13.0/packages/flutter_test/lib/src/widget_tester.dart').
 - 'Object' is from 'dart:core'.
 - 'Duration' is from 'dart:core'.
TestWidgetsFn defaultTestWidgetsFn = testWidgets;

@karvulf
Copy link
Author

karvulf commented Sep 4, 2023

I get no warnings or errors because of the version.
It's just the output of images from the golden test that are inconsistent to the flutter version3.10.6. Widgets that are CustomRenderBoxes are not rendered or showed in the output image (like above shown). @timokz
Or do you see the widget on the image when trying to run the golden test with it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants