Home > Net >  Issues after Flutter upgrade
Issues after Flutter upgrade

Time:06-15

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

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.

CodePudding user response:

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.

  • Related