我正在制作一个文本按钮,需要将其放置在页面的右侧。
按钮内容位于右侧,但按钮本身占据了整个页面的宽度。如何使其不占据整个宽度?
这是我的代码:
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包装按钮,但没有起作用