【发布时间】:2021-01-30 10:57:19
【问题描述】:
我正在做一个需要位于页面右侧的 TextButton。
按钮内容在右侧,但按钮本身占据了页面的整个宽度。我怎么能不呢?
这是我的代码:
Padding(
padding: const EdgeInsets.only(bottom: 14.0, right: 7.0),
child: TextButton(
onPressed: onPressed,
style: ButtonStyle(
backgroundColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.pressed))
return Theme.of(context).colorScheme.primary.withOpacity(0.5);
return Colors.red;
},
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(right: 9.5, top: 1.6),
child: Icon(Icons.back_arrow, color: Colors.blue),
),
Text( "Home",
style: Theme.of(context)
.textTheme
.bodyText2
.merge(TextStyle(color: Colors.blue)
)
),
]),
),
);
我尝试将按钮包装在 Align 中,但没有成功
【问题讨论】:
标签: flutter flutter-layout flutter-web