v1.1.3sticky_and_expandable_list
섹션 전개/접기 및 스티키 헤더를 지원하는 그룹화된 목록을 만들고, 슬리버 위젯과 함께 사용할 수 있도록 합니다.
175좋아요 1만30일 다운로드140Pub 점수
AndroidiOSWebmacOSWindowsLinux
스티키 헤더 및 그룹화 목록 Sliver 구현 그룹화된 목록을 만들고 섹션의 확장/접기 기능과 스티키 헤더를 지원하며 Sliver 위젯과 함께 사용할 수 있도록 합니다.
{"sdk":"flutter"}{"sdk":"flutter"}아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
Flutter implementation of sticky headers and expandable list.Support use it in a CustomScrollView.
Screenshot
In the pubspec.yaml of your flutter project, add the following dependency:
dependencies:
sticky_and_expandable_list: ^1.1.3
sectionList is a custom data source for ExpandableListView.
We should create a model list to store the information of each section, the model must implement ExpandableListSection.
//In this example, we create a custom model class(ExampleSection).
//class ExampleSection implements ExpandableListSection<String> {}
//so: SliverExpandableChildDelegate<String, ExampleSection>()
List<ExampleSection> sectionList = List<ExampleSection>();
return ExpandableListView(
builder: SliverExpandableChildDelegate<String, ExampleSection>(
sectionList: sectionList,
headerBuilder: (context, sectionIndex, index) =>
Text("Header #$sectionIndex"),
itemBuilder: (context, sectionIndex, itemIndex, index) {
String item = sectionList[sectionIndex].items[itemIndex];
return ListTile(
leading: CircleAvatar(
child: Text("$index"),
),
title: Text(item),
);
}),
);
If you want to use it with sliver widget, use SliverExpandableList instead of ExpandableListView.
setState(() {
sectionList[i].setSectionExpanded(true);
});
@override
Widget build(BuildContext context) {
ExpandableListView(
builder: SliverExpandableChildDelegate<String, ExampleSection>(
headerController: _getHeaderController(),
),
)
}
_getHeaderController() {
var controller = ExpandableListController();
controller.addListener(() {
print("switchingSectionIndex:${controller.switchingSectionIndex}, stickySectionIndex:" +
"${controller.stickySectionIndex},scrollPercent:${controller.percent}");
});
return controller;
}
Use sectionBuilder