Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.6k views
in Technique[技术] by (71.8m points)

flutter - Firebase Firestore Error: The operator '[]' isn't defined for the class 'Object'

im learning how to connect flutter app to firebase from this video

https://youtu.be/ggYTQn4WVuw

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...