ListViewBuilder<T extends ListItem> class abstract

标准列表构建类
通过继承实现不同List的构造创建。

Example:

  class MessListItem implements ListItem{
    MessListItem(this.name);
    String name;
  }

  class MessListBuilder extends ListViewBuilder<MessListItem> {
    MessListBuilder(List<MessListItem> list, OnItemTaped<MessListItem> onItemTap) : super(list, onItemTap);

    @override
    Widget itemBuild(BuildContext context, MessListItem item, int index) {
      return Text(item.name);
    }
  }

默认空数据页返回空数据文字,如果需要自定义,重写buildBlank方法。

  class MessListBuilder extends ListViewBuilder<MessListItem> {
    ...

    @override
    Widget buildBlank() {
      return Text("Blank");
    }
  }

创建列表页

 @override
 Widget build(BuildContext context) {
   return Container(
     child: MessListBuilder(
         list: _list,
         onItemTap: (item, index) {
            print(_list[index]);
           /// 显示详情
           _showDetails(_list[index].mess);
         }).build(),
   );
 }

Constructors

ListViewBuilder({required List<T> list, OnItemTaped<T>? onItemTap, double height = 80, ScrollController? scrollController, String blankTitle = "", VoidCallback? onPullToRefreshed, VoidCallback? onLoadingMore})

Properties

blankTitle String
list的长度为0时,显示的文字内容。
final
hashCode int
The hash code for this object.
no setterinherited
height double
高度(一个控件的高度)
final
isLoading bool
是否加载中
getter/setter pair
list List<T>
数据列表
final
onItemTap OnItemTaped<T>?
单个控件点击事件
final
onLoadingMore VoidCallback?
加载更多
final
onPullToRefreshed VoidCallback?
状态改变
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scrollController ScrollController?
final

Methods

build() Widget
buildBlank() Widget
空数据状态下的界面显示内容
dispose() → void
init() → void
初始化上拉刷新
itemBuild(BuildContext context, T item, int index) Widget
单个List自定义控件
loadViewBuild() Widget
构建下拉刷新区域内容
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited