a14n / dart-google-maps

A library to use Google Maps JavaScript API v3 from Dart scripts.
Apache License 2.0
130 stars 66 forks source link

Can't access extension methods #101

Closed delizondo closed 3 years ago

delizondo commented 3 years ago

Hi

First of all, thanks for this library, I've been using it for a while with Flutter Web, and it's great. However, today I've updated the library to the latest version, and I'm getting error accessing some extension methods.

The above code worked fine in previous versions of this library, but only when update it, it's causing me the errors showed in the screenshot.

Not sure how to access this methods, any suggestion?

Screen Shot 2021-04-06 at 08 26 00
a14n commented 3 years ago

Strange! Extensions are defined in the same library and should be valid as any other method. Did you try to restart your IDE? What's the current dart version in your pubspec.yaml ?

delizondo commented 3 years ago

Using VSCode as my main IDE, and if I restart the IDE the error continues

delizondo@MacBook-Pro fixar_admin % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.0.4, on Mac OS X 10.15.7 19H524 darwin-x64, locale en)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[!] Xcode - develop for iOS and macOS
    ✗ CocoaPods installed but not working.
        You appear to have CocoaPods installed but it is not working.
        This can happen if the version of Ruby that CocoaPods was installed with is different from the one being used to invoke it.
        This can usually be fixed by re-installing CocoaPods.
      To re-install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] VS Code (version 1.55.0)
[✓] Connected device (1 available)

My Dart version in my pubspec.yaml is

environment: sdk: ">=2.3.0 <3.0.0"

dart --version
Dart SDK version: 2.12.2 (stable) (Wed Mar 17 10:30:20 2021 +0100) on "macos_x64"
a14n commented 3 years ago

What's the version of google_maps package?

delizondo commented 3 years ago

What's the version of google_maps package?

google_maps: ^5.1.0

a14n commented 3 years ago

Strange that pub accepts that as google_maps: ^5.1.0 requires that your lower bound in the sdk constraint should be at least 2.12.0.

After bumping your sdk constraint to environment: sdk: ">=2.12.0 <3.0.0" it should be ok.

delizondo commented 3 years ago

@a14n thanks! I'll take a look at that. I've upgraded the sdk constraint to >=2.12.0 <3.0.0 and it's complaining everywhere about null safety, but that's another issue. I'll get back to you if the error persist after checking the null safety issue.

delizondo commented 3 years ago

@a14n something I've found is that even if I downgrade the google_maps library to version 4.0.0 (prior to null safety changes) I get the same error as stated above.

In the release notes, for version 4.0.0 the change was:

a14n commented 3 years ago

Extensions are enabled starting from sdk 2.6.0. I guess that's the reason fo your failures.

delizondo commented 3 years ago

Updated the sdk to sdk: '>=2.10.0 <3.0.0'

And the google_maps library to google_maps: ^4.0.0

Restarted the IDE, did a pub get packages, and the error persist, same as the original error in the screenshot

a14n commented 3 years ago

I'm sorry but I don't have other ideas without code access :-/ Is your project public?

delizondo commented 3 years ago

I'm sorry but I don't have other ideas without code access :-/ Is your project public?

No, it's a private repo, but I'll try to create a public example project to show this issue

delizondo commented 3 years ago

@a14n I've created a new example project with the core functionality of my main project, and was able to reproduce the issue.

The repo is: https://github.com/delizondo/Flutter_Maps_example

The error should be visible here

a14n commented 3 years ago

Thanks for the reproduction. To make it work you only have to add an import:

diff --git a/flutter_map_example/lib/map_parent_widget.dart b/flutter_map_example/lib/map_parent_widget.dart
index 90b7916..d83a562 100644
--- a/flutter_map_example/lib/map_parent_widget.dart
+++ b/flutter_map_example/lib/map_parent_widget.dart
@@ -1,4 +1,5 @@
 import 'package:flutter/material.dart';
+import 'package:google_maps/google_maps.dart';
 import 'package:google_maps/google_maps_places.dart';

 import 'map_location_notifier.dart';
delizondo commented 3 years ago

That's it!! Thanks a lot! it worked! The only question I have now is why the import is not suggested in both VSCode and Android Studio

a14n commented 3 years ago

The only question I have now is why the import is not suggested in both VSCode and Android Studio

That's another problem for another repo ;)