我是 dart/flutter 新手,并尝试在该图像小部件周围添加一个小的黑色边框,但我不知道如何操作。
代码:
Align(
alignment: const Alignment(0.0, -0.15),
child: image.isNotEmpty
? Image.asset(
image,
width: 400,
height: 200,
fit: BoxFit.cover,
)
: SizedBox.shrink(),
),
您可以将
Container
与 DecorationImage
一起使用。
Container(
width: 400,
height: 200,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: Colors.deepPurpleAccent,
width: 2,
),
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage(image),
),
),
),