I wanted to ask, because I get a lot of errors, if it is possible to place a Divider()
widget like this:
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.
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.
bottom: const PreferredSize(
preferredSize: Size.fromHeight(1),
child: Divider(height: 1),
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.