Last active
October 3, 2020 14:57
-
-
Save luizmarcus/c52def4ba9a04452c6f5576472fd6700 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void onSend(ChatMessage message) async { | |
print(message.toJson()); | |
setState(() { | |
messages = [...messages, message]; | |
print(messages.length); | |
}); | |
sendMessage(message.text); | |
} | |
void initDio() { | |
BaseOptions options = BaseOptions( | |
baseUrl: "https://seusite.com/seu_backend", | |
connectTimeout: 10000, | |
); | |
_dio = new Dio(options); | |
} | |
Future<void> sendMessage(String msg) async { | |
Response response = await _dio.get("?msg=${Uri.encodeFull(msg)}"); | |
print(response.data.toString()); | |
setState(() { | |
messages = [ | |
...messages, | |
ChatMessage(text: response.data.toString(), user: bot) | |
]; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment