AppBar(
bottom: PreferredSize(
preferredSize: const Size.fromHeight(4.0),
child: Container(
color: Colors.orange,
height: 4.0,
),
)
shape
属性来实现这一点:AppBar(
shape: Border(
bottom: BorderSide(
color: Colors.orange,
width: 4
)
),
elevation: 4,
/* ... */
)
如果您想要一个真正可定制的设计,最好自己创建应用栏。例如:
class MyAppbar extends StatelessWidget implements PreferredSizeWidget {
final Widget title;
const MyAppbar({Key key, this.title}) : super(key: key);
@override
Widget build(BuildContext context) {
return Material(
elevation: 26.0,
color: Colors.white,
child: Container(
padding: const EdgeInsets.all(10.0),
alignment: Alignment.centerLeft,
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: Colors.deepOrange,
width: 3.0,
style: BorderStyle.solid,
),
),
),
child: title,
),
);
}
final Size preferredSize = const Size.fromHeight(kToolbarHeight);
}
shadowColor
的属性,您可以像这样轻松使用它:
AppBar( shadowColor : Colors.blue )
AppBar(elevation: 1, backgroundColor:Colors.orange,)
如果你只想在AppBar底部使用小部件,这是我的方法:
appBar: AppBar(
title: Text('Soroush!'),
bottom: PreferredSize(
child: Container(
color: Colors.white,
child: TextFormField(),
),
preferredSize: Size.fromHeight(kToolbarHeight)),