微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

导航到另一个页面时使图像提供者变脏状态

如何解决导航到另一个页面时使图像提供者变脏状态

我正在尝试创建一个操作,该操作按下发送消息按钮并将用户与该特定用户一起发送到聊天页面,但是我无法将数据发送到聊天页面。我收到此错误

The following assertion was thrown building Chat(dirty):
'package:cached_network_image/src/image_provider/_image_provider_io.dart': Failed assertion: line 20 pos 16: 'url != null': is not true

错误指向窗口小部件“聊天”,位于此处的个人资料页面

ProfilePage.dart


messageUser(BuildContext context,{String receiverName,receiverId,receiverAvatar}) {
Navigator.push(context,MaterialPageRoute( builder: (context) => 
 Chat( 
   receiverName: receiverName,receiverId: receiverId,receiverAvatar: receiverAvatar
 ))); }

这是调用上面小部件的onTap函数

onTap: () => 
 messageUser(context,receiverName: user.receiverName,receiverId: user.id,receiverAvatar: user.photoUrl
),),

这是错误指向“聊天”页面上图像获取空值的地方:

Chat.dart

CircleAvatar(
              backgroundColor: Colors.grey,backgroundImage: CachednetworkImageProvider(receiverAvatar),

在这里添加了User模型类,仅供参考,以防万一。

import 'package:cloud_firestore/cloud_firestore.dart';

class User {
  final String id;
  final String profileName;
  final String username;
  final String photoUrl;
  final String url;
  final String email;
  final String bio;
  final Timestamp createdAt;
  final String talkingTo;
  final String receiverName;

  User({
    this.id,this.profileName,this.username,this.photoUrl,this.url,this.email,this.bio,this.createdAt,this.talkingTo,this.receiverName,});

  factory User.fromDocument(DocumentSnapshot doc) {
    if (doc != null) {
      return User(
        id: doc.documentID,email: doc['email'] ?? "",username: doc['username'],photoUrl: doc['photoUrl'],url: doc['photoUrl'],profileName: doc['profileName'],bio: doc['bio'],createdAt: doc['createdAt'],talkingTo: doc['talkingTo'],receiverName: doc['receiverName'],);
    } else {
      return new User();
    }
  }
}

我正在尝试尝试此功能,但不确定将其弄乱的地方或缺少的地方。我检查了无数其他StackOverflow问题,以查看是否可以解决问题,但是仍然有问题。

感谢您的帮助。如果我遗漏了任何有用的信息,请告诉我。谢谢

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。