Skip to content

Inline conditional rendering in list #28181

@tzvc

Description

@tzvc

Hi everyone,

I have a list of widget (Column widget) and I would like to render one of them only on condition.
I tried achieving that using a ternary operator but flutter complains about rendering a null widget.

    return Column(children: <Widget>[
      Text("hello"),
      condition ? Text("should not render if false") : null,
      Text("world")
    ],);

My question is therefore, is there a way to do inline conditional rendering in Flutter like it is possible to do in React using the logical && operator ?

Thanks :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions