【问题标题】:Flutter - Having trouble loading this profile image from FirebaseFlutter - 从 Firebase 加载此个人资料图片时遇到问题
【发布时间】: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


【解决方案1】:

经典程序员打错字的另一个问题。我不得不重新检查其中一个类中的代码并稍作更改。不过距离太远了,我找不到了。

感谢大家的有用建议。

【讨论】:

    猜你喜欢
    • 2017-11-16
    • 1970-01-01
    • 2020-11-02
    • 2012-02-25
    • 2019-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多