개발자
locate.dart를 만들어서 import 'package:geolocator/geolocator.dart'; class Locate{ Future<List<double>> location() async { List<double> m_l = []; // 위치 권한 요청 LocationPermission permission = await Geolocator.requestPermission(); // 현재 위치 가져오기 Position position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high); // 위치 정보 리스트에 추가 m_l.add(position.longitude); m_l.add(position.latitude); return m_l; // 위치 정보를 포함한 리스트 반환 } Future<List<double>> get_loc() async { // 위치 정보를 가져오기 List<double> location = await this.location(); // 수정된 부분 return location; // 위치 정보를 포함한 리스트 반환 } } 를 작성하였구요 main_screen.dart 라는 파일에서 함수를 생성해서 my_locate() async{ Locate locator = Locate(); // 위치 정보 가져오기 List<double> location = await locator.get_loc(); } @override Widget build(BuildContext context) { // 함수 실행은 //요 부분에서 return Scaffold( 이 부분 안에서 실행시킬려고 하는데 자꾸 오류가 걸리네요. 방법 알려주실 분 있나요?
답변 0
첫 답변을 기다리고 있어요.
지금 가입하면 모든 질문의 답변을 볼 수 있어요!
현직자들의 명쾌한 답변을 얻을 수 있어요.
이미 회원이신가요?
지금 가입하면 모든 질문의 답변을 볼 수 있어요!