Skip to content

OccludeWrapper: Getting "RenderBox was not laid out" issue in custom widgets #54

@jebstern

Description

@jebstern

I keep "RenderBox was not laid out" errors when using OccludeWrapper on custom widgets. Doesn't help if I give them height & width.

flutter_uxcam version: 2.5.2
Flutter SDK version: 3.22.0
Dart: 3.4.0

Error Message:

E/flutter (23543): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'package:flutter/src/rendering/box.dart': Failed assertion: line 2165 pos 12: 'hasSize': RenderBox was not laid out: RenderMouseRegion#bb55c NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
E/flutter (23543): #0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
E/flutter (23543): #1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
E/flutter (23543): #2      RenderBox.size (package:flutter/src/rendering/box.dart:2165:12)
E/flutter (23543): #3      RenderBox.paintBounds (package:flutter/src/rendering/box.dart:2903:41)
E/flutter (23543): #4      GlobalKeyExtension.globalPaintBounds (package:flutter_uxcam/src/widgets/occlude_wrapper.dart:82:46)
E/flutter (23543): #5      _OccludeWrapperState.getOccludePoints (package:flutter_uxcam/src/widgets/occlude_wrapper.dart:58:30)
E/flutter (23543): #6      _OccludeWrapperState.initState.<anonymous closure> (package:flutter_uxcam/src/widgets/occlude_wrapper.dart:30:9)
E/flutter (23543): #7      _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
E/flutter (23543): #8      _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
E/flutter (23543): #9      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
E/flutter (23543): 

If I replace the Timer in OccludeWrapper --> initState() method to use WidgetsBinding.instance.addPostFrameCallback((_) {});, then the app works normally. (Haven't verified end results in UXCam dashboard yet)

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions