Search code examples
flutterdartwidgetflutter-widget

How to return two widgets in an if - flutter


I want to return two widgets when one condition is true. Something like this:

Row(
  children: [
   ...
   if (session.server.autoVenta)
    SizedBox(
     width: size.width * 0.16,
     child: const TextPrimary(
      text: "N° Doc:",
     ),
    ),
   if (session.server.autoVenta)
     SizedBox(
      width: size.width * 0.24,
      child: Text(order.documento),
     ),
  ]
)

But using only one if.

I've searched on google but I couldn't find anything.


Solution

  • Like

    Row(
      children: [
        if (true) ...[
          Widget(),
          Widget(),
        ],
        Widget(),
      ],
    )