如何在flutter中给予CircleAvatar();小部件一个渐变色?
CircleAvatar();
fykwrbwg1#
Container( decoration: BoxDecoration( shape: BoxShape.circle, gradient: LinearGradient( colors: [ color1, color2, ], begin: Alignment.bottomLeft, end: Alignment.topRight ) ), child: CircleAvatar( child: Text( 'MS', style: TextStyle( color: Colors.white ) ), backgroundColor: Colors.transparent ) )
50few1ms2#
通过将Container作为CircleAvatar的子项,并将gradient属性赋予Container,我实现了我想要的功能。
CircleAvatar( radius: 40, child: Container( decoration: BoxDecoration( shape: BoxShape.circle, gradient: LinearGradient( colors: [ color1, color2, ], ), ), ), ),
62lalag43#
首先,我用Container Package CircleAvatar,并给予形状和渐变色赋予Container,将透明色赋予CircleAvatar。
Container
CircleAvatar
child: Container( decoration: BoxDecoration( gradient: LinearGradient( colors: [Colors.red, Colors.orange]), shape: BoxShape.circle, ), child: CircleAvatar( backgroundColor: Colors.transparent, radius: 45, ), ),
3条答案
按热度按时间fykwrbwg1#
50few1ms2#
通过将Container作为CircleAvatar的子项,并将gradient属性赋予Container,我实现了我想要的功能。
62lalag43#
首先,我用
Container
PackageCircleAvatar
,并给予形状和渐变色赋予Container
,将透明色赋予CircleAvatar
。