renderChildren method

dynamic renderChildren(
  1. dynamic list
)

Implementation

renderChildren(list) {
  final List<Widget> children = [];

  // 遍历
  for (int index = 0; index < list.length; index++) {
    final item = list[index];
    final key = item.key == null ? index.toString() : item.key;
    final Widget child =
        Material(color: Colors.white, child: buildItem(key, index, item));

    // 判断是否卡片样式
    if (widget.card) {
      children.add(Padding(
          padding: EdgeInsets.only(top: index == 0 ? 0.0 : widget.clearance),
          child: child));
    } else {
      children.add(border);
      children.add(child);
    }
  }

  // 默认边框
  if (widget.card == false) children.add(border);

  return children;
}