I updated the cloud firestore yesterday. And, I surprised everything about firestore became wrong. I tried to update my code but I still getting an error with the Future builder. Here is the code and the error. The code was ok before the update.
Future getposts() async{
await Firebase.initializeApp();
var firestore = FirebaseFirestore.instance;
QuerySnapshot qn = await firestore.collection("Restaurants").get();
return qn.docs;}
FutureBuilder(
future: getposts(),
builder: (_,snapshot){
if(snapshot.connectionState == ConnectionState.waiting){
return Center(
child: CircularProgressIndicator(),
);}
else{
return ListView.builder(
itemCount: snapshot.data().length,
itemBuilder: (_,index){
return Center(
child: Text(snapshot.data()[index].data()["name"]),
);
},);
}
},
),
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════ The following NoSuchMethodError was thrown building FutureBuilder(dirty, state: _FutureBuilderState#2c7a5): Class 'List' has no instance method 'call'. Receiver: Instance(length:2) of '_GrowableList' Tried calling: call()
The relevant error-causing widget was: FutureBuilder file:///C:/Users/youse/AndroidStudioProjects/new_app/lib/screens/main_page.dart:226:23 When the exception was thrown, this was the stack: #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5) #1 _MainPageState.build. (package:new_app/screens/main_page.dart:235:55) #2 _FutureBuilderState.build (package:flutter/src/widgets/async.dart:740:55) #3 StatefulElement.build (package:flutter/src/widgets/framework.dart:4663:28) #4 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4546:15) ... ════════════════════════════════════════════════════════════════════════════════════════════════════