简体   繁体   中英

How to use App bar to toggle custom widget below the app bar in flutter?

So I know that I can give Icons and perform actions when tapped in my app bar but I dont know to toggle the widget just below the app bar.

在此处输入图像描述

I tried Position widget but it didn't work for me.

Would appreciate if Anyone could help me just to toggle the box(dont need help with anything inside the box)

You can use ternary operator to get a function like that.

create a bool like

bool isOpen

and show you widget like

isOpen?YourWidget:null

the above code will check if isOpen is true. If it is true, it'll show YourWidget() . else it'll show nothing.

You can use SetState() to toggle between these.

To know more about ternary operator and how to use it to conditionally show/hide Flutter widgets, take a look at Here

Use preferred size widget at the bottom property off app bar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM