How do i make a widget visible only if the collection has docs in flutter?

Viewed 23

I'm using firebase database and i want to show a certain widget if there was docs only. i tried this line but it's not the right one.

Visibility(
                  visible: controller.doc.isEmpty(),
2 Answers

Not sure what controller.doc.isEmpty() does but you want the widget to be visible if the doc is not empty. So you have to change it to:

Visibility(
  visible: !controller.doc.isEmpty(),
)

Try the code:

Visibility(
  visible: controller.doc.isNotEmpty(),
),
Related