admin管理员组文章数量:1415138
I am using SearchAnchor with a SearchBar, and I want the viewConstraints to dynamically adjust based on the number of items in viewBuilder.
Currently, my code looks like this:
SearchAnchor(
viewConstraints: BoxConstraints.loose(Size.fromHeight(200)),
builder: (context, controller) => SearchBar(
suggestionsBuilder: (_, __) => [],
viewBuilder: (suggestions) => Column(
children: List.generate(
some_number,
(int index) => ListTile(title: Text('$some_number')),
),
),
),
)
Problem: Right now, viewConstraints takes a fixed height (200), but I need it to take only as much space as needed for the number of rows returned by viewBuilder. Setting min and Maxheight also didn't work, it always takes the MaxHeight. Adding the Flexbile widget also didn't work.
Since I don’t know the number of elements beforehand (it's only available inside viewBuilder), I can't predefine a proper constraint.
How can I ensure viewConstraints automatically adjusts based on the number of items in viewBuilder, without using a fixed height?
版权声明:本文标题:flutter - How to make viewConstraints dynamically adjust to viewBuilder content in SearchAnchor? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745196669a2647172.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论