import 'dart:io';
void main() async {
String messager = '';
print('------- INICIADO CHAT -------');
await clock(3);
print('------- CHAT ENTRE EVERTON E LUANA INICIADO -------');
await clock(1);
print('Everton Inicia a Conversa com Luana');
try{
var by = true;
String conversationEvertonAndLuana = '';
String messager = '';
do{
messager = messageEvertonFunc();
await clock(2);
print('-- TELA CHAT LUANA --');
conversationEvertonAndLuana += messager;
print(conversationEvertonAndLuana);
print('----------------------------- \n LUANA RESPONDE: ');
if(messager.contains('xau') || messager.contains('Xau')){
by = false;
break;
}
messager = messageLuanaFunc();
await clock(2);
print('-- TELA CHAT EVERTON --');
conversationEvertonAndLuana += messager;
print(conversationEvertonAndLuana);
print('----------------------------- \n EVERTON RESPONDE: ');
if(messager.contains('xau') || messager.contains('Xau')){
by = false;
}
}while(by);
}catch(e){
print('unexpected error: $e');
}finally{
await clock(1);
print('CONVERSA ENCERRADA');
await clock(3);
}
}
String messageEvertonFunc(){
String nameEverton = ' \n Everton: ';
String message = stdin.readLineSync().toString();
String messageSend = nameEverton + message;
return messageSend;
}
String messageLuanaFunc(){
String nameLuana = '\n Luana: ';
String message = stdin.readLineSync().toString();
String messageSend = nameLuana + message;
return messageSend;
}
Future clock(int seconds){
return Future.delayed(Duration(seconds: seconds));
}