[英]Flutter - AppBar Bottom widget
I wanted to ask, because I get a lot of errors, if it is possible to place a Divider()
widget like this:我想问一下,因为我遇到了很多错误,是否可以像这样放置一个Divider()
小部件:
AppBar(
bottom: Divider()
)
And if yes, could anyone show me how it's possible to do that如果是的话,谁能告诉我如何做到这一点
If you read the bottom
documentation, it must implement PreferredSizeWidget
and Divider
does not implement it.如果您阅读bottom
文档,它必须实现PreferredSizeWidget
而Divider
没有实现它。
But you can create your own version and use it there.但是您可以创建自己的版本并在那里使用它。
class MyDivider extends Divider implements PreferredSizeWidget {
MyDivider({
Key key,
height = 16.0,
indent = 0.0,
color,
}) : assert(height >= 0.0),
super(
key: key,
height: height,
indent: indent,
color: color,
) {
preferredSize = Size(double.infinity, height);
}
@override
Size preferredSize;
}
try this...尝试这个...
bottom: PreferredSize(
child: Container(
color: Colors.orange,
height: 4.0,
),
preferredSize: Size.fromHeight(4.0)),
Yes, you can add Divider()
to AppBar bottom.是的,您可以将Divider()
添加到 AppBar 底部。
bottom: const PreferredSize(
preferredSize: Size.fromHeight(1),
child: Divider(height: 1),
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.