I have wrapped BottomAppBar with PreffredSize widget to set its height based on requirnment but its not giving the height which is applied by Size.fromHeight(20)
so how to solve?
bottomNavigationBar: const PreferredSize(
preferredSize: Size.fromHeight(20),
child: BottomAppBar(
padding: EdgeInsets.zero,
elevation: 0,
color: Colors.blue,
child: Row(children: [
Expanded(child: Text('Add to cart')),
Expanded(child: Text('Buy Now'))
],)
),
),
2
Answers
I think no need to use
PreferredSize
Widget just wrap yourBottomAppBar
insideSizedBox
and provide your expected height.Refer below code.
Result Image
Just wrap it with a
SizedBox
widget. Also its not mandatory that aBottomAppBar
needs to be passed to that widget, it can be any widget which has a custom widget