Boa tarde!
Estou tentando aprender a utilizar o Dio
para integrar uma API que estou desenvolvendo também e para isso tentei realizar um teste simples.
Eu simplesmente tentei fazer um print no terminal mesmo utilizando esse trecho de código:
class _MyHomePageState extends State<MyHomePage> {
void teste() async {
Response res;
Dio dio = new Dio();
res = await dio.get("192.168.15.10:3000/welcome");
print(res.data.toString());
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Verifique o teste no terminal!!!:',
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: teste,
child: Icon(Icons.adjust),
),
);
}
}
A rota (Express) que estou utilizando no dio.get():
router.get('/', (req, res) => {
res.send({ message: 'Parabéns você está conectado a API' })
})
Porém quando executo teste no app pressionando o botão, obtenho o seguinte erro (Como é muito grande, decidi upar uma captura de tela dele, visando não poluir muito a postagem):
O que fiz de errado? Desde já agradeço.