rf_section_listview 0.0.3 copy "rf_section_listview: ^0.0.3" to clipboard
rf_section_listview: ^0.0.3 copied to clipboard

rf_section_listview is section listView package for flutter

rf_section_listview #

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

Simulator Screen Shot - iPhone 12 - 2021-11-19 at 16.03.19.png

使用 #

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 //可选
      ),
    );
  }
}
1
likes
100
pub points
69%
popularity

Publisher

unverified uploader

rf_section_listview is section listView package for flutter

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on rf_section_listview