Flutter 是否可以使MainAxisAlignment.spaceAround组件的一部分在颤振中左对齐
现在我有一个卡组件,它有三个元素:Flutter 是否可以使MainAxisAlignment.spaceAround组件的一部分在颤振中左对齐,flutter,Flutter,现在我有一个卡组件,它有三个元素: 通道配置文件图像 频道名称 显示频道订阅状态的按钮 现在我使用一个行组件来显示三个组件,这是我的完整代码: return Card( key: Key(counter.value.id.toString()), child: Padding( padding: const EdgeInsets.all(16.0), child: Container( child: Column(
- 通道配置文件图像
- 频道名称
- 显示频道订阅状态的按钮
return Card(
key: Key(counter.value.id.toString()),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
CircleAvatar(
radius: 20,
backgroundColor: Theme
.of(context)
.primaryColor,
backgroundImage: backgroundImage,
foregroundImage:foregroundImage,
),
Flexible(
child: Padding(
padding: const EdgeInsets.only(left: 8),
child: Text(
counter.value.subName,
softWrap: true,
textAlign: TextAlign.left,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
)),
),
),
if (isFav.value == 1)
Padding(
padding:
const EdgeInsets.only(top: 8, bottom: 8.0, left: 10),
child: ButtonTheme(
minWidth: 50,
height: 30.0,
child: RaisedButton.icon(
color: Theme
.of(context)
.primaryColor,
icon: Icon(
Feather.check_circle,
size: 16,
),
onPressed: () =>
touchSub(
counter.value.id.toString(), SubStatus.UNSUB),
label: Text("已订阅"),
)),
),
if (isFav.value != 1)
Padding(
padding:
const EdgeInsets.only(top: 8, bottom: 8.0, right: 1),
child: ButtonTheme(
minWidth: 50,
height: 30.0,
child: RaisedButton(
color: Theme
.of(context)
.primaryColor,
shape: new RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(5.0)),
onPressed: () =>
touchSub(
counter.value.id.toString(), SubStatus.SUB),
child: Text("订阅"),
)),
)
],
),
Row(
children: [
Flexible(
child: Text(counter.value.intro,
softWrap: true,
style: TextStyle(
fontSize: 15,
)),
),
],
)
],
),
),
),
);
事实上,这没什么区别。因此,我尝试将MainAxisAlignment
调整为MainAxisAlignment.start
,但一个新问题是组件从左到右显示,我希望subscribe按钮位于右侧位置。现在我真的不知道我应该做什么才能让它成为我的期望。那么,我应该怎么做才能做到:
配置文件图像在左侧,订阅按钮在右侧,标题在左侧,但在配置文件图像的右侧?这是现在的状态:
标题居中,但我希望标题位于左侧,并跟随配置文件图像。我在flex组件中添加了一个尺寸盒,并扩展了中心组件尺寸:
SizedBox(
width: screenWidth * 0.45,
child: Flexible(
child: Padding(
padding: const EdgeInsets.only(left: 8),
child: Text(counter.value.subName,
softWrap: true,
textAlign: TextAlign.left,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
)),
),
),
),
它可以工作,如下所示:
child: Text(
counter.value.subName,
softWrap: true,
textAlign: TextAlign.left,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
)),