如何在列表中显示列表的内容

时间:2020-06-15 16:03:38

标签: list flutter

我非常陌生,我想将列表的内容显示为文本,我不能使用listview构建器,因为它是轮播...... ................................................... ........我应该添加哪种代码

List<String> _quotes = ["a","b","c"];
@override
Widget build(BuildContext context) {
return Builder(
  builder: (ct) {
    return Scaffold(
      backgroundColor: Colors.lightBlue,
      body: Container(
        child: Column(children: [
           Container(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children:[
                 Container(
                  padding: EdgeInsets.fromLTRB(0, 80, 0, 100),
                  child: CarouselSlider(
                    options: CarouselOptions(height: 450),
                    items: [
                      Container(
                        width: 500,
                        child: Card(
                          color: Colors.white,
                          semanticContainer: true,
                          child: Container(
                            child: Text(_quotes[index]
                              ,
                              textAlign: TextAlign.center,
                              style: TextStyle(
                                  fontWeight: FontWeight.bold,
                                  fontSize: 30,
                                  color: Colors.black),
                            ),
                            alignment: Alignment.center,
                          ),
                        ),
                      ),
                    ],
                  ),)],),),

1 个答案:

答案 0 :(得分:0)

这应该对您有帮助

CarouselSlider(
      options: CarouselOptions(height: 450),
      items: _quotes.map((quote) {
        return Container(
          width: 500,
          child: Card(
            color: Colors.white,
            semanticContainer: true,
            child: Container(
              child: Text(quote,
                textAlign: TextAlign.center,
                style: TextStyle(
                    fontWeight: FontWeight.bold,
                    fontSize: 30,
                    color: Colors.black),
              ),
              alignment: Alignment.center,
            ),
          ),
        );
      }).toList(),
    )