How to put more than three elements in a listview

83 views Asked by At

Currently I need to display more than three elements in a list tile I used leading, title and trailing but I am unable to add an image inbetween the leading and title the current code I have vs the required listtile

return ListTile(
  tileColor: Colors.white,
  shape: RoundedRectangleBorder(

    borderRadius: BorderRadius.circular(10),
  ),
  leading:
      Icon(
    isSaved ? Icons.favorite : Icons.favorite_border,
    color: isSaved ? Colors.red : null,),
  title: Text(nameData.getName(index)),
  trailing: Text(
    nameData.getDate(index),
  ),
);

1

There are 1 answers

0
Babul On BEST ANSWER
leading: SizedBox(
  height: 100.0,
  width: 100.0, // fixed width and height
  child: Image.asset(...)
)

  leading: CircleAvatar(
      backgroundImage: AssetImage("..."), // no matter how big it is, it won't overflow
    ),

If you wanna use rectangle image, you an use

leading: ConstrainedBox(
  constraints: BoxConstraints(
    minWidth: 44,
    minHeight: 44,
    maxWidth: 64,
    maxHeight: 64,
  ),
  child: Image.asset(profileImage, fit: BoxFit.cover),
),