the element type 'List' can't be assigned to the list type 'Widget'

前端 未结 4 1153
死守一世寂寞
死守一世寂寞 2021-02-05 03:19

I am trying to add data using for loop in gridview but it is showing some error. Here is my code for component

return new GridView.count(
    crossAxisCount: 2,
         


        
4条回答
  •  不知归路
    2021-02-05 03:49

    Since the answer was not satisfactory for me, so I found another solution.

    Flutter gives you the possibility to write conditions on a single line also in the graphic, so you can insert a cycle on a single line and then insert the other different widgets. This is a practical example in response to the main question:

     Column(
        children: 
          [
            for (int i = 0;
            i < workouts.series.length;
            i++)
              "//CREATE N YOUR WIDGETS//",
              new Text(
              "${workouts.series.length} x ${exerciseWorkout.repsToDo} ",
              style: TextStyle(
              color: Colors.black87,
              fontSize: 16,
              fontWeight: FontWeight.bold),
              )
          ],
         )
    

提交回复
热议问题