skip to Main Content

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


  1. I think no need to use PreferredSize Widget just wrap your BottomAppBar inside SizedBox and provide your expected height.

    Refer below code.

    bottomNavigationBar: const SizedBox(
              height: 200,
              child: BottomAppBar(
                padding: EdgeInsets.zero,
                elevation: 0,
                color: Colors.blue,
                child: Row(
                  children: [
                    Expanded(child: Text('Add to cart')),
                    Expanded(child: Text('Buy Now'))
                  ],
                ),
              ),
            ),
    

    Result Image

    Login or Signup to reply.
  2. Just wrap it with a SizedBox widget. Also its not mandatory that a BottomAppBar needs to be passed to that widget, it can be any widget which has a custom widget

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search