Closed 1rgs closed 5 years ago
@rahulgs12 this exception explains that you have an active request for permissions when a second call to the requestPermissions
is coming in. Make sure you await the call to requestPermissions
(which you indicate you do) and that you call it only once.
A common mistake is that people call the requestPermissions
method from build
method in there widget. In some situations this method can be called multiple times by Flutter to organize the UI and in this case also calling the plug-in multiple times.
If you keep on having problems please feel free to send us a code example, even better would be a small app that shows how to reproduce the error and we will be glad to have a look at it.
Hello @mvanbeusekom
Thank you for your response. Please, anyone, I need help with this simple geolocation app. It is very simple but I'm having the same problem in ios. It's Working in Android. dependencies: location: ^2.3.5 provider: ^3.0.0+1 geolocator: ^5.1.1+1
info.plist file
import 'dart:async'; import 'package:flutter/material.dart'; import 'package:geolocator/geolocator.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Get User Location', theme: ThemeData( primarySwatch: Colors.blue, ), home: MyHomePage(title: 'Get User Location'), ); } }
class MyHomePage extends StatefulWidget { MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override _MyHomePageState createState() => _MyHomePageState(); }
class _MyHomePageState extends State
Position position = null;
void requestLocationPermission(BuildContext context) async { Position currentPosition = await Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
setState(() {
position = currentPosition;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Requesting Location Permission'),
),
body:Column(
crossAxisAlignment: CrossAxisAlignment.center,
children:
Syncing files to device iPhone 6s... [VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: PlatformException(ERROR_ALREADY_REQUESTING_PERMISSION, A request for permissions is already running, please wait for it to finish before doing another request., null)
Sorry, I was missing these: it works
Ps. You need all 4: NSLocationUsageDescription NSLocationAlwaysUsageDescription NSLocationAlwaysAndWhenInUseUsageDescription NSLocationWhenInUseUsageDescription
Only after running the app directly in xcode did the message appear that stated there are missing permissions in the info.plist
🐛 Bug Report
If requestPermissions is called, this exception is thrown:
Expected behavior
This should work with no exception.
Reproduction steps
Version: 2.0.0
Platform: