分组列表

一个 Flutter 分组列表小部件,类似于 iOS UITableview 的方法名。

适用于 Flutter 的 Group tablelist 包。

PubCI

WeChat72b21c420d6bb06007a44d196e78906a

功能

  • iOS tableview 风格的方法名。
  • 声音空安全。
  • 列表项可以按组分隔。
  • 可以设置整个列表的页眉和页脚。
  • 您可以使用 GroupTableList 中 Listview 的几乎所有原始参数。

入门

将包添加到您的 pubspec.yaml

group_tablelist: ^0.0.4

在您的 dart 文件中,导入库

import 'package:group_tablelist/group_tablelist.dart';

不要使用 SliverList,而是创建一个 SliverGroupTableList 小部件

SliverGroupTableList(
 numberOfSections: showcaseList.length,
 numberOfRowsInSection: (section) => showcaseList[section].item.length,
 cellForRowAtIndexPath: (indexPath) => _flutterShowcaseCell(
     showcaseList[indexPath.section].item[indexPath.row]),
 headerInSection: (section) => _makeHeaderOrFooterInSection(section),
 overallHeader: () => _makeOverAll('overallHeader'),
 overallFooter: () => _makeOverAll('overallFooter'),
 footerInSection: (section) => _makeHeaderOrFooterInSection(section),
 didSelectRowAtIndexPath: (indexPath) => _handleDidSelectAtIndexPath(indexPath),
) 

或者

不要使用 Listview,而是创建一个 GroupTableList 小部件

GroupTableList(
  numberOfSections: showcaseList.length,
  numberOfRowsInSection: (section) => showcaseList[section].item.length,
  cellForRowAtIndexPath: (indexPath) => _flutterShowcaseCell(
      showcaseList[indexPath.section].item[indexPath.row]),
  headerInSection: (section) => _makeHeaderOrFooterInSection(section),
  overallHeader: () => _makeOverAll('overallHeader'),
  overallFooter: () => _makeOverAll('overallFooter'),
  footerInSection: (section) => _makeHeaderOrFooterInSection(section),
  didSelectRowAtIndexPath: (indexPath) => _handleDidSelectAtIndexPath(indexPath),
) 

参数

GroupTableList

名称 描述 必需 默认值
numberOfSections 要求数据源返回列表中的节数。 no 1
numberOfRowsInSection 返回指定节中行的数量(表格单元格)。 必需
cellForRowAtIndexPath 返回您指定的索引路径处的表格单元格。 必需
separatorAtIndexPath 返回您指定的索引路径处的分隔符。 no
sectionSeparator 请求显示列表中指定节的分隔符。 no
headerInSection 请求显示列表中指定节的页眉视图。 no
footerInSection 请求显示列表中指定节的页脚视图。 no
overallHeader 整个列表的页眉视图。 no
overallFooter 整个列表的页脚视图。 no
placeholderView 没有数据时显示的无数据视图。 no
didSelectRowAtIndexPath 单击列表项时的回调。 no

SliverGroupTableList

名称 描述 必需 默认值
numberOfSections 要求数据源返回列表中的节数。 no 1
numberOfRowsInSection 返回指定节中行的数量(表格单元格)。 必需
cellForRowAtIndexPath 返回您指定的索引路径处的表格单元格。 必需
separatorAtIndexPath 返回您指定的索引路径处的分隔符。 no
sectionSeparator 请求显示列表中指定节的分隔符。 no
headerInSection 请求显示列表中指定节的页眉视图。 no
footerInSection 请求显示列表中指定节的页脚视图。 no
overallHeader 整个列表的页眉视图。 no
overallFooter 整个列表的页脚视图。 no
placeholderView 没有数据时显示的无数据视图。 no
didSelectRowAtIndexPath 单击列表项时的回调。 no
Listview 原有的其他参数

GitHub

查看 Github