I have a little issue with a snapshot and a ListView. So far it was working very well. But since I have updated flutter and Dart, I am getting an error.
The following StateError was thrown building StreamBuilder<QuerySnapshot<Object?>>(dirty, state: _StreamBuilderBaseState<QuerySnapshot<Object?>, AsyncSnapshot<QuerySnapshot<Object?>>>#8b4ae): Bad state: field does not exist within the DocumentSnapshotPlatform
I do not understand how to fix the problem. I have checked the name of the fields in the document and it is fine. Please, can you help me to understand this? It would be appreciated. Thank you
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
class ProjectsList3 extends StatefulWidget {
ProjectsList3 ({Key key}) : super(key : key);
@override
_ProjectsList3State createState() => _ProjectsList3State();
}
class _ProjectsList3State extends State<ProjectsList3> {
@override
Widget build(BuildContext context) {
return Scaffold(
drawer: new MyMenu(),
appBar: new AppBar(
title: new Text('Projects'),
),
body: Column(
children: [
Expanded(
child: StreamBuilder<QuerySnapshot>(
stream: FirebaseFirestore.instance
.collection('Users')
.doc(FirebaseAuth.instance.currentUser.uid)
.collection('projects')
.snapshots(),
builder: (BuildContext context,
AsyncSnapshot<QuerySnapshot> snapshot) {
if(snapshot.connectionState == ConnectionState.waiting){
return Center(child: LinearProgressIndicator());
}
else{
return new ListView(
children: snapshot.data.docs.map((prgSnapshot){
return Card(
child: ListTile(
leading: CircleAvatar(
),
title: Text(prgSnapshot['project_Name']),
)
) ;
}).toList(),
);
//if (!snapshot.hasData) {
// return Center(
// child: CircularProgressIndicator(),
// );
}
}
),
),
],
),
bottomNavigationBar: MyBottomAppBar(),
);
throw UnimplementedError();
}
}