我希望你一切安好。我还有另一个关于 flutter 的问题。我正在尝试从评论对象(下面的代码)加载此个人资料图片。我尝试重命名并重新加载Firebase存储和所有内容。我尝试添加异步,但无济于事。如果您想查看我正在关注的教程,请在下面提供一个链接。我非常感谢您的帮助!
教程链接:https://www.udemy.com/course/ios-android-masterclass-build-3-apps-with-google-flutter/
集数:113
我的屏幕图片:
list_widgets-> _ReviewListTileState-> initState()
@override
void initState() {
this._review = widget.review;
this._review.contact.getContactInfoFromFirestore().whenComplete(() {
setState(() {
print("Dot Dots");
});
});
super.initState();
}
list_widgets-> _ReviewListTileState-> build()InkResponse(
onTap: (){
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => view_profile_page(contact: _review.contact),
),
);
},
child: Container(
child: (_review.contact.displayImage == null) ? Container(
width: MediaQuery.of(context).size.width / 7.5,
child: Text("${_review.contact.firstName} was here"),
) : CircleAvatar(
backgroundImage: _review.contact.displayImage,
radius: MediaQuery.of(context).size.width / 15,
),
),
),
review_objects->评论{}import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutterrentalapp/Models/user_objects.dart';
class Review{
Contact contact;
String text;
double rating;
DateTime dateTime;
Review();
void createReview(Contact contact, String text, double rating, DateTime dateTime){
this.contact = contact;
this.text = text;
this.rating = rating;
this.dateTime = dateTime;
}
void getReviewInfoFromFirestore(DocumentSnapshot snapshot){
this.rating = snapshot['rating'].toDouble() ?? 2.5;
this.text = snapshot['text'] ?? "";
Timestamp timestamp = snapshot['dateTime'] ?? Timestamp.now();
this.dateTime = timestamp.toDate();
String fullName = snapshot['name'] ?? "";
String contactID = snapshot['userID'] ?? "";
_loadContactInfo(contactID,fullName);
}
void _loadContactInfo(String id, String fullName){
String firstName = "";
String lastName = "";
firstName = fullName.split(" ")[0];
lastName = fullName.split(" ")[1];
this.contact = Contact(id: id, firstName: firstName, lastName:lastName);
}
}
最佳答案
这些问题中的另一个问题是经典程序员输入错误的内容。我必须返回其中一个类中的代码,并进行一些更改。尽管我找不到它了。
谢谢大家的有用建议。
关于ios - Flutter-无法从Firebase加载此个人资料图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62660968/