Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to addDirection with GeoCoord on Android #59

Open
autosoft-co opened this issue Nov 8, 2020 · 2 comments
Open

Unable to addDirection with GeoCoord on Android #59

autosoft-co opened this issue Nov 8, 2020 · 2 comments

Comments

@autosoft-co
Copy link

When I try to add direction to map. It fails with below error.

Here is my code.

_mapKey.currentState.addDirection(
        GeoCoord(
          lat1,
          lng1,
        ),
        GeoCoord(
          lat2,
          lng2,
        ),
        startLabel: "S",
        endLabel: "You",
);

It's works fine on web.

Error log

E/flutter ( 1300): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: Unsupported operation: Unsupported type of argument: LatLng
E/flutter ( 1300): #0      _convertLocation (package:google_directions_api/src/directions.request.dart:24:3)
E/flutter ( 1300): #1      DirectionsRequest.toString (package:google_directions_api/src/directions.request.dart:213:35)
E/flutter ( 1300): #2      DirectionsService.route (package:google_directions_api/src/directions.dart:54:45)
E/flutter ( 1300): #3      GoogleMapState.addDirection (package:flutter_google_maps/src/mobile/google_map.state.dart:272:23)
E/flutter ( 1300): #4      _TrackOrderPageState._addDirectionOnMap.<anonymous closure> (package:foodxpapp/features/orders/presentation/pages/track_order_page.dart:88:28)
E/flutter ( 1300): #5      SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1117:15)
E/flutter ( 1300): #6      SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1063:9)
E/flutter ( 1300): #7      SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:971:5)
E/flutter ( 1300): #8      _rootRun (dart:async/zone.dart:1190:13)
E/flutter ( 1300): #9      _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter ( 1300): #10     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
E/flutter ( 1300): #11     _invoke (dart:ui/hooks.dart:251:10)
E/flutter ( 1300): #12     _drawFrame (dart:ui/hooks.dart:209:3)
E/flutter ( 1300): 
Analyzing app...                                             
No issues found! (ran in 7.3s)
[✓] Flutter (Channel beta, 1.23.0-18.1.pre, on Mac OS X 10.15.6 19G2021 x86_64, locale en-IN)
    • Flutter version 1.23.0-18.1.pre at /Users/kinggaming/flutter
    • Framework revision 198df796aa (3 weeks ago), 2020-10-15 12:04:33 -0700
    • Engine revision 1d12d82d9c
    • Dart version 2.11.0 (build 2.11.0-213.1.beta)

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/kinggaming/Library/Android/sdk
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS
    ✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
      Download at: https://developer.apple.com/xcode/download/
      Or install Xcode via the App Store.
      Once installed, run:
        sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
        sudo xcodebuild -runFirstLaunch
    • CocoaPods version 1.9.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.50.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.16.0

[✓] Connected device (3 available)
    • RMX1921 (mobile) • 5c7df826   • android-arm64  • Android 10 (API 29)
    • Web Server (web) • web-server • web-javascript • Flutter Tools
    • Chrome (web)     • chrome     • web-javascript • Google Chrome 86.0.4240.183

! Doctor found issues in 1 category.
@autosoft-co
Copy link
Author

Found a fix.

Instead of passing GeoCoords to addDirection. You can pass LatLng string like below.

final latLng = "$lat,$lng";

@eloix2
Copy link

eloix2 commented Mar 28, 2022

Another way to fix it is using a String "lat,long", in case someone is having the same error and don't want to use latLng.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants