'_TypeError (type 'newsPostDetails' is not a subtype of type 'newsPostDetails' )
Getting error
"_TypeError (type 'newsPostDetails' is not a subtype of type 'newsPostDetails' where newsPostDetails is from package:iona_central/Screens/Admin/NewsPostDetails.dart newsPostDetails is from package:iona_central/Screens/Admin/newsPostDetails.dart )" when running.
Firebase uploads work completly, but app has an exeption occuring.
_getNewsPostDetails (place where error is occuring is line 3)
_getNewsPostDetails() async {
print("_getPostDetails now running... ");
await DatabaseService()
.getNewsPostDetails(widget.newsPostId)
.then((newsPostId) {
setState(() {
NewsPostDetails = newsPostId;
print("Newspost Details = " + newsPostId);
_isLoading = false;
print("_isLoading now is false!");
});
});
getNewsPostDetails Code (Databaseservices)
Future getNewsPostDetails(String newsPostId) async {
QuerySnapshot snapshot = await FirebaseFirestore.instance
.collection('newsPosts')
.where('newsPostId', isEqualTo: newsPostId)
.get();
final newsPostData = snapshot.docs[0].data()! as Map<String, dynamic>;
newsPostDetails? postDetails = newsPostDetails(
newsPostTitle: newsPostData['newsPostTitle'] as String?,
newsPostContent: newsPostData['newsPostContent'] as String?,
date: newsPostData['date'] as String?,
);
print("getNewsPostDetails Complete");
return postDetails;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
