Comments (11)
you can fix it using the following:
add this in the build method
WidgetsBinding.instance.addPostFrameCallback(afterBuild);
and use a scrollcontroller like the following:
void afterBuild(Duration duration) {
_scrollController.jumpTo(_scrollController.position.maxScrollExtent);
}
from dash_chat.
@Marcosmaliki This is fixed in 1.0.17
.
from dash_chat.
I have updated but I can't see any difference. All I want is to display the latest messages first. The current implementation displays old messages then scrolls/jumps to the latest. Reproduce this with a thousand messages to see how ugly it looks.
from dash_chat.
from dash_chat.
Hello can you provide an example project? And I'll take a look at it
from dash_chat.
Hello @Dreamersoul thanks!
Reversing the list then reversing the message works alright but the list scrolls to the top when sending a message๐. Ps. I'm not using Firebase
return Scaffold(
appBar: AppBar(
title: Text('Messages'),
),
body: FutureBuilder<ApiRes<MessagesRes>>(
future: NetworkCalls().getMessages(id),
builder: (context, snapshot) {
if (snapshot.hasData) {
if (snapshot.data.error) {
return Center(child: Text(snapshot.data.errorMsg.toString()));
} else {
List<Messages> msgs =
List.from(snapshot.data.data.messages);
// List.from(snapshot.data.data.messages.reversed);
var mess;
messages.clear();
msgs.forEach((f) {
user = ChatUser(
name: f.name,
uid: f.from,
avatar: "f.avatar",
);
mess = ChatMessage(
text: f.message,
user: user,
createdAt: DateTime.parse(f.createdat)
.add(new Duration(hours: 3)));
messages.add(mess);
});
return DashChat(
messages: messages,
showUserAvatar: false,
showAvatarForEveryMessage: false,
scrollToBottom: false,
inverted: false,//true
user: user,
shouldShowLoadEarlier: false,
key: _chatViewKey,
onSend: onSend,
leading: <Widget>[
IconButton(
icon: Icon(Icons.attach_file),
onPressed: () {
print("object");
},
)
],
// scrollController: _scrollController,
onLoadEarlier: () {
print('loading . . . ');
},
onLongPressMessage: (val) {
_modalBottomSheet(context);
},
inputDecoration:
InputDecoration.collapsed(hintText: "Add message here..."),
dateFormat: DateFormat('dd MMM yyyy'),
timeFormat: DateFormat.jm(),
inputMaxLines: 5,
messageContainerPadding:
EdgeInsets.only(left: 5.0, right: 5.0, top: 5),
alwaysShowSend: false,
inputTextStyle: TextStyle(fontSize: 16.0),
inputContainerStyle: BoxDecoration(
border: Border.all(width: 0.0, color: Colors.grey),
color: Colors.white,
),
);
}
} else if (snapshot.hasError) {
return Center(child: Text(snapshot.error.toString()));
}
return Center(child: spinkitSquareCircle);
},
),
);
from dash_chat.
Can I see the onSend
method?
from dash_chat.
void onSend(ChatMessage message) {
//send to API and MQTT
print(message.text + 'ID of sending user: $id');
Map<String, dynamic> data = {'message': message.text, 'to': id};
sendMessage(data);
messages.insert(0,
ChatMessage(text: message.text, createdAt: DateTime.now(), user: user));
messages = [...messages];
}
the insert method is a fix to add the message as the start of the array when reversed. My major issue is the scrolling. Check the gif above. The list stutters when scrolling
from dash_chat.
i dont seem to know how to fix this, maybe @fayeed can help out!
from dash_chat.
Same problem here =/
from dash_chat.
mark, same problem
from dash_chat.
Related Issues (20)
- [Bug] Old Chat messages are not aligned with sender to the right HOT 1
- [Question] Does this have null safety? HOT 5
- [Question] Why is it necessary for scrollNotificationFunc to always return true?
- 1.1.16 cannot show emojis HOT 4
- how to use flutter dash_chat with dialogflow?
- why dash_chat support 3 Quick Replies limited at 3? in flutter any idea
- how i use flutter_dialogflow with dashchat to my app flutter
- Can't open chat emoji dash_chat: ^1.1.16 HOT 5
- does the package support sending videos and files ?
- [Feature request] Your title
- [Question] about messageTextBuilder HOT 1
- does 2.0 release? HOT 5
- [Bug] default DateBuilder is wrong when scrolling HOT 1
- [Feature request] ListView.custom to prevent widgets from rebuilding
- [Question] Is it possible to send a new message programmatically?
- How to show sender name or auth anme in massage box list? and also emoji are not working in chat.
- [Feature request] Voice
- Invalid image data
- Null check operator used on a null value
- padding between messages
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dash_chat.