如何从Flutter中的REST API制作水平Listview.builder?

时间:2020-08-10 20:56:58

标签: rest flutter listview dart layout

我正在尝试使用REST API中的数据制作水平列表视图,我已经有了数据,问题被填满了屏幕 这是我的代码:

Positioned(
      top: 270,
      bottom: 0,
      right: 0,
      left: 30,
      child: new Container(
        height: 100,
        constraints: new BoxConstraints(
//              minHeight: 40.0
            ),
            child: FutureBuilder(
              future: getKategori('kelas'),
              builder: (BuildContext context, AsyncSnapshot snapshot){
                if(snapshot.data==null){
            }else{
              return Container(
                  height: 100,
                  child: ListView.builder(
                      itemCount: snapshot.data.length,
                      scrollDirection: Axis.horizontal,
//                      mainAxisSize: MainAxisSize.min,
                          itemBuilder: (BuildContext context, int index){
                        return
                          new Container(
                              height: 10,
                              child: Card(
                                child: new Text(snapshot.data[index].nama),
                              )
                          );`
}
                    )
                  );

            }
          }
        ),


      ),
    ),

这是屏幕截图 enter image description here

有人可以帮助我吗?

0 个答案:

没有答案