1

I have circle avatars. I want to add each circle's avatar name at the bottom of the avatar. But I can not do this. when I run the below code, the text appears on the avatar.

My code

child: Container(
              height: 60.0,
              width: 60.0,
              margin: EdgeInsets.all(6.0),
              decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(100.0),
                  boxShadow: [
                    new BoxShadow(
                        color: Color.fromARGB(100, 20, 0, 0),
                        blurRadius: 5.0,
                        offset: Offset(5.0, 5.0))
                  ],
                  border: Border.all(
                      width: 2.0,
                      style: BorderStyle.solid,
                      color: Colors.purple),
                  image: DecorationImage(
                      fit: BoxFit.cover,
                      image: NetworkImage(userData[x]["image"]))),
                      child: new Text(userData[x]["name"], style: TextStyle(fontSize: 20.0),),
                      )
                      ));

Kirill Matrosov
  • 5,564
  • 4
  • 28
  • 39
jancooth
  • 555
  • 1
  • 10
  • 25

3 Answers3

4

If you are trying to Implementing like this:

enter image description here

then you can use Column or Stack widget. I used Stack with Align widget.

Code:


Container(
       height: 80.0,
       width: 80.0,
       child: Stack(
        children: <Widget>[
           Container(
             height: 60.0,
             width: 60.0,
             margin: EdgeInsets.all(6.0),
             decoration: BoxDecoration(
               //  shape: BoxShape.circle,
                 borderRadius: BorderRadius.circular(100.0),
                 boxShadow: [
                   new BoxShadow(
                       color: Color.fromARGB(100, 20, 0, 0),
                       blurRadius: 5.0,
                       offset: Offset(5.0, 5.0))
                 ],
                 border: Border.all(
                     width: 2.0,
                     style: BorderStyle.solid,
                     color: Colors.purple),
                 image: DecorationImage(
                     fit: BoxFit.cover,
                     image: NetworkImage("https://image.shutterstock.com/image-photo/cute-baby-girl-sitting-on-260nw-689375770.jpg"))),
                   // child:
           ),
           Align(
             alignment: Alignment.bottomCenter,
             child:  new Text("name", style: TextStyle(fontSize: 20.0),),
           )
         ],
      ),
    )

Kirill Matrosov
  • 5,564
  • 4
  • 28
  • 39
Shruti Ramnandan Sharma
  • 4,027
  • 13
  • 44
  • 76
1

You can try something like this following:

Container(
      child: Column(
        children: <Widget>[
          Container(
            height: 60.0,
            width: 60.0,
            alignment: Alignment.bottomCenter,
            margin: EdgeInsets.all(6.0),
            decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(100.0),
                boxShadow: [
                  new BoxShadow(
                      color: Color.fromARGB(100, 20, 0, 0),
                      blurRadius: 5.0,
                      offset: Offset(5.0, 5.0))
                ],
                border: Border.all(
                    width: 2.0,
                    style: BorderStyle.solid,
                    color: Colors.purple),
                image: DecorationImage(
                    fit: BoxFit.cover,
                    image: NetworkImage(
                        "https://source.unsplash.com/random"))),
          ),
          Text(
            "text....",
            style: TextStyle(fontSize: 16.0),
          )
        ], 
      ),
    )
ॐ Rakesh Kumar
  • 1,318
  • 1
  • 14
  • 24
0

you can use stack widget, like this:-

Container(
          height: 60,
          child: Stack(
            children: <Widget>[
            Container(
            height: 60.0,
            width: 60.0,
            margin: EdgeInsets.all(6.0),
            decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(100.0),
                boxShadow: [
                  new BoxShadow(
                      color: Color.fromARGB(100, 20, 0, 0),
                      blurRadius: 5.0,
                      offset: Offset(5.0, 5.0))
                ],
                border: Border.all(
                    width: 2.0,
                    style: BorderStyle.solid,
                    color: Colors.purple),
                image: DecorationImage(
                    fit: BoxFit.cover,
                    image: NetworkImage(userData[x]["image"]))),
          ),
              Positioned(
                bottom: 5.0,
                right:5.0
                child: Text(userData[x]["name"], style: TextStyle(fontSize: 20.0),),
              )
            ],
          ),
        )