Search code examples
flutterdartflutter-layout

How to give gradient to CircleAvatar in flutter?


How to give a gradient color to CircleAvatar(); widget in flutter ?


Solution

  • I was able to achieve the functionality I was looking for by using a Container as child of CircleAvatar and giving gradient properties to the Container.

     CircleAvatar(
            radius: 40,
            child: Container(
              decoration: BoxDecoration(
                shape: BoxShape.circle,
                gradient: LinearGradient(
                  colors: [
                    color1,
                    color2,
                  ],
                ),
              ),
            ),
          ),