简体   繁体   中英

How to show widget sent from another page based on a condition in flutter

I have a page that I use in common. I'm posting a "widget" named "custom widget" on this page. If "custom widget" is sent I want to show it. If it's not sent, don't do anything. How can I achieve this?

在此处输入图像描述

use your custom widget like this:

customWidget != null ? Row(children: [customWidget!]) : Container()

Check if the customWidget is null and show it if it's not.

customWidget ?? Container()

you can use the if condition like below.

Row(
  children: [
    if (customWidget != null) customWidget,
  ],
),

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