ListView

作者: 不二客 | 来源:发表于2020-08-08 16:46 被阅读0次

ListView

ListView({
    Key key,
    Axis scrollDirection = Axis.vertical, //列表的滚动方向
    bool reverse = false,
    ScrollController controller,
    bool primary,
    ScrollPhysics physics,//
    bool shrinkWrap = false,//列表的长度是否仅包裹其内容的长度 当ListView嵌在一个无限长的容器组件中时,shrinkWr   
                                            ap必须为true,否则Flutter会给出警告;
    EdgeInsetsGeometry padding,//间距
    this.itemExtent,//子元素长度
    bool addAutomaticKeepAlives = true,//添加自动保持有效
    bool addRepaintBoundaries = true,//添加重绘边界
    bool addSemanticIndexes = true, //添加语义索引
    double cacheExtent, // 预渲染区域长度
    List<Widget> children = const <Widget>[],
    int semanticChildCount,
    DragStartBehavior dragStartBehavior = DragStartBehavior.start, //拖动开始行为
    ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, //滚动视图键盘关闭行为
  })

DragStartBehavior

拖动开始行为
down 向下
start 开始

ScrollViewKeyboardDismissBehavior

滚动视图键盘关闭行为
manual 手册
onDrag 拖航

ListView.builder

  childrenDelegate = SliverChildBuilderDelegate(
         itemBuilder,
         childCount: itemCount,
         addAutomaticKeepAlives: addAutomaticKeepAlives,
         addRepaintBoundaries: addRepaintBoundaries,
         addSemanticIndexes: addSemanticIndexes,
       )

ListView.separated

 childrenDelegate = SliverChildBuilderDelegate(
         (BuildContext context, int index) {
           final int itemIndex = index ~/ 2;
           Widget widget;
           if (index.isEven) {
             widget = itemBuilder(context, itemIndex);
           } else {
             widget = separatorBuilder(context, itemIndex);
             assert(() {
               if (widget == null) {
                 throw FlutterError('separatorBuilder cannot return null.');
               }
               return true;
             }());
           }
           return widget;
         },

ListView.custom

 const ListView.custom({
    Key key,
    Axis scrollDirection = Axis.vertical,
    bool reverse = false,
    ScrollController controller,
    bool primary,
    ScrollPhysics physics,
    bool shrinkWrap = false,
    EdgeInsetsGeometry padding,
    this.itemExtent,
    @required this.childrenDelegate,
    double cacheExtent,
    int semanticChildCount,
  }) :

相关文章

网友评论

      本文标题:ListView

      本文链接:https://www.haomeiwen.com/subject/zjckrktx.html