【发布时间】:2020-08-10 02:53:37
【问题描述】:
我想找到一种解决方案,在 Flutter 包装的小部件结构上模拟附加图像 Android 约束布局。
在这种情况下,蓝色文本 TextView 宽度是换行内容和图像(美元符号)必须采用相同的宽度。
有什么建议吗?非常感谢!
这是我目前的代码,一个简单的专栏,我尝试了很多替代方案,但我无法从逻辑上弄清楚:/
Widget _getPublisherLogoImage() {
return ClipOval(
child: CachedNetworkImage(
imageUrl: _publisherLogo,
placeholder: (context, url) => CircularProgressIndicator(),
errorWidget: (context, url, error) => Icon(Icons.error),
width: 50,
height: 50,
),
);
}
Widget _getNewsItemHour(BuildContext context) {
return Padding(
padding: EdgeInsets.only(top: 8),
child: Text(DateUtils.getHoursMinutesStringDate(_timestamp),//'09:35',
style: TextStyle(
fontSize: 14,
color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold))
);
}
Widget _getNewsItemQuotation() {
return Padding(
padding: EdgeInsets.only(top: 8),
child: Text('\$$_price',
style: TextStyle(
fontSize: 18,
color: Colors.black,
fontWeight: FontWeight.bold))
);
}
.
.
.
Column(
children: <Widget>[
_getPublisherLogoImage(),
_getNewsItemHour(context),
_getNewsItemQuotation()
],
)
.
.
.
【问题讨论】:
-
分享你的代码你尝试了什么?
-
感谢 Sandeep,代码共享。我目前的方法是为图像小部件设置固定大小,尝试了很多替代方法,但我不知道如何设置这两个小部件之间的关系
标签: flutter layout flutter-layout