geolocator 가 import 가 안되는데 어떡하죠?
92
작성한 질문수 23
코드팩토리 디스코드에 질문하면 더욱 빠르게 질문을 받아 볼 수 있습니다!
[코드팩토리 디스코드]
https://bit.ly/3HzRzUM
geolocator 가 import 가 안되는데 어떡하죠?
오류는 아래와 같이 나오구요.
Target of URI doesn't exist: 'package:geolocator/geolocator.dart'.
소스는 아래와 같습니다.
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:geolocator/geolocator.dart';
class HomeScreen extends StatefulWidget {
const HomeScreen({super.key});
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
final CameraPosition initialPosition = CameraPosition(
target: LatLng(
37.5214,
126.9246
),
zoom: 15,
);
checkPermission() async{
final isLocationEnabled = await Geolocator.isLocationServiceEnabled();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [Expanded(child: GoogleMap(initialCameraPosition: initialPosition))],
),
);
}
}
pubspec.yaml 은 아래와 같이 되어 있습니다.
name: chool_check
description: "A new Flutter project."
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+1
environment:
sdk: ^3.7.2
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.8
google_maps_flutter: ^2.6.0
geolocator: ^14.0.0
dev_dependencies:
flutter_test:
sdk: flutter
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^5.0.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter packages.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/to/resolution-aware-images
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/to/asset-from-package
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/to/font-from-package
답변 2
0
안녕하세요, 인프런 AI 인턴입니다. moonseok.shin님.
geolocator 패키지가 import되지 않는 문제는 대부분 pubspec.yaml 파일과 관련된 설정 오류에서 발생합니다. 다음 사항들을 확인해보시기 바랍니다:
패키지 설치 여부 확인:
geolocator패키지가pubspec.yaml에 추가되어 있음을 확인하셨으니,flutter pub get명령어를 실행하여 의존성을 업데이트하십시오. 이를 통해 패키지가 올바르게 설치되었는지를 확인할 수 있습니다.패키지 버전 호환성 확인:
geolocator패키지의 최신 버전을 사용하는 것이 중요합니다. 때때로 패키지 버전 간의 충돌로 인해 문제가 발생할 수 있습니다.pubspec.yaml에 명시되어 있는geolocator패키지의 버전 번호가 최신인지 확인하고, 필요하다면 최신 버전으로 업데이트하십시오.패키지 명세 확인:
pubspec.yaml파일 내 dependencies 섹션에geolocator: ^14.0.0이 올바르게 기재되어 있는 것을 확인하였습니다. 이 부분이 정확하다면 특별한 문제는 없어 보입니다.IDE 재시작: 가끔 플러그인이나 캐시 문제가 발생할 수 있습니다. 사용하는 IDE(예: Android Studio, Visual Studio Code)를 재시작하고 다시 시도해보시기 바랍니다.
Flutter SDK와의 호환성 확인: 사용하고 있는 Flutter SDK의 버전이
geolocator와 호환되는지도 확인해보세요. 프로젝트에 사용하는 Flutter 버전을flutter --version명령어로 확인할 수 있습니다.
해당 문제의 해결에 참고할 수 있는 유사 질문이 있습니다:
- Invalid depfile 에러 관련 해결 방안
위 방법들이 문제 해결에 도움이 되지 않는다면, 오류 메시지나 콘솔 로그를 보다 자세히 분석하여 다시 한 번 확인해주세요.
저는 질문자님의 이해를 돕고자 지식공유자님의 기존 답변을 참고하여 유사한 답변 링크를 추천해드리고 있습니다.
현재 베타 기능으로 답변이 만족스럽지 않을 수 있는 점 양해 부탁드립니다. 🙏
추가적으로 궁금한 점이 있으시면, 이어서 질문해 주세요. 곧 지식공유자께서 답변해 주실 것입니다.
198강 (){onTap(e);}의 이해 돕기
0
28
1
video_call 플러그인 설치후 에러 발생
0
45
1
SDK 안드로이드 설치 질문!
0
60
1
코드팩토리 디스코드 링크 다시 부탁드려요~
0
92
1
Webview를 이용해서 URL 상의 페이지 출력 불가
0
70
1
홈스크린 함수를 함축해서 main.dart에 옮기는 문제
0
55
1
플레이스토어
0
59
1
아고라 엔진 init 함수의 반환타입이 Future<void> 이것의 의미는 무엇인가요?
0
55
1
가이드라인 질문
0
57
0
emulator 에러 환경설정 뭐가 문제 일까요??
0
77
1
emulator 실행 오류
0
93
3
Column을 가로방향 최대 사이즈를 차지하도록 하는 방법에 관련
0
71
1
pubspec.yaml에서 font를 추가하면서 weight 값을 지정하는 것이 의미가 있는 것인지 문의
0
43
1
setState()를 호출하지 않으면 build가 실행 안되는 건가요?
0
53
1
video_call 플러그인 설치시 에러문제
0
64
1
children 안의 if 문에서 { } 못쓰는 이유?
0
48
1
이렇게 오류가 떠요
0
64
1
AppBar 사용했는데
0
61
2
[문제해결] '오늘도 출첵!' 의 171번 강의에서 중요한 문제를 발견했습니다
0
56
1
StatefulWidget 실습 에러가 발생합니다.[해결완료]
0
63
1
Video Player 프로젝트에 대한 추가 질문
0
53
0
Row위젯이나 column위젯의 위치는 누가 정하나요??
0
42
1
geolocator 오류때문에 개발진행이 불가능입니다
0
63
1
API 관련 이슈
0
86
2





