Fix panic when grid widget is empty

This commit is contained in:
Héctor Ramón Jiménez 2025-12-08 21:36:19 +01:00
parent 3997291f31
commit 6fe7c2bdd5
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -192,6 +192,14 @@ where
Constraint::Amount(amount) => amount,
};
if self.children.is_empty() || cells_per_row == 0 {
return layout::Node::new(limits.resolve(
size.width,
size.height,
Size::ZERO,
));
}
let cell_width = (available.width
- self.spacing * (cells_per_row - 1) as f32)
/ cells_per_row as f32;