flutter-geolocator icon indicating copy to clipboard operation
flutter-geolocator copied to clipboard

Location is not being returned

Open Wixi105 opened this issue 6 years ago • 5 comments

So I just added the plugin to my pubspec file, run pub get, and also added the method from the example on the package page. There is no location data being returned from the plugin and it is disturbing me. I am not entirely sure it is a bug but I need some help with that

Wixi105 avatar Sep 18 '20 16:09 Wixi105

First of all, all caps in the title does not really motivate me to help you, puts you already -1 behind.

Second you are not providing any helpful information that would put me in the spot to actually help you. Why do you expect me to spend my time helping you to fix your problem if you don't even take the time to fill in the issue template?

If you really want me to help provide at least the following information:

  • Specify the version of the plugin you are using;
  • Specify the platform you are experiencing this behaviour (Android, iOS or both);
  • Specify if you are testing on a real device or on the simulator/ emulator;
  • Provide some example code and make sure you already carefully read issue #507.

mvanbeusekom avatar Sep 18 '20 16:09 mvanbeusekom

Sorry. I have never filled out an issue and I am very sorry for my bad manners. I just thought if I used all caps it would grab your attention. My version of the plugin is geolocator: ^6.0.0+4 I am using it on the Android Emulator and experiencing this problem only on the Android Emulator. Haven't tried IOS yet. I have read issue #507 and couldn't really find any help.

import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';

class LoadingScreen extends StatefulWidget {
  @override
  _LoadingScreenState createState() => _LoadingScreenState();
}

class _LoadingScreenState extends State<LoadingScreen> {


  void getLocation() async{
    Position position = await getCurrentPosition(desiredAccuracy: LocationAccuracy.low);
    print(position);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: RaisedButton(
          onPressed: () {
          getLocation();
          },
          child: Text('Get Location'),
        ),
      ),
    );
  }
}

Wixi105 avatar Sep 18 '20 17:09 Wixi105

@Wixi105 try changing the desired accuracy to LocationAccuracy.high or above. Android Emulator doesn't support simulating position updates based on the network or cell towers and therefore never returns any update. So update your call to the getCurrentPosition method to this:

    Position position = await getCurrentPosition(desiredAccuracy: LocationAccuracy.high);

Also just to make sure, check if you added the android.permission.ACCESS_FINE_LOCATION permission to the AndroidManifest.xml file.

And last but not least verify that you set a location in the emulator.

mvanbeusekom avatar Sep 18 '20 17:09 mvanbeusekom

Thank you very much. That worked and I am very sorry for being rude. I didn't actually mean to be and I'm sorry for not filling out the template.

Wixi105 avatar Sep 18 '20 17:09 Wixi105

Glad to hear that solved the problem. Just wanted to let you (and others) know that we are doing these open source things in our spare time, so be considerate and if you want help be nice and try to give as much information as possible. The template is there to help and let you know which information we need.

mvanbeusekom avatar Sep 18 '20 18:09 mvanbeusekom