Comments (8)
Here's an example.
I have a column containing children with some padding between them. The children themselves are containers with dynamic height that may have some "ornaments" floating around them, which initially could be Positioned children of a Stack. The ornaments are also dynamic, and thus, only know their size after layout.
Example with ornaments around children:
The problem is that sometimes those ornaments overlap, which is not desired. I'd like to increase the padding accordingly only if there are overlaps. And for that, I need to know the rects of those ornaments, or worst case scenario, the rect of the column children including the ornaments, so I can compute the minimum amount of padding necessary so they don't overlap.
Desired result after pushing overlaps:
The real problem though is not laying out the children. A Stack can do it just fine. What I need is access to the child rect during layout phase including the space of floating children.
from boxy.
The framework makes very strong assumptions about how data is passed between RenderObjects during layout, specifically, only constraints can go down and only geometry can go up, any communication outside of that would break layout optimizations.
Adding more properties to the geometry (Size / SliverGeometry) would require writing a RenderObject subclass and handling its new protocol in the parent.
Luckily if the information is known during build, you can just use parent data: https://gist.github.com/PixelToast/2d51cc484d9a7a6a15c1bd405712a3d4
from boxy.
@PixelToast I see. In that case, I think I'll have to dive in custom RenderObjects.
While I'm at it, may I ask if using a lot of GlobalKeys to access deep nested children impacts on performance or is just not a good practice in general?
from boxy.
The only significant cost to GlobalKey is when its used to reparent the child widget, accessing it alone is usually fine.
You shouldn't use it to access descendants during layout though, that would break a lot of the assumptions the framework makes (there are a bunch of assertions that should prevent you from doing that too).
from boxy.
Also the gist I posted above implements what I thought you wanted to do, and it doesn't require subclassing RenderObject.
from boxy.
In my use case, I don't know the size of the children during build time.
Actually, what I'm looking for is more accurately described as a Stack with non-positioned children whose size are not know until layout.
from boxy.
The gist doesn't rely on the size of the child being known at build time, only OverflowingChild.padding
Do you have a diagram or example of the layout you are trying to achieve?
from boxy.
Moving to #24
from boxy.
Related Issues (20)
- Can boxy deal with adjusting listview position when an item changes height? HOT 3
- Finding child Offeset HOT 4
- How to remove a rendered widget? HOT 4
- Ignore layout for somes childs ? HOT 2
- [Question] - Can I use Boxy to build a Flutter version of Angular FlexLayouts HOT 2
- Get widget's global position inside custom layout delegate HOT 3
- Problem with rendering a CustomBoxy when a new item is added to an animated list HOT 3
- Something wrong when using custom boxy and layer link HOT 3
- Strange behavior occurs when a Wrap widget is used in a Custom boxy. HOT 2
- [Question] Centered widget or Scrollable widget HOT 3
- Custom layout protocols
- Make `BoxyFlex` Implement `Flex` HOT 1
- [Question] is there a simple way to change the Tree View so that it is horizontally oriented? HOT 2
- OverflowPadding hitTest HOT 3
- `RedirectPointer` is not importable HOT 1
- [Feature Request] Sliver OverflowPadding
- Skip ignored children in `RenderObject.visitChildrenForSemantics` HOT 2
- [Feature request] `BaseBoxyDelegate.getChildOrNull` HOT 1
- [Question] Layout child reorder
- Overriden shouldRelayout doesn't have access to BoxyDelegate HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from boxy.