I have been working on a flutter mobile project of a taxi clone app. I have used Google Maps API for GeoCoding and Directions. I have been following a tutorial on youtube (the link). When I run the project I don't get any data and see this error in the console
[ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: type 'String' is not a subtype of type 'Uri'
Please help me. I am doing it for a school project
It's most likely due to the versioning of the http package. Looking at the video tutorial, it appears that the teacher used http 0.12.2, while it seems that you are using a later version(0.13.0 or above). If you look at the changelog, you'd see this note on the changes made after 0.12.2:
Breaking All APIs which previously allowed a
String
orUri
to be passed now require aUri
.
To solve your issue, you need to pass a Uri instead of a String
var url = Uri.parse('https://example.com');