How to use conditional statement within child attribute of a Flutter Widget (Center Widget)

前端 未结 18 2131
再見小時候
再見小時候 2020-11-30 18:50

So far whenever I needed to use a conditional statement within a Widget I have done the following (Using Center and Containers as simplified dummy examples):



        
18条回答
  •  死守一世寂寞
    2020-11-30 19:45

    Here is the solution. I have fixed it. Here is the code

    child: _status(data[index]["status"]),
    
    Widget _status(status) {
      if (status == "3") {
        return Text('Process');
      } else if(status == "1") {
        return Text('Order');
      } else {
        return Text("Waiting");
      }
    }
    

提交回复
热议问题