displayMessages method
Implementation
Widget displayMessages(int index, MessageModel message) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Column(
children: [
Padding(
padding: const EdgeInsets.only(left: 60.0, right: 16),
child: ListTile(
textColor: Get.theme.colorScheme.onSurface,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(16),
topLeft: Radius.circular(16),
bottomRight: Radius.circular(16))),
tileColor: Get.theme.colorScheme.primaryContainer,
contentPadding: EdgeInsets.zero,
title: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Text(
message.message,
),
),
),
),
message.response != null
? Padding(
padding: EdgeInsets.only(
left: 16.0,
right: message.isReading ? 16.0 : 60.0,
top: 16.0,
),
child: Row(
children: [
Expanded(
child: ListTile(
textColor: Get.theme.colorScheme.onSurface,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(16),
topRight: Radius.circular(16),
bottomRight: Radius.circular(16))),
tileColor: Get.theme.colorScheme.surfaceVariant,
contentPadding: EdgeInsets.zero,
title: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 16.0),
child: Text(
message.response!.gptResponse ?? '',
),
),
),
),
if (message.isReading)
SizedBox(
width: 44,
height: 44,
child: Lottie.asset(
"packages/chat_bot_llm/assets/animation/chat_reading.json")),
],
),
)
: Padding(
padding:
const EdgeInsets.only(left: 16.0, right: 60, top: 16),
child: ListTile(
contentPadding: EdgeInsets.zero,
leading: Container(
decoration: BoxDecoration(
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(16),
topRight: Radius.circular(16),
bottomRight: Radius.circular(16)),
color: Get.theme.colorScheme.surfaceVariant),
child: Lottie.asset(
"packages/chat_bot_llm/assets/animation/chat_typing.json")),
),
),
],
),
);
}