我创建了一个聊天应用程序,一切正常,除了两件事
1- 在火力基地商店中,即使我什么都不做,我也得到了太多的阅读,例如,我只使用了我的聊天应用程序 5 分钟,我得到了大约 6000 次阅读
2-当我与任何人聊天时,有些消息没有收到,这是一个例子
另一个人(威廉)没有收到三条消息(是的,k,现在)。
///////////
这是显示消息的流构建器代码
class Streambuild extends StatelessWidget {
final String roomid;
Streambuild({@required this.roomid});
@override
Widget build(BuildContext context) {
return StreamBuilder<QuerySnapshot>(
stream: _store
.collection('FCHATROOM')
.doc(roomid)
.collection("CHAT")
.orderBy('time', descending: true)
.snapshots(),
builder: (context, snap) {
if (!snap.hasData) {
return Center(
child: Text('No Messages'),
);
}
return Expanded(
child: ListView.builder(
itemCount: snap.data.docs.length,
reverse: true,
shrinkWrap: true,
itemBuilder: (context, index) {
return Bubblemsg(
txt: snap.data.docs[index].data()['message'],
sender: snap.data.docs[index].data()['sender'],
realtime: snap.data.docs[index].data()['realtime'],
isMe: (snap.data.docs[index].data()['sender'] ==
_auth.currentUser.email),
);
}),
);
});
}
}
气泡消息代码:
class Bubblemsg extends StatelessWidget {
Bubblemsg({this.sender, this.txt, this.isMe, this.realtime});
final String txt;
final String sender;
final bool isMe;
final String realtime;
@override
Widget build(BuildContext context) {
var myprov = Provider.of<Help>(context, listen: false);
return Container(
width: double.infinity,
child: Bubble(
elevation: 5,
padding: BubbleEdges.all(10),
margin: isMe
? BubbleEdges.only(top: 10, right: 5, left: 30)
: BubbleEdges.only(top: 10, left: 5, right: 30),
alignment: isMe ? Alignment.topRight : Alignment.topLeft,
nip: isMe ? BubbleNip.rightTop : BubbleNip.leftTop,
color: isMe ? myprov.mid : Colors.grey[900],
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
txt != null
? txt.startsWith("https://firebasestorage.googleapis.com/v0")
? Imagecontainer(
url: txt,
)
: SelectableText(
txt != null ? txt : "",
style: TextStyle(
color: myprov.word,
fontSize: 20,
),
)
: Text(""),
Padding(
padding: EdgeInsets.only(top: 10.0),
child: Text(
realtime != null ? realtime : "",
style: TextStyle(fontSize: 15, color: myprov.word),
textAlign: TextAlign.end,
),
)
],
),
),
);
}
}