fix scroll to bottom button
This commit is contained in:
@@ -309,19 +309,8 @@ class _MessageListViewState extends State<MessageListView> {
|
||||
return messageWidget;
|
||||
},
|
||||
),
|
||||
if (streamChannel.channel.state.members.contains((Member e) =>
|
||||
e.userId == streamChannel.channel.client.state.user.id) &&
|
||||
widget.showScrollToBottom)
|
||||
StreamBuilder<int>(
|
||||
stream: streamChannel.channel.state.unreadCountStream,
|
||||
builder: (context, snapshot) {
|
||||
if (!_showScrollToBottom ||
|
||||
!snapshot.hasData ||
|
||||
snapshot.data == 0) {
|
||||
return SizedBox();
|
||||
}
|
||||
return _buildScrollToBottom(snapshot.data);
|
||||
}),
|
||||
if (widget.showScrollToBottom && _showScrollToBottom)
|
||||
_buildScrollToBottom(),
|
||||
Positioned(
|
||||
top: 20.0,
|
||||
child: ValueListenableBuilder<Iterable<ItemPosition>>(
|
||||
@@ -364,7 +353,8 @@ class _MessageListViewState extends State<MessageListView> {
|
||||
position.itemLeadingEdge > max.itemLeadingEdge ? position : max);
|
||||
}
|
||||
|
||||
Widget _buildScrollToBottom(int unreadCount) {
|
||||
Widget _buildScrollToBottom() {
|
||||
final streamChannel = StreamChannel.of(context);
|
||||
return Positioned(
|
||||
bottom: 8,
|
||||
right: 8,
|
||||
@@ -389,24 +379,34 @@ class _MessageListViewState extends State<MessageListView> {
|
||||
);
|
||||
},
|
||||
),
|
||||
Positioned(
|
||||
width: 20,
|
||||
height: 20,
|
||||
left: 10,
|
||||
top: -10,
|
||||
child: CircleAvatar(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(3.0),
|
||||
child: Text(
|
||||
unreadCount.toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (streamChannel.channel.state.members.any((Member e) =>
|
||||
e.userId == streamChannel.channel.client.state.user.id))
|
||||
StreamBuilder<int>(
|
||||
stream: streamChannel.channel.state.unreadCountStream,
|
||||
initialData: streamChannel.channel.state.unreadCount,
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData || snapshot.data <= 0) {
|
||||
return Offstage();
|
||||
}
|
||||
return Positioned(
|
||||
width: 20,
|
||||
height: 20,
|
||||
left: 10,
|
||||
top: -10,
|
||||
child: CircleAvatar(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(3.0),
|
||||
child: Text(
|
||||
snapshot.data.toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user