1

I'm currently working on my first app. When I try to import

'package:flutter_google_maps/location_service.dart';

I'm given this message:

[myapp] flutter pub add flutter_google_maps The current Dart SDK version is 3.0.6.

Because myapp depends on flutter_google_maps any which doesn't support null safety, version solving failed.

The lower bound of "sdk: '>=2.6.0 <3.0.0'" must be 2.12.0 or higher to enable null safety. For details, see https://dart.dev/null-safety exit code 65

Can anyone explain this issue to me as if I were a child? I think I know that the dart version is incorrect, but how do I change the dart version? When I try to run which dart and which flutter, my computer is unfamiliar with it.

I tried to change the SDK version in the pubspec.yaml to sdk: '>=2.12.0 <3.0.0', but it didn't change anything.

audaciity
  • 11
  • 1
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jul 14 '23 at 16:52
  • In pub dev changelog google_maps_flutter 2.3.1 (https://pub.dev/packages/google_maps_flutter/changelog) it says minimum supported SDK version to Flutter 3.10/Dart 3.0. You can change to the required version of dart or use a different version of the library. You can also see pubspec.yaml in example app for google_maps_flutter – M14 Jul 14 '23 at 17:20
  • @M14 My flutter is on version 3.10.6 on the stable channel and my Dart is on version 3.0.6, so shouldn't mine work? I don't think I need to change my library version, right? – audaciity Jul 14 '23 at 17:30
  • @audaciity Wait, you're using a different plugin, but it hasn't been updated in two years and is incompatible with dart 3. You can downgrade flutter or change to the library I wrote about earlier (I recommend the second option). For the first option select here https://docs.flutter.dev/release/archive?tab=windows the required flutter version (it also shows which version of dart is used) and in the console flutter downgrade version – M14 Jul 14 '23 at 17:36
  • @M14 I’ll be honest, I’m still pretty confused on what I should do lol. When you say “change to the library I wrote about earlier,” are you saying that I should change to Flutter 3.10/ Dart 3.0.0, or change the version of the flutter_google_maps? Btw I really appreciate you taking the time out of your day to help me! – audaciity Jul 14 '23 at 17:56
  • @audaciity No, you're using flutter_google_maps, and I'm saying it's better to use google_maps_flutter if it meets your requirements – M14 Jul 14 '23 at 18:08
  • @M14 I seeeeee lol. I appreciate the help – audaciity Jul 14 '23 at 18:20

0 Answers0