-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Intrinsic Sizing #45
Comments
Once I finally wrapped my head around the flutter layout approach, I realized I really need this. I did a crude implementation, currently only for width and for a limited set of widgets that covers my needs: I'm not sure how to calculate intrinsic height without access to the DOM, so I added the DOM and the current node as an argument to the trait methods. Ideally, I'd like to see this functionality in the mainline, so let me know if you're interested in a pull request and if this approach fits with the general design of the library. |
@johann2 We've run into a couple cases where this would be very useful, like making panels for our editor or sizing a container for a list of objects according to the largest item's cross-axis size. I'd like to try implementing this feature this week based on your implementation. There's a bunch of stuff banked up that needs to be completed and merged with the library and my focus has been elsewhere. |
Yeah, this implementation is enough for my use case. The main reason was that I needed to create columns where every child has the width of the widest element, without manually specifying the width. The most notable omission is that the text widget's implementation returns 0.0 as it seemed a bit more complex and I didn't really need it.
That would be nice. Note that I found a bug in the commit I posted, so please use the latest commit in my fork instead |
A lesser-known part of the Flutter layout algorithm is that objects can report their intrinsic size as opposed to just computing their actual size when performing layout.
This would simplify a lot of widgets and open a lot of doors for us, like being able to implement
IntrinsicSize
.Here's some interesting code in Flutter about this: https://github.com/flutter/flutter/blob/f1875d570e39de09040c8f79aa13cc56baab8db1/packages/flutter/lib/src/rendering/box.dart#L1449
as well as in the flex layout code: https://github.com/flutter/flutter/blob/47035a0102339c0464b1866a09cd6a25e86922d7/packages/flutter/lib/src/rendering/flex.dart#L664
API Additions
As part of this, we'll add two new methods to
Widget
:The text was updated successfully, but these errors were encountered: