当Runnig交易过程中互联网断开连接时,Flutter应用程序崩溃

时间:2018-10-17 15:09:42

标签: firebase dart flutter google-cloud-firestore

我曾问过类似的问题Here。新的问题是,在查找互联网地址(打印“ connected”)之后,但是在运行事务时,如果网络断开或网络断开非常慢,我收到超时错误异常,导致应用崩溃。

try {
   final result = await InternetAddress.lookup('google.com');
   if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
       print('connected');
        Firestore.instance.runTransaction((transactionshere)async{
          DocumentReference reference =
            Firestore.instance.collection('One').document('two').collection('three').document('all_').collection('cur').document();
            await reference.setData(dataToSend,merge: true);

        });

   }
 } on SocketException catch (_) {
    print('not connected');
     _scafoldKey.currentState.showSnackBar(
    SnackBar(content: Text("There was a problem check your connection"),duration: Duration(seconds: 4),),
     );
 }

error output: I/flutter (24149): connected W/Firestore(24149): (0.6.6-dev) [Firestore]: The behavior for java.util.Date objects stored in Firestore is going to change AND YOUR APP MAY BREAK. W/Firestore(24149): To hide this warning and ensure your app does not break, you need to add the following code to your app before calling any other Cloud Firestore methods: W/Firestore(24149): W/Firestore(24149): FirebaseFirestore firestore = FirebaseFirestore.getInstance(); W/Firestore(24149): FirebaseFirestoreSettings settings = new FirebaseFirestoreSettings.Builder() W/Firestore(24149): .setTimestampsInSnapshotsEnabled(true) W/Firestore(24149): .build(); W/Firestore(24149): firestore.setFirestoreSettings(settings); W/Firestore(24149): W/Firestore(24149): With this change, timestamps stored in Cloud Firestore will be read back as com.google.firebase.Timestamp objects instead of as system java.util.Date objects. So you will also need to update code expecting a java.util.Date to instead expect a Timestamp. For example: W/Firestore(24149): W/Firestore(24149): // Old: W/Firestore(24149): java.util.Date date = snapshot.getDate("created_at"); W/Firestore(24149): // New: W/Firestore(24149): Timestamp timestamp = snapshot.getTimestamp("created_at"); W/Firestore(24149): java.util.Date date = timestamp.toDate(); W/Firestore(24149): W/Firestore(24149): Please audit all existing usages of java.util.Date when you enable the new behavior. In a future release, the behavior will be changed to the new behavior, so if you do not follow these steps, YOUR APP MAY BREAK. I/zygote (24149): The ClassLoaderContext is a special shared library. I/zygote (24149): The ClassLoaderContext is a special shared library. V/NativeCrypto(24149): Registering com/google/android/gms/org/conscrypt/NativeCrypto's 287 native methods... D/NetworkSecurityConfig(24149): No Network Security Config specified, using platform default I/ProviderInstaller(24149): Installed default security provider GmsCore_OpenSSL W/System (24149): ClassLoader referenced unknown path: system/framework/mediatek-cta.jar I/System.out(24149): e:java.lang.ClassNotFoundException: com.mediatek.cta.CtaHttp W/System (24149): ClassLoader referenced unknown path: system/framework/mediatek-cta.jar I/System.out(24149): e:java.lang.ClassNotFoundException: com.mediatek.cta.CtaHttp W/System (24149): ClassLoader referenced unknown path: system/framework/mediatek-cta.jar I/System.out(24149): e:java.lang.ClassNotFoundException: com.mediatek.cta.CtaHttp W/System (24149): ClassLoader referenced unknown path: system/framework/mediatek-cta.jar

0 个答案:

没有答案