I am trying to use google places API in flutter. But whenever I try to run my project or do flutter pub get, this error keeps coming up:
The current Dart SDK version is 2.19.6.
Because api requires SDK version >=3.0.0 <4.0.0, version solving failed.
pub get failed
command: "C:\flutter\bin\cache\dart-sdk\bin\dart __deprecated_pub --directory . get --example"
pub env: {
"FLUTTER_ROOT": "C:\flutter",
"PUB_ENVIRONMENT": "flutter_cli:get",
"PUB_CACHE": "C:\Users\taehy\AppData\Local\Pub\Cache",
}
exit code: 1
I tried flutter upgrade in the terminal and it doesn't work. The weird thing is, when I type flutter upgrade in my cmd, it says that the version of my flutter sdk is already the most recent one. But in my project, it doesn't show up as the newest one. Also, this is my pubspec.yaml file:
version: 1.0.0+1
environment:
sdk: '>=3.0.0 <4.0.0'
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
http: ^1.0.0
google_maps_flutter: ^2.3.1
dev_dependencies:
flutter_test:
sdk: flutter
Please help me fix this error.
Try to download the sdk again, run the command "flutter clean" inside your peoject directory, and see if it works