Support for conditional children wrappers
It would be nice to have possibility to make conditional containers for children.
component MyComponent {
if condition : some_id := CustomWrapper {
@children
} else : VerticalLayout {
@children
}
}
else isn't currently supported in the context of conditional rendering. But - aside from its convenience and redundancy reduction potential - it would be a natural way in a limited local context to guarantee that only one @children is rendered. It's far from the sophistication of Rust's compile-time proofs, but it's a start.
Related: https://github.com/slint-ui/slint/issues/6258
I've just gotten the error:
The @children placeholder cannot appear in a conditional element
This was in the context of the implementation of a modal that fades out when being closed using opacity, and that shouldn't keep its subtree including @children alive while the modal isn't needed, which would be most of the time. Every modal instance's outermost element would always exist, though.
So, this changing is basically part of the request of this issue.