Closed xiangtailiang closed 3 years ago
ExpandableListView is a ListView of sections, all items in an section are build at once.
If you want item build when visible, use sectionBuilder
, wrap a sub listview in custom section:
class _SectionWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return SizedBox(
height: 100,
child: ListView(xxx),
);
}
}
I have update an nested listview example, may be it can help you.
All item in ExampleSection.items will call initState at once time, although the item is not visible. This will affect the smoothness of scrolling and the expanded/collapse action.
The example code as follow, the ExampleSection.items size set to 50.
The log: I/flutter (16350): tiger-test initState: 1 I/flutter (16350): tiger-test initState: 2 ... 省略 ... I/flutter (16350): tiger-test initState: 49 I/flutter (16350): tiger-test initState: 50