如何在Flutter中使用DivorTiles()? [英] How to use divideTiles() in Flutter?

查看:115
本文介绍了如何在Flutter中使用DivorTiles()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图建立一个ListView与每个ListTile之间的分隔线. 我看到有一个静态方法可以做到这一点,称为dividTiles(),但我不知道如何使用它..如何/在何处使用此函数?

I am trying to build a ListView with dividers between each ListTile. I saw that there is a static method to do that called divideTiles() but i did not understand how to use that.. How/where is this function used?

我的代码是一个简单的ListView,其中ListTiles作为子级.

My code is a simple ListView with ListTiles as children.

推荐答案

ListView(
  children: ListTile.divideTiles(
    context: context,
    tiles: [
      // your widgets here
    ]
  ).toList(),
)

或者,您也可以使用ListView.separated:

ListView.separated(
  itemCount: 42,
  itemBuilder: (context, index) {
    // your widget here 
  },
  separatorBuilder: (context, index) {
    return Divider(); 
  },
);

这篇关于如何在Flutter中使用DivorTiles()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆