Closure call with mismatched arguments: function '[]' in flutter

前端 未结 3 857
甜味超标
甜味超标 2021-01-25 12:12

** I am getting this error**

Closure call with mismatched arguments: function \'[]\'
Receiver: Closure: (dynamic) => dynamic from Function \'get\':.
Tried call         


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-25 12:57

    The answer by @Peter Haddad is correct. Just to highlight the difference with an example from my own code:

    The previous version of code which created the same error:

    snapshot.data.docs[index].data["chatRoomID"]
    

    Updated version of code which solved the error:

    snapshot.data.docs[index].data()["chatRoomID"]
    

提交回复
热议问题