Class has no instance method `call`

12,018

The issue here is that your are using parentheses () to access an element in your List, which tries to invoke call on your object, but since your object is not a function, this throws an error.

However, List uses square brackets [] to access objects at a given index.

This means that it is an easy fix, just replace your parentheses by square brackets:

return RepTile(RepData.fromDocument(snapshot.data.documents[index]));
Share:
12,018

Related videos on Youtube

Ítalo Maciel
Author by

Ítalo Maciel

Updated on June 04, 2022

Comments

  • Ítalo Maciel
    Ítalo Maciel almost 2 years

    I receive the following NoSuchMethodError in my code:

    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)
    

    This is the error line:

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