gpt4 book ai didi

flutter - 类没有实例方法 `call`

转载 作者:IT王子 更新时间:2023-10-29 07:02:16 26 4
gpt4 key购买 nike

我在我的代码中收到以下 NoSuchMethodError:

I/flutter ( 6579): The following NoSuchMethodError was thrown building:
I/flutter ( 6579): Class 'List<DocumentSnapshot>' has no instance method 'call'.
I/flutter ( 6579): Receiver: Instance(length:2) of '_GrowableList'
I/flutter ( 6579): Tried calling: call(0)

这是错误行:

return RepTile(RepData.fromDocument(snapshot.data.documents(index)));

最佳答案

这里的问题是您正在使用圆括号 () 访问您的 List 中的一个元素,它试图调用 在您的对象上调用,但由于您的对象不是函数,因此会引发错误。

但是,List 使用方括号[]access objects at a given index .

这意味着它很容易修复,只需将括号替换为方括号即可:

return RepTile(RepData.fromDocument(snapshot.data.documents[index]));

关于flutter - 类没有实例方法 `call`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57207473/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com