Kes*_*R.P 4 appbar dart flutter
我想创建一个像这样的应用栏,它具有底部边框以及可以使用高程完成的阴影色调。有人可以提供示例代码片段来实现这一目标
she*_*nan 57
您可以使用 AppBar 的shape
属性来实现此目的:
AppBar(
shape: Border(
bottom: BorderSide(
color: Colors.orange,
width: 4
)
),
elevation: 4,
/* ... */
)
Run Code Online (Sandbox Code Playgroud)
Rém*_*let 10
理想情况下,如果您想要真正可定制的设计,您应该制作自己的应用栏。例子:
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);
}
Run Code Online (Sandbox Code Playgroud)
也许像这样
AppBar(bottom: PreferredSize(child: Container(color: Colors.orange, height: 4.0,), preferredSize: Size.fromHeight(4.0)),)
Run Code Online (Sandbox Code Playgroud)