I'm using the package flutter_chat_ui, when sending a word that contains accents, I get a text with special characters.
I looked on the package documentation but I couldn't find how to change the encoding.
My code : I get a list of messages from the server and then display them in the chat.
class MyChatPageState extends State<MyChatPage> {
List<types.Message> _messages = [];
final _user = const types.User(id: '82091008');
// Get messages from the server
startGetChatMessages() async{
chatMessages().then((value){
List result = json.decode(value.body);
setState(() => _messages = result; );
}).catchError((onError){
...
});
}
@override
void initState() {
super.initState();
startGetChatMessages(); // Get messages
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Chat(
messages: _messages,
onSendPressed: _handleSendPressed,
user: widget.userMe,
onPreviewDataFetched: _handlePreviewDataFetched,
);
}
// When the user presses the send button
void _handleSendPressed(types.PartialText message) {
final textMessage = types.TextMessage(
author: widget.userMe,
createdAt: DateTime
.now()
.millisecondsSinceEpoch,
id: randomString(),
text: message.text,
);
_addMessage(textMessage); // send message
}
}
