rf_section_listview

Last updated:

0 purchases

rf_section_listview Image
rf_section_listview Images
Add to Cart

Description:

rf section listview

rf_section_listview #
the section listview package for flutter
仿iOS group tableview的小组件- rf_section_listview,支持 自定义分组,自定义组头、自定义组尾,使用和iOS tableview代理类似,非常方便。

使用 #
class _MyHomePageState extends State<MyHomePage> {
ScrollController? controller;

//返回多少组
int _numberOfSection() {
return personGroups.length;
}

//每组多少行
int _numberOfRowInSection(int section) {
return personGroups[section].persons.length;
}

// 每行的样式
Widget _cellForRowAtIndexPathBuilder(BuildContext context, IndexPath indexPath) {
final person = personGroups[indexPath.section].persons[indexPath.row];
return GestureDetector(
onTap: () {
_onClickCellItem(indexPath);
},
child: Padding(padding: EdgeInsets.all(8.0),child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(person.name),
Text('${person.height}'),
],)
),
);
}

//组头样式
Widget _sectionHeaderBuilder(BuildContext context, int section) {
final personGroup = personGroups[section];
return Text('${personGroup.groupName} header');
}

//组尾样式
Widget _sectionFooterBuilder(BuildContext context, int section) {
final personGroup = personGroups[section];
return Text('${personGroup.groupName} footer');
}

//点击事件
void _onClickCellItem(IndexPath indexPath) {
print('点击了 第${indexPath.section}组, 第${indexPath.row}行');
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text('rf_section_listview demo'),
),
body: SectionListView(
numberOfSection: _numberOfSection,
numberOfRowInSection: _numberOfRowInSection,
cellForRowAtIndexPathBuilder: _cellForRowAtIndexPathBuilder,
sectionHeaderBuilder: _sectionHeaderBuilder, //可选
sectionFooterBuilder: _sectionFooterBuilder, // 可选
controller: controller //可选
),
);
}
}
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.