如何在Flatter中设置Firebase连接的侦听器?

如何在Flatter中设置Firebase连接的侦听器?,firebase,flutter,google-cloud-firestore,Firebase,Flutter,Google Cloud Firestore,所以我试图捕捉一个“无网络”错误 我正在Firestore中收听这样的文档: final docRef = FirebaseFirestore.instance.collection(kInfoCollection).doc(kInfoDocument); docSubscription = docRef.snapshots().distinct().listen((_) {}); docSubscription.onData((snapshot) => _processInfo(sn

所以我试图捕捉一个“无网络”错误

我正在Firestore中收听这样的文档:

final docRef = FirebaseFirestore.instance.collection(kInfoCollection).doc(kInfoDocument);

docSubscription = docRef.snapshots().distinct().listen((_) {});

docSubscription.onData((snapshot) => _processInfo(snapshot))

docSubscription.onError((e, s) {
        final errorMessage = 'Message:\n$e \nThe Stack was:\n$s';
        print('Error $errorMessage');
        throw InfoException(errorMessage);
      });

如您所见,侦听器正在侦听文档,如果捕获到任何错误,将抛出一个错误

但未捕获控制台中显示的这些Firebase错误:

Connection 1: encountered error(1:53)
6.26.0 - [Firebase/Firestore][I-FST000001] WatchStream (283fb4118) Stream error: 'Unavailable: Network connectivity changed'
6.26.0 - [Firebase/Firestore][I-FST000001] WatchStream (283fb4118) Stream error: 'Unavailable: DNS resolution failed'
6.26.0 - [Firebase/Firestore][I-FST000001] WatchStream (283fb4118) Stream error: 'Unavailable: DNS resolution failed'
6.26.0 - [Firebase/Firestore][I-FST000001] WatchStream (283fb4118) Stream error: 'Unavailable: failed to connect to all addresses'
我错过什么了吗


附加信息:我在手机上模拟飞行模式。否则不会出现错误。

关于此问题,您可能会发现以下有趣的问题:

这似乎是一种正常的行为,以避免仅仅因为暂时没有连接而中断应用程序


我希望这将对您有所帮助,即使这个问题已经7个月了。

我也遇到了同样的问题,您找到了解决方案吗?感谢您的支持,很遗憾,我还没有找到解决方案。希望很快会有人来。为什么我们得到了8张选票,而Firebase还没有人回答?