【发布时间】:2020-07-25 09:57:40
【问题描述】:
我是新来的颤振。我正在尝试在“AppBar”中插入一个带有文本的简单“包含按钮”。 (例如材料设计“包含按钮”here)
问题是,无论我在构造函数中插入什么高度,按钮仍然会填满 AppBar 的整个高度。
我可以像在下面的示例中那样通过设置填充明显地解决问题,但让我感到沮丧的是,我不明白为什么我不能更改按钮本身的高度。 我还尝试用容器或 sizedBox 包装它,如答案here 中所示,但它没有做出任何可见的变化(按钮仍然填充了整个 appBar 的高度)
如果有人能向我解释为什么代码会这样,我将不胜感激。
appBar: AppBar(
automaticallyImplyLeading: false,
title: Text(widget.title),
actions: <Widget>[
Padding(
padding: EdgeInsets.only(top: 7.0, bottom: 7),
child: Container(
width: 80,
child: FlatButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.0),
),
color: Color.fromRGBO(58, 90, 128, 1),
onPressed: () {},
child: Text('Button')
),
)
),
]
)
【问题讨论】:
标签: flutter button dart resize materialbutton