Hey I am trying to get data of my firestore database to display it in a chart. There are some similar Questions on this topic but they couldnt solve my problem. Following the error causing widget:
Widget _buildBody(context) {
return StreamBuilder<QuerySnapshot>(
stream: FirebaseFirestore.instance.collection('TopTen').snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return LinearProgressIndicator();
} else {
List<Klicks> klicks = snapshot.data.docs
.map(
(documentSnapshot) => Klicks.fromMap(documentSnapshot.data()))
.toList();
return _buildChart(context, klicks);
}
}
);
}
After running my App the LinearProcessIndicator is shown quickly and then the errorpage gets displayed with the following message:
Failed assertion: boolean expression must not be null
The relevant error-causing widget was
StreamBuilder<QuerySnapshot>
If I dont quit the App the errormessage gets build all the time.
I've set up the firestore collection called 'TopTen'. As requested this is the 'Klicks' class
class Klicks{
final int gesamtKlicks;
final String name;
Klicks(this.gesamtKlicks,this.name);
Klicks.fromMap(Map<String,dynamic> map)
:assert(map['gesamtKlicks']=!null),
assert(map['name']=!null),
gesamtKlicks=map['gesamtKlicks'],
name=map['name'];
@override
String toString() => "Record <$gesamtKlicks:$name>";
}
And finally the database:
thanks in advance!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…