Flutter中图像形状的变化

xqnpmsa8  于 2022-11-17  发布在  Flutter
关注(0)|答案(2)|浏览(156)

希望大家都做得好。我是新的Flutter我想知道如何给这样的图像形状,我已经附上了样本...图像来自数据库

z4bn682m

z4bn682m1#

您可以使用Stack小部件,

Stack(
  clipBehavior: Clip.hardEdge,
  children: [
    Positioned(
      top: -30, //negative value will shift to up side 
      right: -30, // this will shift pixel to the right
      child: Container(
          width: 100, //,
          height: 100,
          child: Image.network(
            " ",
            fit: BoxFit.cover,
          )),
    )
  ],
),
wbrvyc0a

wbrvyc0a2#

将Container和BoxDecoration与clipBehaviour沿着使用。将Container的形状设置为所需的形状,然后将clipBehaviour设置为Clip.hardEdge

Container(
  decoration: const BoxDecoration(shape: BoxShape.circle),
  clipBehavior: Clip.hardEdge,
  width: MediaQuery.of(context).size.height * 0.08,
  height: MediaQuery.of(context).size.height * 0.08,
  child: Image.asset('assets/default_avatar.png')),

相关问题