Add debug warnings for layout gotchas
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 9.7k
- Forks
- 565
- PR merge metrics
- No merged PRs in 30d
Description
There are some layouts that are expressible in our system, but nonsensical, that we want to watch out for. When we can we'd like to log a warning, and if possible fix the API to make nonsensical layouts harder or impossible to layout. But warnings are a good first step.
Here are a few:
1. A "minimum" constraint of infinity makes no sense.
2. A child returning infinity as its size makes no sense (infinity should only be passed down to children, never bubbled back up). I believe this can currently happen with a flexible widget inside an align widget, for instance.
3. As far as I know, passing an infinite width to an align widget that's trying to center horizontally makes no sense, and same for height / vertical. However, an align widget could center something in one axis and still be fine with max infinity in the other — centering in a vertical scroll comes to mind.
4. If you try to "expand" a SizedBox inside of infinity that should be bad.
When possible, warnings can be added to the BoxConstraints method `debug_check`. `constrain` might also be a good spot. Not sure if that will work for all of these.
If you know of any other gotchas please add them!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the BoxConstraints methods `debug_check` and `constrain`, which the issue identifies as likely warning points. Trace how infinite minimum constraints, child sizes, alignment, and SizedBox expansion reach those methods. Done means the listed nonsensical layouts produce useful debug warnings where possible without rejecting valid infinite constraints.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- desktop
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100