【发布时间】:2020-10-20 23:09:05
【问题描述】:
我希望你一切都好。我有另一个关于颤振的问题。我正在尝试从评论对象中加载此个人资料图片(代码如下)。我尝试重命名和重新加载 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);
}
}
【问题讨论】:
-
您的个人资料图片是否已加载到 Firebase 存储?您是否能够在存储桶上看到这一点并验证该图像是否存在且未损坏? console.cloud.google.com/storage/browser您是否在应用调试控制台上收到任何错误消息?
-
是的先生,我可以在存储桶和所有内容中查看它。打开我的 VPN,因为我无法从应用程序的任何方面或驱动器上查看任何图片。我多次替换图像,甚至尝试重命名图像。
标签: ios firebase flutter dart google-cloud-firestore