when function
Returns child when condition is true, otherwise an empty node.
This is useful in collection literals where a nullable child would be less readable:
div(children: [
text('Account'),
when(isAdmin, Badge('Admin')),
]);
Implementation
ReactNode? when(bool condition, ReactNode child) => condition ? child : null;