Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Issues after Flutter upgrade

I am completely lost.

Last week I was working in a project that was running nice.

Then I began working on another project and upgraded my Flutter version to the last version

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Running flutter doctor...
Doctor summary (to see all details, run flutter doctor -v):
[âś“] Flutter (Channel stable, 3.0.2, on macOS 12.3.1 21E258 darwin-x64, locale en-GB)
[âś“] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[âś“] Xcode - develop for iOS and macOS (Xcode 13.3)
[âś“] Chrome - develop for the web
[âś“] Android Studio (version 2021.1)
[âś“] VS Code (version 1.68.0)
[âś“] Connected device (5 available)
[âś“] HTTP Host Availability

Today I needed to make some changes in the project from last week, and suddenly I find out that the project has errors on 5 files.

All errors are related to the package geocoder2.

As example here you have where the issue is:

 onSelected: (Place place) async {
                    FetchGeocoder fetchGeocoder =
                    await Geocoder2.getCoordinatesFromAddress(
                        address: place.description,
                        googleMapApiKey:
                        "A---");
                    var first = fetchGeocoder.results.first;

                    var lat = first.geometry.location.lat;
                    var lng = first.geometry.location.lng;
                    LatLng sitio = LatLng(lat, lng);

The error says Undefined class 'FetchGeocoder, which was there before without issues.

>Solution :

According to the package versions in pub.dev, the package started to rename FetchGeocoder to GeoData starting from version 1.0.4, here is a latest from the newest version in pub.dev:

GeoData data = await Geocoder2.getDataFromAddress(
    address: "277 Bedford Ave, Brooklyn, NY 11211, USA",
    googleMapApiKey: "GOOGLE_MAP_API_KEY",
);

//Formated Address
print(data.address);
//City Name
print(data.city);
//Country Name
print(data.country);
//Country Code
print(data.countryCode);
//Latitude
print(data.latitude);
//Longitude
print(data.longitude);
//Postal Code
print(data.postalCode);
//State
print(data.state);
//Street Number
print(data.street_number);

Note: This problem is a mistake from the package author because for the breaking and major changes the major version number should be changed and the documentation should contain a section for migration.

Because the author just changed the patch number in the version so it becomes 1.0.4 from 1.0.3 instead of being 2.0.0 and properly you are writing the version with ^ sign in pubspec.yaml, Flutter pulls the latest version before the new major version of the package automatically, and that’s what caused the problem for you without changing anything.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading