Pumuckelo
Pumuckelo

Reputation: 379

Unhandled Exception: type '_TypeError' is not a subtype of type 'String'

I am getting this error on my flutter app.

Unhandled Exception: type '_TypeError' is not a subtype of type 'String'

List<Cars> cars = docs.map((e){
    return Car(name: e.data["name"])
});

Upvotes: 0

Views: 1266

Answers (1)

Pumuckelo
Pumuckelo

Reputation: 379

The answer is: You need to use .toList() on the map function

List<Cars> cars = docs.map((e){
    return Car(name: e.data["name"])
}).toList();

Hope this helps someone who receives the same weird error

Upvotes: 2

Related Questions