I would like to create an App Bar like this which has a bottom border as well a tint of shadow which can be done using elevation. Could someone provide a sample code snippet to achieve this
Asked
Active
Viewed 5.7k times
5 Answers
67
Maybe something like this
AppBar(
bottom: PreferredSize(
preferredSize: const Size.fromHeight(4.0)),
child: Container(
color: Colors.orange,
height: 4.0,
),
)

Luca_54
- 529
- 4
- 16

Andrii Turkovskyi
- 27,554
- 16
- 95
- 105
-
2This requires creating a unnecessary container/widget Checkout this response - https://stackoverflow.com/a/67933424/8153955 This is much more cleaner, can directly be added to your app theme as well – Nikhil Bansal Jul 28 '22 at 06:00
48
You can use the AppBar's shape
property to achieve this:
AppBar(
shape: Border(
bottom: BorderSide(
color: Colors.orange,
width: 4
)
),
elevation: 4,
/* ... */
)

tim-montague
- 16,217
- 5
- 62
- 51

shennan
- 10,798
- 5
- 44
- 79
11
Ideally you should make your own appbar if you want a truly customizable design. Example:
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);
}

Rémi Rousselet
- 256,336
- 79
- 519
- 432
1
Now a shadowColor
Property is available in AppBar which you can use easily like this:
AppBar( shadowColor : Colors.blue )

Kishan Somaiya
- 109
- 1
- 11
0
If you just want to use a widget in bottom of the AppBar, This is how I did it:
appBar: AppBar(
title: Text('Soroush!'),
bottom: PreferredSize(
child: Container(
color: Colors.white,
child: TextFormField(),
),
preferredSize: Size.fromHeight(kToolbarHeight)),

Hossein Yousefpour
- 3,827
- 3
- 23
- 35