This is the widget tree returns this error
'Future' is not a subtype of type 'String' The relevant error-causing widget was SavedTab
Widget build(BuildContext context) {
return Container(
child: Stack(
children: [
FutureBuilder<QuerySnapshot>(
future: productsRef
.document(_firebaseServices.getUserId())
.collection("Saved")
.getDocuments(),
builder: (context, snapshot) {
if (snapshot.hasError) {
return Scaffold(
body: Center(
child: Text("Error: ${snapshot.error}"),
),
);
}
// Collection Data ready to display
if (snapshot.connectionState == ConnectionState.done) {
// Display the data inside a list view
return ListView(
padding: EdgeInsets.only(
top: 108.0,
bottom: 12.0,
),
children: snapshot.data.documents.map((document) {
return GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ProductPage(
productId: document.documentID,
),
));
},
child: FutureBuilder(
future: _firebaseServices.productsRef
.document(document.documentID)
.get(),
builder: (context, productSnap) {
if (productSnap.hasError) {
return Container(
child: Center(
child: Text("${productSnap.error}"),
),
);
}
if (productSnap.connectionState ==
ConnectionState.done) {
Map _productMap = productSnap.data.data();
}
},
),
);
}).toList(),
);
}
// Loading State
return Scaffold(
body: Center(
child: CircularProgressIndicator(),
),
);
},
),
CustomActionBar(
title: "Saved",
hasBackArrrow: false,
),
],
),
);
}
}
Read more here: https://stackoverflow.com/questions/65078496/how-do-i-fix-this-type-futuredynamic-is-not-a-subtype-of-type-string-the-r
Content Attribution
This content was originally published by Clinton Sang at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.