Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for the deprecation of BitmapDescriptor.fromBytes #11

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

LuisReyes98
Copy link

@LuisReyes98 LuisReyes98 commented Oct 7, 2024

As of google_maps_flutter_platform_interface: 2.8.0
The method BitmapDescriptor.fromBytes has been deprecated in favor of BitmapDescriptor.bytes and BytesMapBitmap.
The changes in this pull request include

  • The changes added in the example and the code focus on updating the package to flutter 3 and above
  • Updating the minimum dart SDK to 3.0
  • Replacing the use of BitmapDescriptor.bytes to BitmapDescriptor.fromBytes .
  • Updating the size of widgets on the example because the BitmapDescriptor.bytes solves a platform specific bug with the marker size , this fix in turn make the markers too big

Consideration for migration added on the README with the following text

Migrating to 1.0

The update to the google_maps_flutter_platform_interface: ^2.8.0 changes that, Deprecate BitmapDescriptor.fromBytes in favor of BitmapDescriptor.bytes and BytesMapBitmap.

This fixed a long standing bug where the markers size would change depending of the platform.

The workaround before used to be to multiply the devicePixelRatio to the width and height of the BitmapDescriptor.fromBytes to make the markers the same size across platforms and use the value of 1 for devicePixelRatio of web platform.

This would make code like this:

Before

WidgetMarker(
  position: cafePosition,
  markerId: 'cafe',
  widget: Container(
    color: Colors.brown,
    padding: const EdgeInsets.all(2),
    child: Icon(
      Icons.coffee,
      color: Colors.white,
      size: 14 * MediaQuery.of(context).devicePixelRatio,
    ),
  ),
)

Now this code will have to be changed to:

After

WidgetMarker(
  position: cafePosition,
  markerId: 'cafe',
  widget: Container(
    color: Colors.brown,
    padding: const EdgeInsets.all(2),
    child: const Icon(
      Icons.coffee,
      color: Colors.white,
      size: 14,
    ),
  ),
)

It is more straightforward and easier to maintain. This being the only consideration if you have been mainting a multiplatform app with this package, or google_maps_flutter in general.

@LuisReyes98
Copy link
Author

@santa112358

@LuisReyes98
Copy link
Author

Latest commit also adds all the new props that are available on GoogleMap to be directly available from WidgetMarkerGoogleMap
this props are:

    this.cloudMapId,
    this.webGestureHandling,
    this.style,
    this.clusterManagers = const <ClusterManager>{},
    this.fortyFiveDegreeImageryEnabled = false,
    this.heatmaps = const <Heatmap>{},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant