在listview.builder上方的Flutter Scroll Carousel

时间:2019-10-02 01:22:30

标签: flutter dart

我想在listview.builder的上方添加轮播,但滚动只会在轮播下进行,并且轮播是固定的

//在此处滚动轮播

new Expanded(
                child: new ListView.builder(
                    itemCount: 4,
                    itemBuilder: (BuildContext context, int index) {
                         return itemFeed(context: context, index: index);
                    }
                )
            )

1 个答案:

答案 0 :(得分:1)

您可以使用Column来实现。切记在ListView.builder内用Expanded小部件包装Column

示例-

Column(
      mainAxisSize: MainAxisSize.max,
      children: <Widget>[
        Container(
          height: 100.0,
          width: double.infinity,
          child: Text('Fixed Box'),
          color: Colors.pink,
        ),
        Expanded(
          child: ListView.builder(
            itemBuilder: (context, index) => Text("Index - " + index.toString()),
            itemCount: 100,
          ),
        )
      ],
    )