I want to drop/delete a Renderbox in my class
class RenderDynamicTimeline extends RenderBox
with
ContainerRenderObjectMixin<RenderBox, DynamicTimelineParentData>,
RenderBoxContainerDefaultsMixin<RenderBox, DynamicTimelineParentData> {
///default Code
}
Here is my code for using dropChild()
:
void deleteChildBykey(Key? childKey) {
// Find the child with the matching key
for (final child in getChildrenAsList()) {
final dynamicTimelineParentData = child.parentData as DynamicTimelineParentData;
if (dynamicTimelineParentData.key == childKey) {
dynamicTimelineParentData.previousSibling = null;
dynamicTimelineParentData.nextSibling = null;
dropChild(child);
break;
}
}
}
Problem is, that I get a Null check operator used on a null value error
in the layout function from RenderDynamicTimeline
as I see through debugging, the child is already in the RenderDynamicTimeline as child there, but the parentData
is deleted.
The child is marked with NEEDS-PAINT DETACHED
How can I delete the child complete from the RenderDynamicTimeline
class?
as @pskink mentioned,
remove
is the solution: