Add push_maybe to Column and Row

This commit is contained in:
Héctor Ramón Jiménez 2024-02-15 02:38:07 +01:00
parent e57668d677
commit feab96f323
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
9 changed files with 144 additions and 95 deletions

View file

@ -124,6 +124,19 @@ where
self.children.push(child);
self
}
/// Adds an element to the [`Column`], if `Some`.
pub fn push_maybe(
self,
key: Key,
child: Option<impl Into<Element<'a, Message, Theme, Renderer>>>,
) -> Self {
if let Some(child) = child {
self.push(key, child)
} else {
self
}
}
}
impl<'a, Key, Message, Renderer> Default for Column<'a, Key, Message, Renderer>