问题描述
因此,我目前正在开发一个应用程序项目,现在我想将两个文本行分别放在一行的上方。例如,它应该这样 app demo created with figma。到目前为止,我有一排包含相同高度的每个元素的行,但是我很难将两个元素放在一行中并排放置。我已经找到了一个叫做Stack的类,但是我很难实现它。在我的Stack类中,我有一个RichText类。从flutter api中,我了解到您必须使用容器(才能定义位置)。所以我想知道是否应该在Stack类之后立即切换到容器类,然后在每个Container类中放置RichText吗?如果我对此有什么建议,或者只是如何在图片中创建类似的东西,那将是很棒的。预先感谢。
解决方法
添加了您要实现的目标的演示:
Column(
crossAxisAlignment: CrossAxisAlignment.start,mainAxisAlignment: MainAxisAlignment.center,children: [
// row containing the avatar,name,date and icons (likes and comments)
Row(
children: [
// circle avatart
CircleAvatar(
backgroundColor: Colors.blue,radius: 25,),// spacing
SizedBox(
width: 10,// the name of poster and date in a column
Column(
crossAxisAlignment: CrossAxisAlignment.start,children: [
Text(
'Claire',Text(
'July 03 at 13:08PM',],// spacer
Spacer(),// likes icon
Icon(Icons.favorite_border),Text(
'32',// comments icon
Icon(
Icons.comment,// spacing
SizedBox(
height: 10,// title text
Text(
'Dorm recommendation',// decription
Text(
'Any recommendations on dorm application? Does anyone know how\'s the facility at Talent Apartment? Are there teamrooms and gym in TA? Also,updates on the location of washers and dryers?',maxLines: 3,overflow: TextOverflow.ellipsis,
结果: