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

GoldenBuilder with materialAppWrapper causes Flutter assertion #174

Open
mdazy opened this issue Jul 3, 2023 · 1 comment
Open

GoldenBuilder with materialAppWrapper causes Flutter assertion #174

mdazy opened this issue Jul 3, 2023 · 1 comment

Comments

@mdazy
Copy link

mdazy commented Jul 3, 2023

Actual results

A builder grid test with a simple widget triggers an assert in Flutter if a MaterialApp wrapper is used (e.g. materialAppWrapper):

// this works - although the last line of widgets gets cropped vertically
      final builder = GoldenBuilder.grid(
        columns: 2,
        widthToHeightRatio: 1,
      )..addScenario( /*...*/ );

// this crashes Flutter
    final builder = GoldenBuilder.grid(
      columns: 2,
      widthToHeightRatio: 1,
      wrap: materialAppWrapper(), // also fails with custom MaterialApp wrapping
    )..addScenario( /*...*/ );

The second case causes an assert with this log

══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
The following assertion was thrown during performLayout():
RenderBox was not laid out: RenderPadding#d67b0 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1966 pos 12: 'hasSize'

Either the assertion indicates an error in the framework itself, or we should provide substantially
more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.md

The relevant error-causing widget was:
  GridView
  GridView:file:///Users/mdazy/.pub-cache/hosted/pub.dev/golden_toolkit-0.15.0/lib/src/golden_builder.dart:132:21

When the exception was thrown, this was the stack:
#2      RenderBox.size (package:flutter/src/rendering/box.dart:1966:12)
#3      RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:123:21)
#4      RenderObject.layout (package:flutter/src/rendering/object.dart:2395:7)
#5      RenderBox.layout (package:flutter/src/rendering/box.dart:2386:11)
#6      RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:122:14)
#7      RenderObject.layout (package:flutter/src/rendering/object.dart:2395:7)
#8      RenderBox.layout (package:flutter/src/rendering/box.dart:2386:11)
#9      RenderSliverMultiBoxAdaptor.insertAndLayoutChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:491:13)
#10     RenderSliverGrid.performLayout (package:flutter/src/rendering/sliver_grid.dart:635:17)
#11     RenderObject.layout (package:flutter/src/rendering/object.dart:2395:7)
#12     RenderSliverEdgeInsetsPadding.performLayout (package:flutter/src/rendering/sliver_padding.dart:139:12)
#13     RenderSliverPadding.performLayout (package:flutter/src/rendering/sliver_padding.dart:361:11)
#14     RenderObject.layout (package:flutter/src/rendering/object.dart:2395:7)
#15     RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:534:13)
#16     RenderShrinkWrappingViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1882:12)
#17     RenderShrinkWrappingViewport.performLayout (package:flutter/src/rendering/viewport.dart:1833:20)
#18     RenderObject.layout (package:flutter/src/rendering/object.dart:2395:7)
#19     RenderBox.layout (package:flutter/src/rendering/box.dart:2386:11)
#20     RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:122:14)
#21     RenderObject.layout (package:flutter/src/rendering/object.dart:2395:7)
#22     RenderBox.layout (package:flutter/src/rendering/box.dart:2386:11)
#23     RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:122:14)
#24     RenderObject.layout (package:flutter/src/rendering/object.dart:2395:7)
[ 125 more frames omitted for brevity ]

Expected results

  • First (working) case does not clip widgets
  • Second case works - wrapping is necessary in real-world case to add localization and theming

Flutter version

Flutter 3.10.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 9cd3d0d9ff (6 weeks ago) • 2023-05-23 20:57:28 -0700
Engine • revision 90fa3ae28f
Tools • Dart 3.0.2 • DevTools 2.23.1

Repro

https://github.com/mdazy/golden_builder_assert

Related

flutter/flutter#129902

@mdazy
Copy link
Author

mdazy commented Jul 3, 2023

I have added a third example in the repository: wrapping the entire build() inside a single MaterialApp appears to work. I'm guessing multiple MaterialApps inside upper-level layout components are a no-go for Flutter.

However, even in that third example I'm still getting overflow/cropping issues. None of the examples are supplying an explicit size - am I wrong in assuming golden_toolkit is supposed to resize the consolidated screenshot as necessary?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant