Home > Back-end >  How do i make a widget visible only if the collection has docs in flutter?
How do i make a widget visible only if the collection has docs in flutter?

Time:09-15

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(),

CodePudding user response:

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(),
)

CodePudding user response:

Try the following code:

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