Skip to content

Instantly share code, notes, and snippets.

@luizmarcus
Last active October 3, 2020 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luizmarcus/c52def4ba9a04452c6f5576472fd6700 to your computer and use it in GitHub Desktop.
Save luizmarcus/c52def4ba9a04452c6f5576472fd6700 to your computer and use it in GitHub Desktop.
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