Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 294 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I get the height of a widget?

#1
I don't understand how `LayoutBuilder` is used to get the height of a widget.

I need to display the list of Widgets and get their height, so I can compute some special scroll effects. I am developing a package and other developers provide a widget (I don't control them). I read that LayoutBuilder can be used to get the height.

In a very simple case, I tried to wrap a widget in LayoutBuilder.builder and put it in the stack, but I always get `minHeight` `0.0`, and `maxHeight` `INFINITY`. Am I misusing the LayoutBuilder?

It seems that LayoutBuilder is a no go. I found the [CustomSingleChildLayout][1] which is almost a solution.

I extended that delegate, and I was able to get the height of widget in `getPositionForChild(Size size, Size childSize)` method. *but*, the first method that is called is `Size getSize(BoxConstraints constraints)` and as constraints, I get 0 to INFINITY because I'm laying these CustomSingleChildLayouts in a ListView.

My problem is that SingleChildLayoutDelegate `getSize` operates like it needs to return the height of a view. I don't know the height of a child at that moment. I can only return *constraints.smallest* (which is 0, and the height is 0), or *constraints.biggest* which is infinity and crashes the app.

In the documentation it even says:

> ...but the size of the parent cannot depend on the size of the child.

And that's a weird limitation.

[1]:

[To see links please register here]


Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through