[英]How do i make a widget visible only if the collection has docs in flutter?
I'm using firebase database and i want to show a certain widget if there was docs only.我正在使用 firebase 数据库,如果只有文档,我想显示某个小部件。 i tried this line but it's not the right one.我试过这条线,但它不是正确的。
Visibility(
visible: controller.doc.isEmpty(),
Not sure what controller.doc.isEmpty()
does but you want the widget to be visible if the doc is not empty.不确定controller.doc.isEmpty()
做了什么,但如果文档不为空,您希望小部件可见。 So you have to change it to:因此,您必须将其更改为:
Visibility(
visible: !controller.doc.isEmpty(),
)
Try the following code:试试下面的代码:
Visibility(
visible: controller.doc.isNotEmpty(),
),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.