flutter ListView.separated使用

ListView.separated 在flutter使用中主要是修饰列表的分割线

Scrollbar(
        child: ListView.separated(
      itemCount: _dataList.length,
//        itemExtent: 40.0,
      separatorBuilder: (BuildContext context, int index) {
        return index % 2 == 0 ? _divider2 : _divider1;
      },
      itemBuilder: (BuildContext context, int index) {
        if (_dataList[index] == loadEndTag) {
          if (_dataList.length < MAX_SIZE) {
            _generateData();
            return Container(
              alignment: Alignment.center,
              padding: EdgeInsets.symmetric(vertical: 10),
              child: SizedBox(
                  width: 28,
                  height: 28,
                  child: CircularProgressIndicator(strokeWidth: 2)),
            );
          } else {
            return Container(
                alignment: Alignment.center,
                padding: EdgeInsets.symmetric(vertical: 10),
                child: Text(
                  "加载完毕",
                  style: TextStyle(color: Colors.red),
                ));
          }
        }
        return Container(
          height: 50,
          color: index % 2 == 0 ? _color1 : _color2,
          child: Center(
            child: Text("$index"),
          ),
        );
      },
    ));

你可能感兴趣的:(flutter,javascript,ios)