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

TimeoutException after 0:00:10.000000: Future not completed Error #566

Closed
2 tasks done
Abhijithsp opened this issue Oct 30, 2020 · 2 comments
Closed
2 tasks done

Comments

@Abhijithsp
Copy link

Abhijithsp commented Oct 30, 2020

🐛 Bug Report

I am trying to get current location it was working fine about 1 days ago but yesterday i have updated to latest version after that it does't work as expected,it throws timeout exception even if i added 10 sec time limit it still throws the error,i have lot plugins so i have tried to add a prefix then tried with that prefix but it throws same error
Flutter doctor not giving any error

Expected behavior

Get current location with latt and long value

Reproduction steps

Expanded(
            flex: 0,
            child: Padding(padding: EdgeInsets.all(10),
              child: Row(
                children: [
                  Icon(Icons.location_searching, color: Colors.black,),
                  GestureDetector(
                    onTap: (){
                      _getCurrentLocation();
                    },
                    child:Text("Locate Me", style: TextStyle(
                      fontWeight: FontWeight.bold,
                      color: Colors.black,), textAlign: TextAlign
                        .right,),
                  )

                ],
              ),),
          ),
Location function
 _getCurrentLocation() async{
    print("locateion");
    await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.best,forceAndroidLocationManager: true,timeLimit: Duration(seconds: 10))
        .then((Position position) {
      setState(() {
        _getAddressFromLatLng(position.latitude,position.longitude);
        print(position.latitude);
        print(position.longitude);
        final snackBar = SnackBar(content: Text("Located Successfully"));
        _scaffoldKey.currentState.showSnackBar(snackBar);
      });


    }).catchError((e) {
      print(e);
    });
  }

Configuration

Version: geolocator: ^6.1.2
Flutter version 1.22.2

Platform:
in both Platforms

  • 📱 iOS
  • 🤖 Android
@mvanbeusekom
Copy link
Member

Thank you for reporting this issue. I have made a small mistake when setting up the timeout on the getCurrentPosition method.

I have released an update of the geolocator_platform_interface package (v1.0.6+1) which includes a fix. To fix this you might need to run flutter pub get to update your packages. After that this issue should be solved and the timeout settings should be respected:

  1. If the timeLimit parameter is not supplied, no timeout will occur and the getCurrentPosition method will wait until it receives the first location;
  2. If a timeLimit is supplied the getCurrentPosition will throw a TimeoutException when the time limit is reached before a location is returned.

Apologies for the inconvenience.

@Abhijithsp
Copy link
Author

Thanks it worked 👌✌ @mvanbeusekom

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