How to add the widgets dynamically to column in Flutter?

后端 未结 4 1034
日久生厌
日久生厌 2021-02-08 10:55

I have added a few widgets inside the ListView. So that I can scroll all widgets. Now I required to add one more widget to the ListView to load the li

4条回答
  •  长发绾君心
    2021-02-08 11:22

    In Addition to @Derek Lakin's Answer which worked for me too, it is also required to call setState(), if you need to update the comments and reload.

    var commentWidgets = List();
    for (var comment in comments) {
          commentWidgets.Add(Text(comment.text)); // TODO: Whatever layout you need foreach widget.
    }
    setState(() {
    
    });
    

提交回复
热议问题