Solucionado (ver solução)
Solucionado
(ver solução)
2
respostas

Erro no HTTP

Bom dia,

Quando faço o hot Reload ou o Hot Restart eu recebo a seguinte mensagem:

lib/http/webclient.dart:5:39: Error: The argument type 'String' can't be assigned to the parameter type 'Uri'.

-'Uri' is from 'dart:core'. final Response response = await get('http://192.168.0.10:8080/transactions');

Segue meu webclient.dart

import 'package:http/http.dart';

void findAll() async {
  final Response response = await get('http://192.168.0.10:8080/transactions');
  print(response.body);
}

O trecho 'http://192.168.0.10:8080/transactions' está sublinhado em vermelho demonstrando o erro, quando coloco o cursor em cima aparece o seguinte texto: The argument type 'String' can't be assigned to the parameter type 'Uri'. (Documentation)

Como resolvo esse problema?

2 respostas

Oi Sergio, tudo bem?

Tente por favor substituir então a string por uma chamada de Uri como no exemplo abaixo:

await get(Uri.http('http://192.168.0.10:8080', 'transactions'));

Testa e volta aqui pra me contar se deu certo! :)

Abração e bom estudo!

solução!

Eu consegui colocar par funcionar, mas eu usei https invés de http.

  await client.get('https://192.168.20.249:8080/transactions');

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software