【发布时间】:2020-08-10 22:08:06
【问题描述】:
我需要将小部件的中心与应用栏底部边缘对齐。 因此它将垂直一半位于应用栏上,一半位于页面正文上。
现在我已将小部件添加到 AppBar 底部:但它不会与其水平中心线对齐。
目前看起来是这样的:
虽然我希望 SelectEnvironment 按钮的 center 以及水平白线将“正好”位于 appBar 的底部边缘
appBar的代码是这样的:
class CustomAppBar extends AppBar {
final Widget appBarActionButton;
CustomAppBar({Widget title = AppUtils.EMPTY_TEXT_VIEW, this.appBarActionButton}): super(
title: title,
backgroundColor: Colors.blueGrey,
elevation: 0,
bottom: PreferredSize(
child: Stack( //The stack holds the horizontal line and the button aligned cente
alignment: Alignment.center,
children: <Widget>[
Container( //This is the horizontal line
color: Colors.GeneralDividerGray,
height: 1.0,
),
Align(
child: Container(
child: appBarActionButton, //This is the button widget
),
)
],
),
preferredSize: Size.fromHeight(4.0)),
);
}
如果有更好的方法可以通过将其移出应用栏来实现这一点,我可以,只要它会产生相同的效果。
【问题讨论】:
-
你试过
centerTitle: true