• Michael Goderbauer's avatar
    Fix ParentDataWidget crash for multi view scenarios (#142486) · 3da5ff54
    Michael Goderbauer authored
    Fixes https://github.com/flutter/flutter/issues/142480.
    
    This fixes a crash occurring during hot reload when a `ViewAnchor` is used between a `ParentDataWidget` (like `Positioned`) and its closest `RenderObject` descendant. Prior to the fix, the `ParentDataWidget` was accidentally applying its parent data to the render object in the `ViewAnchor.view` slot, which crashed because that render object wasn't (and shouldn't be) setup to accept parent data (after all, it is in a different render tree). Instead, the parent data should only be applied to the render object in the `ViewAnchor.child` slot. Luckily, with `Element.renderObjectAttachingChild` we already have API in place to walk the widget tree such as that only `RenderObjectWidgets` from the same render tree are considered.
    3da5ff54
multi_view_parent_data_test.dart 1.58 KB