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

Time:02-01

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?

enter image description here

CodePudding user response:

use your custom widget like this:

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

CodePudding user response:

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

customWidget ?? Container()

CodePudding user response:

you can use the if condition like below.

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