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

MissingPluginException when trying to use #311

Closed
ShehabSN opened this issue Aug 5, 2019 · 5 comments
Closed

MissingPluginException when trying to use #311

ShehabSN opened this issue Aug 5, 2019 · 5 comments
Assignees
Labels
status: closed (missing info) Indicates the issue was automatically closed due to a lack of information. type: bug Something isn't working

Comments

@ShehabSN
Copy link

ShehabSN commented Aug 5, 2019

I followed the docs and i tried to use the example code for getting the distancebetween two geo points below:

double distanceInMeters = await Geolocator().distanceBetween(52.2165157, 6.9437819, 52.3546274, 4.8285838);
          print(distanceInMeters);

This didn't work however and i got an exception:

Unhandled Exception: MissingPluginException(No implementation found for method distanceBetween on channel flutter.baseflow.com/geolocator/methods)

Any ideas why this is happening? I ran packages get,upgrade, even flutter upgrade and still the same issue. Is this method deprecated or removed?

@mvanbeusekom mvanbeusekom added the status: needs more info We need more information before we can continue work on this issue. label Aug 26, 2019
@mvanbeusekom
Copy link
Member

@ShehabSN, I have been looking in to this issue but having a hard time reproducing it. Using the example app (part of the Geolocator plugin). Could you maybe supply a bit more information? Questions right out of the box are:

  • Which version of the plugin are you using (maybe you are using an outdated version and you should update, we tested with 5.1.1 and 5.1.2)?
  • Do you get this error on both (Android and iOS) platforms (I tested both platforms and both worked)?
  • Which version of Flutter do you use?

@mvanbeusekom mvanbeusekom self-assigned this Aug 26, 2019
@mvanbeusekom mvanbeusekom added the type: bug Something isn't working label Aug 26, 2019
@mvanbeusekom
Copy link
Member

Closing this issue because of lack of activity. Feel free to re-open it and supply the requested additional information when the issue resurfaces.

@dougsibley
Copy link

Hi - I'm having this issue as well in trying to run unit testing. Perhaps it is because I'm calculating distances before creating a GeoLocator object/stream and starting to get any location. That said, I'm not clear why the distanceBetween function is a Future function; I would have thought it would make sense to be a static class method.

Code to reproduce this is below.

car_trip.dart:

import 'package:geolocator/geolocator.dart';

class CarTrip {
  double tripDistance = 0; // Distance in meters
  var _geoLocator = Geolocator();

  List<Position> _tripWaypoints; // List of positions returned by GPS in a trip

  Future<void> addWaypoint(Position newWaypoint) async {
    if (_tripWaypoints == null) {
      _tripWaypoints = [newWaypoint];
    } else {
      Position priorWaypoint = _tripWaypoints.last;
      tripDistance += await _geoLocator.distanceBetween(priorWaypoint.latitude,
          priorWaypoint.longitude, newWaypoint.latitude, newWaypoint.longitude);
      _tripWaypoints.add(newWaypoint);
    }
    
    print("NewWaypoint: ${newWaypoint.latitude}, ${newWaypoint.longitude}");

    // TODO: Add trip time. 

  } // addWaypoint
} // class CarTrip

car_trip_test.dart:

import 'package:carcost/cartrip.dart';
import 'package:geolocator/geolocator.dart';
import 'package:flutter_test/flutter_test.dart';

main() {
  TestWidgetsFlutterBinding.ensureInitialized();
  test('Distance between waypoints should be non-zero.', () async {
    // Unit test
    Position pos1 = Position(latitude: 33, longitude: 33);
    Position pos2 = Position(latitude: 34, longitude: 34);

    CarTrip testCarTrip = CarTrip();
    await testCarTrip.addWaypoint(pos1);
    await testCarTrip.addWaypoint(pos2);
    print("Test distance is ${testCarTrip.tripDistance} ");
    expect(testCarTrip.tripDistance, 145000);
  });
}

@dan-gandolfo
Copy link

Hi,

I have the same issue when I call Geolocator.isLocationServiceEnabled() in a background isolate function.

Have you a workaround to fix it?

Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 2.10.5, on macOS 12.3.1 21E258 darwin-arm, locale fr-FR) [✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1) [✓] Xcode - develop for iOS and macOS (Xcode 13.4.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.1) [✓] VS Code (version 1.67.2) [✓] Connected device (4 available) [✓] HTTP Host Availability

geolocator: ^8.2.1

@mvanbeusekom
Copy link
Member

Hi @dangabdolfo,

The solution to this is described in this comment.

@mvanbeusekom mvanbeusekom added status: closed (missing info) Indicates the issue was automatically closed due to a lack of information. and removed status: needs more info We need more information before we can continue work on this issue. labels Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: closed (missing info) Indicates the issue was automatically closed due to a lack of information. type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants