Pondikpa Tchabao
Pondikpa Tchabao

Reputation: 3665

how to make a control in listTile with flutter

how to make a control in a lisTile with flutter. i get datas from json and display them in a listTile,. but i want to make a if control to show a button.

if(data[position]['value'] == 0){
       sho raised button;
}else{
    don't show it;

}

Upvotes: 4

Views: 7554

Answers (1)

Jonathan
Jonathan

Reputation: 392

You can add a button on the trailing edge of the tile, using the trailing property of ListTile.

For example, here we add an IconButton :

Widget _ = ListView.builder(
    itemBuilder: (BuildContext context, int index) {
      return ListTile(
          title: Text("Row $index"),
          trailing: (data[position]['value'] == 0)
              ? IconButton(icon: Icon(Icons.alarm), onPressed: () {})
              : null);
    });

Upvotes: 5

Related Questions