clearUserChatHistory method
Implementation
clearUserChatHistory(BuildContext context) {
if (chatList.isNotEmpty) {
Future.delayed(const Duration(milliseconds: 100), () {
var starred =
chatList.indexWhere((element) => element.isMessageStarred.value);
Helper.showAlert(
message: AppConstants.areYouClearChat,
actions: [
Visibility(
visible: !starred.isNegative,
child: TextButton(
onPressed: () {
// Get.back();
Navigator.pop(context);
clearChatHistory(false, context);
},
child: Text(
AppConstants.clearAll.toUpperCase(),
style: TextStyle(
color: MirrorflyUikit.getTheme?.primaryColor),
)),
),
TextButton(
onPressed: () {
// Get.back();
Navigator.pop(context);
},
child: Text(
AppConstants.cancel.toUpperCase(),
style:
TextStyle(color: MirrorflyUikit.getTheme?.primaryColor),
)),
Visibility(
visible: starred.isNegative,
child: TextButton(
onPressed: () {
// Get.back();
Navigator.pop(context);
clearChatHistory(false, context);
},
child: Text(
AppConstants.clear.toUpperCase(),
style: TextStyle(
color: MirrorflyUikit.getTheme?.primaryColor),
)),
),
Visibility(
visible: !starred.isNegative,
child: TextButton(
onPressed: () {
// Get.back();
clearChatHistory(true, context);
Navigator.pop(context);
},
child: Text(
AppConstants.clearExceptStarred.toUpperCase(),
style: TextStyle(
color: MirrorflyUikit.getTheme?.primaryColor),
)),
),
],
context: context);
});
} else {
toToast(AppConstants.noConversation);
}
}