[Flutter] Future-Async-Await

sidcode·2024년 6월 8일

Future-Async-Await 를 예제를 통해 글읽듯이 간단하게 이해해보겠습니다.

double latitube = 0.0;

Future<void> _getLocatoin() async{
	Position position = await Geolocator.getCurrentPosition(
    desiredAccuracy: LocationAccuracy.best);
    
    setState(() {
      latitude = position.latitude;
      debugPrint("Latitude : $latitude");
    });
}

(future)미래에 A가 완료될때까지 기다렸다가(await) latitude에 값이 치환된 후에(async) 처리하세요.

A가 뭔데 : Geolocator.getCurrentPosition

profile
I will do, what i want!!

0개의 댓글