fluttercommunity/flutter_google_places

Google maps webservice error: The argument type 'String' can't be assigned to the parameter type 'Uri'.

thealteria opened this issue · 5 comments

Getting this error while running the app:

../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/google_maps_webservice-0.0.19/lib/src/utils.dart:61:27: Error: The argument type 'String' can't be assigned to the parameter type 'Uri'.
 - 'Uri' is from 'dart:core'.
    return httpClient.get(url, headers: headers);

                          ^
../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/google_maps_webservice-0.0.19/lib/src/utils.dart:74:28: Error: The argument type 'String' can't be assigned to the parameter type 'Uri'.

 - 'Uri' is from 'dart:core'.
    return httpClient.post(url, body: body, headers: postHeaders);
                           ^
3 FAILURE: Build failed with an exception.

* Where:
Script 'C:\Users\hp\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\Users\hp\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 16s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

Because other packages depend on http: 0.13.0, I have updated to latest dependencies. Trying workaround https://github.com/hoc081098/flutter_google_places:

dependency_overrides:
  flutter_google_places:
    git:
      url: https://github.com/hoc081098/flutter_google_places.git
      ref: 7b6c2aa2053131142c0e48639823d24f312d00c1

so I remove my flutter_google_places dependency from the dependencies and just put it in the pubspec.yaml like you mentioned?

Just published as new name: https://pub.dev/packages/flutter_google_places_hoc081098. Only replace the importing

- import 'package:flutter_google_places/flutter_google_places.dart';
+ import 'package:flutter_google_places_hoc081098/flutter_google_places_hoc081098.dart';

Can you test with version 0.3.0?

This is an easy fix.
Just parse the String object with Uri().

for e.g Uri.parse(yourStringHere)