Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

E/flutter ( 7683): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: FormatException: Invalid radix-10 number (at character 1) E/flutter ( 7683): //192.168.1.7:8080

Estou recebendo esse erro ao tentar utilizar o Interceptor, esse erro só aparece no Console: E/flutter ( 7683): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: FormatException: Invalid radix-10 number (at character 1) E/flutter ( 7683): //192.168.1.7:8080 E/flutter ( 7683): ^ E/flutter ( 7683): E/flutter ( 7683): #0 int._throwFormatException (dart:core-patch/integers_patch.dart:131:5) E/flutter ( 7683): #1 int._parseRadix (dart:core-patch/integers_patch.dart:142:16) E/flutter ( 7683): #2 int._parse (dart:core-patch/integers_patch.dart:100:12) E/flutter ( 7683): #3 int.parse (dart:core-patch/integers_patch.dart:63:12) E/flutter ( 7683): #4 _Uri._makeHttpUri (dart:core/uri.dart:1591:49) E/flutter ( 7683): #5 new _Uri.http (dart:core/uri.dart:1456:12) E/flutter ( 7683): #6 findAll (package:bytebank/http/webclient.dart:33:28) E/flutter ( 7683): #7 main (package:bytebank/main.dart:7:3) E/flutter ( 7683): #8 _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:140:25) E/flutter ( 7683): #9 _rootRun (dart:async/zone.dart:1354:13) E/flutter ( 7683): #10 _CustomZone.run (dart:async/zone.dart:1258:19) E/flutter ( 7683): #11 _runZoned (dart:async/zone.dart:1788:10) E/flutter ( 7683): #12 runZonedGuarded (dart:async/zone.dart:1776:12) E/flutter ( 7683): #13 _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:133:5) E/flutter ( 7683): #14 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:283:19) E/flutter ( 7683): #15 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12) E/flutter ( 7683):

import 'dart:convert';

import 'package:bytebank/models/contact.dart';
import 'package:bytebank/models/transaction.dart';
import 'package:http/http.dart';
import 'package:http_interceptor/http_interceptor.dart';

class LogginInterceptor implements InterceptorContract {
  @override
  Future<RequestData> interceptRequest({RequestData data}) async {
    print('Request');
    print('url: ${data.url}');
    print('headers: ${data.headers}');
    print('body: ${data.body}');
    return data;
  }

  @override
  Future<ResponseData> interceptResponse({ResponseData data}) async {
    print('Response');
    print('status code: ${data.statusCode}');
    print('headers: ${data.headers}');
    print('body: ${data.body}');
    return data;
  }
}

Future<List<Transaction>> findAll() async {
  final Client client = HttpClientWithInterceptor.build(
    interceptors: [LogginInterceptor()],
  );
  final Response response =
      await client.get(Uri.http('http://192.168.1.7:8080','transactions'));
  final List<dynamic> decodedJson = jsonDecode(response.body);
  final List<Transaction> transactions = [];
  for (Map<String, dynamic> transactionJson in decodedJson) {
    final Map<String, dynamic> contactJson = transactionJson['contact'];
    final Transaction transaction = Transaction(
      transactionJson['value'],
      Contact(
        0,
        contactJson['name'],
        contactJson['accountNumber'],
      ),
    );
    transactions.add(transaction);
    print(response.body);
  }
  return transactions;

}
1 resposta
solução!

Oi Thais, só o ouro?

Então, ele está falando que o formato do seu http está incorreto, vamos tentar colocar ele assim:

await client.get(Uri.http('192.168.1.7:8080','transactions'));

Se por acaso não funcionar, tente:

await client.get(Uri.https('192.168.1.7:8080','transactions'));

Com a nova atualização do flutter a utilização do URL mudou um pouco, estamos trabalhando para corrigir isso rapidamente!