http.Client() should make a request
When making a request a minute or two after a client is opened, it errors with the following stacktrace:
E/flutter (12367): NoSuchMethodError: The method 'openUrl' was called on null.
E/flutter (12367): Receiver: null
E/flutter (12367): Tried calling: openUrl("PUT", Instance of '_SimpleUri')
E/flutter (12367): #0 Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:46:5)
E/flutter (12367): #1 IOClient.send (package:http/src/io_client.dart:30:36)
E/flutter (12367):
E/flutter (12367): #2 BaseClient._sendUnstreamed (package:http/src/base_client.dart:171:38)
E/flutter (12367):
E/flutter (12367): #3 BaseClient.put (package:http/src/base_client.dart:78:5)
E/flutter (12367): #4 _myFunction.. (file://main.dart:XXXX:XX)
E/flutter (12367): #5 _RootZone.runUnary (dart:async/zone.dart:1381:54)
E/flutter (12367): #6 _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
E/flutter (12367): #7 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:633:45)
E/flutter (12367): #8 Future._propagateToListeners (dart:async/future_impl.dart:662:32)
E/flutter (12367): #9 Future._completeWithValue (dart:async/future_impl.dart:477:5)
E/flutter (12367): #10 Future._asyncComplete.(dart:async/future_impl.dart:507:7)
E/flutter (12367): #11 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter (12367): #12 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
E/flutter (12367): #13 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:391:30)
E/flutter (12367): #14 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
E/flutter (12367): #15 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:165:12)
My code is:
client.get("https://google.com").then((response) {
print(response.body);
});
$ flutter --version
Flutter 0.5.1 • channel beta • https://github.com/flutter/flutter.git
Framework • revision c7ea3ca377 (3 months ago) • 2018-05-29 21:07:33 +0200
Engine • revision 1ed25ca7b7
Tools • Dart 2.0.0-dev.58.0.flutter-f981f09760
I can't replicate the issue with this minimal example:
import 'package:http/http.dart' as http;
main() {
var client = new http.Client();
client.get("https://google.com")
.then((response) {
print(response.body);
});
}
However, I see you're working with Flutter, and one that seems a little old.
Have you tried updating the various packages to the latest version and checked if the issue persists?
With the recent launch of Dart 2.0 quite a lot of things have changed during the transition, so it's possible you've hit some bad combination of versions.
seen this issue in flutter
@rakeshlanjewarwork can you please provide more information.
As mentioned above there is no way to reproduce. Without reproduction there is no way to fix.
Having the same issue when i make http GET request call, how do you resolve it @ottomated ? thanks
Are you calling .close() on the Client instance? That makes the client unusable for further requests...
Change the http library to dio, simple but powerful.
https://pub.dartlang.org/packages/dio/versions/2.1.0
I had the same issue, a full restart of the debugged app solved it.
Edit : it turns out it was my code, I disposed it and tried to use it again (quite difficult to find out)
Most helpful comment
Are you calling
.close()on theClientinstance? That makes the client unusable for further requests...