flutter - 如何在颤动的图像上添加文本?
问题描述
这是带有边框的图像的代码,
Container(
child: Image.network(
"https://drive.google.com/uc?export=view&id=139Wu8bbLz5ubRECzdEmZof8crfGhx0oA", height: 140,fit: BoxFit.cover),
decoration: BoxDecoration(
border: Border.all(color: Colors.black12, width: 1),
),
),
如何以这样的方式添加文本,以便获得给定图像中的输出?
解决方案
您可以使用Stack
,这是一个示例:
Stack(
children: [
Container(
child: Image.network(
"https://drive.google.com/ucexport=view&id=1GgUaQNmNaY2h2oRqgBECQZzJ4I6MnV8G",
height: 140,
fit: BoxFit.cover,
),
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(Radius.circular(7)),
border: Border.all(color: Colors.black12, width: 1),
),
),
Positioned(
child: Text(
'Vegetables',
style: TextStyle(
fontSize: 42,
shadows: <Shadow>[
Shadow(
offset: Offset(1.0, 5.0),
blurRadius: 2.0,
color: Color.fromARGB(255, 0, 0, 0),
),
],
),
),
top: 45,
left: 20,
)
],
)
推荐阅读
- python - 在python中使用twisted,如何使用多客户端UDP服务器进行语音聊天
- list - 将列表扩展为具有 n 个元素的列表列表
- python - 写入文件的问题导致 Errno 22
- r - 您如何解释 CLMM 中的阈值(截距和优势比)
- python - Pyomo + Mosek 麻烦:系数矩阵不是半正定的
- java - 在java中查找重复部分(a / b)并仅将重复整数打印为字符串?
- php - 从表中获取空值
- haskell - Haskell 左箭头运算符替代
- reactjs - 根据 if 语句返回网页布局
- docker - Docker image failed with caniuse-lite is outdated 错误