Solved: LIstView.builder in flutter


Asked by Md. M on December 09, 2021 (source).

In a column or any widget, when i am trying to use listview.builder it don't execute the code. But when i bundle listview.builder in expanded widget it successfully run. Why it runs in expanded widget not another widget?

in the 1st imagewithout expand widget Without expand and using shrinkwrap: true my output is like that, but why? In the 2nd image when i am wrapping my listview.builder in expanded widget it runs successfully, why?without expand 1st image code 2nd image code


Question answered by Suganya (source).

Listview.builder works in Column when you add shrinkwrap property as true. It is because listview and its parent takes different height or size, once you add shrinkwrap property it will get minimized to children height and will work fine. Without shrinkwrap it throw overflow or rendering error. And when you use it with expanded widget both parent and listview expands to the same height so it working fine with Expanded widget