im learning how to connect flutter app to firebase from this video
For me everything is exactly the same, but in Android Studio there is an error.
error: The operator '[]' isn't defined for the type 'Object'. (undefined_operator at [firebase_test] libservicesdatabase.dart:24)
Code where is error:
List<Brew> _brewListFromSnapshot(QuerySnapshot snapshot) {
return snapshot.docs.map((doc) {
return Brew(
name: doc.data()['name'] ?? '',
strength: doc.data()['strength'] ?? 0,
sugars: doc.data()['sugars'] ?? '0',
);
}).toList();}
Brew Class:
class Brew {
final String name;
final String sugars;
final int strength;
Brew({ this.name, this.sugars, this.strength });
}
Can someone help me fix this? Is this a problem with Android Studio?
See Question&Answers more detail:os