小编Edu*_*chi的帖子

我如何知道 Firestore 上的交易是否成功?

有没有什么方法可以知道交易是否成功?如果我上传大型档案并花费太多时间,我需要实现加载“小部件动画”。然后成功后换屏幕,但我不知道如何。

谢谢!

交易示例:

CollectionReference reference = Firestore.instance.collection("collection_example");

Firestore.instance.runTransaction((Transaction transaction) async {

await transaction.set(reference, {
  "index_1":"ABC",
  "index_2": 2,
  "index_3": {"mapIndex_1": "ABC"}
});

});
Run Code Online (Sandbox Code Playgroud)

transactions dart flutter google-cloud-firestore

8
推荐指数
1
解决办法
2105
查看次数

为什么在Firebase Cloud Functions中收到“无效信封”错误?

有时,可调用CloudFunctions cloud_functions 0.0.5的响应 引发CloudFunctionGenericException “无效信封”消息。

这似乎是没有特定原因的,并且没有任何内容记录到Firebase Cloud Function Logs。

这种情况很少发生(大约每10次出现一次),但会破坏应用程序的逻辑。

为什么会发生这种情况以及如何解决?

firebase flutter google-cloud-functions

7
推荐指数
1
解决办法
163
查看次数

如何在颤动中裁剪图像?

我寻找这个问题的日子.

我想像这样裁剪图像,在颤动:

在此输入图像描述

GIF资料来源:https://github.com/ArthurHub/Android-Image-Cropper

这个解决方案最接近的lib是Image Lib,lib提供了操作图像和裁剪,但我想在UI级别裁剪图像,就像这个gif一样.我发现的所有lib都不提供.

image flutter

4
推荐指数
2
解决办法
2128
查看次数

Firebase规则:如何阻止匿名访问?

阅读Firebase规则文档对于如何阻止匿名访问特定集合或文档我一无所获。

换句话说,我要阻止未登录的用户,并且我也要阻止以匿名身份登录的用户。我只允许用户以自己的身份登录(通过电子邮件,Facebook,Google,SMS等)。

我怎样才能做到这一点?

这是我想出的代码,不起作用:

    service cloud.firestore {
      match /databases/{database}/documents {
        }
        match /collectionExample/{documentExample} {
          allow create: if request.auth.uid != null && request.auth.token.isAnonymous != false;              
          allow read: if request.auth.uid == resource.data.userId;
        }
      }
    } 
Run Code Online (Sandbox Code Playgroud)

firebase google-cloud-firestore firebase-security-rules

3
推荐指数
1
解决办法
421
查看次数

如何使用arrayUnion更新地图中的数组?

在 Firestore 中,我有一个包含名为 的地图的文档myMap,其中包含一个名为 的数组字段myArr

是否可以通过在事务中向其添加元素来arrayUnion用于更新myArr

await admin.firestore().runTransaction(async (transaction: Transaction) => {
    //

    const docRef: DocumentReference = admin.firestore()
        .doc(`collection/document`);

    const doc: DocumentSnapshot = await transaction.get(docRef);

    if (doc.exists) 
        await transaction.update(docRef,
            {'myMap': {'myArr': FieldValue.arrayUnion('myNewValue')},}
        );

});
Run Code Online (Sandbox Code Playgroud)

我相信上面的代码应该添加myArr,但它代替了整个数组。

我究竟做错了什么?

firebase typescript google-cloud-firestore

3
推荐指数
1
解决办法
960
查看次数

有没有一种使用Firestorage的方法,可以在没有Streambuilder / widget的情况下将集合转换为地图列表?

有没有一种使用Firestorage的方法,可以在没有Streambuilder / widget的情况下将集合转换为地图列表?

示例:我有一个包含文档的“ exampleData”集合。我需要使用集合的数据从中创建“地图列表”。数据示例:

List<Map> exampleData = [map1,map2,map3]
Run Code Online (Sandbox Code Playgroud)

该列表中的元素具有如下数据:

map1 = {
"active":"true"
"age" = "2"
"editing" = "false"
"photo_url" = "https://test.com"
"score: 0"
}
Run Code Online (Sandbox Code Playgroud)

dart flutter google-cloud-firestore

2
推荐指数
1
解决办法
307
查看次数