【问题标题】:Flutter Firestore Operator isn't definedFlutter Firestore Operator 未定义
【发布时间】:2021-09-13 12:38:59
【问题描述】:

您好,我遇到了这个错误

错误:没有为“对象”类型定义运算符“[]”。 ([mbpayment] lib\screens\transactionhistory\transaction_history.dart:61 处的 undefined_operator)

这是代码

StreamBuilder(
            stream: FirebaseFirestore.instance.collection('transactionHistory').where('SenderEmail', isEqualTo: user.email).snapshots(),
            builder: (context, AsyncSnapshot<QuerySnapshot> snapshot) {
            return Container(
              child: ListView.builder(
                itemCount: snapshot.hasData?snapshot.data!.docs.length:0,
                itemBuilder: (context, index) {
                  return Card(
                    child: ListTile(
                      title: Text('To: ' + snapshot.data!.docs[index].data()!['RecipientEmail'].toString()),
                      subtitle: Text('Details: ' + snapshot.data!.docs[index].data()!['RecipientReference'].toString()),
                      leading: CircleAvatar(
                        backgroundColor: Colors.white,
                        child: Icon(
                          Icons.remove,
                          color: Colors.red,
                        ),
                      ),
                      trailing: Text('RM ' + snapshot.data!.docs[index].data()!['amount'].toString(), style: TextStyle(
                          color: Colors.red
                      ),
                      ),
                    ),
                  );
                },
              ),
            );
          }
        ),

我正在尝试为交易历史创建一个列表视图。

【问题讨论】:

标签: flutter google-cloud-firestore


【解决方案1】:

我认为您的问题源于 cloud_firestore 的 2.0.0 更改。检查this。如果是这样,您必须在需要的地方添加 Map&lt;String, dynamic&gt;&gt; 泛型参数。

【讨论】:

    猜你喜欢
    • 2021-09-10
    • 1970-01-01
    • 1970-01-01
    • 2020-09-06
    • 2022-10-07
    • 2016-10-03
    • 2011-04-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多