min_chan님의 블로그

[Flutter] - PermissionDeniedException User denied permissions to access the device's location. 본문

Flutter

[Flutter] - PermissionDeniedException User denied permissions to access the device's location.

min_chan 2025. 1. 15. 10:08

 

에러 코드 & 사진

class _LoadingPageState extends State<LoadingPage> {
  Future<void> getLocation() async {
    Position position = await Geolocator.getCurrentPosition(
        desiredAccuracy: LocationAccuracy.high);
    print(position);
  }

 


해결방법

  • pub.dev에서 찾아본 결과 해당 코드를 추가해 주면 된다고 한다.
  •  

해결 코드 & 사진

class _LoadingPageState extends State<LoadingPage> {
  Future<void> getLocation() async {
    LocationPermission permission = await Geolocator.requestPermission();
    Position position = await Geolocator.getCurrentPosition(
        desiredAccuracy: LocationAccuracy.high);
    print(position);
  }

 


  • requestPermission이 잘 나오는 것을 볼 수 있다 ^^*