Search code examples
flutterdartwidgetgesturedetector

How to add circleAvatar with listView layout


I am trying to display the contact list with gesture detector but I am unable to add the CircleAvatar image icon before the contact name. Here is the code:

return Scaffold(
        body: new ListView.builder(
      //return ListView.builder(
        itemCount: _contacts!.length,
        itemBuilder: (BuildContext context, int index) {

       return new GestureDetector(
        child: SizedBox(
           height: 75.0,
           child: Text(_contacts![index].displayName),
            
        ),

      onTap: () {
        speak(_contacts![index].displayName);
      },
      onDoubleTap: (){
        speak("double tapped");
      },

    );}));

enter image description here


Solution

  • return  GestureDetector(
          onTap:(){},
            child: Row(
    crossAxisAlignment: CrossAxisAlignment.center,
            children:[
           CircularAvatar(child:Image.network(_contacts![index].imageurl
    )),
    Text(_contacts![index].displayName)
           ]
            ),