Closed gtu-myowin closed 2 years ago
Hi! Obviously, you don't have to use Firebase :)
What does "backend agnostic" exactly means - you can use any backend, but still, when developing any UI package I have to use something, right? Since I don't know what backend will be eventually used, I still need to have ids, texts, images, some fields to render something and do some logic.
Now you probably have your own messages, and instead of "id" you have "messageId", instead of "type" you don't have anything, but still messages are messages, they always have id, in case of text messages they always have text etc. What you left to do is when you fetch messages from your backend, you just map them to my types, so all the presentation logic in the UI works - and importantly - you must not use custom messages for everything, you probably have a way of defining a simple text message, and you need to map it to my text message, and then you probably have image message, etc etc.
You can't do anything about it, if I'd have no types, I will not be able to write the UI. Any UI library will work the same way, another way would be just coding all the UI yourself.
Thank you for your quick reply and clearing the clouds in my head. I have thought of mapping my data to the pre-defined types when I was checking the below code
void _loadMessages() async {
final response = await rootBundle.loadString('assets/messages.json');
final messages = (jsonDecode(response) as List).map((e) => types.Message.fromJson(e as Map<String, dynamic>)).toList();
setState(() {
_messages = messages;
});
}
But now I am sure that this is the way I am heading to. Thank you again for the nice package and fast support.
Thank you for the nice chat UI package. I install it soon after I found the words "Backend agnostic" on the pub.dev page. Now I wonder how can I pass my messages & users to the Chat() widget.
I have read about the custom messages in the documentation (https://docs.flyer.chat/flutter/chat-ui/advanced-usage#custom-messages) as well but still don't know how.
My backend API is with Laravel + Pusher and I have configured it well. Just to be clear, this is not about the backend API. I have got all the messages and users in my flutter app.
I just don't know how to pass those information to the chat UI since it is using pre-defined modes from
flutter_chat_types.dart
.Do I need to override something or is that even possible? I am not planning to use with Firebase since my website is integrated with pusher.
Thank you for your time.