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

[google_maps_flutter_platform_interface] Convert BitmapDescriptor to typesafe subclasses #7699

Merged
merged 15 commits into from
Oct 4, 2024
Prev Previous commit
Next Next commit
Convet AssetMapBitmap
  • Loading branch information
yaakovschectman committed Oct 4, 2024
commit a7ccb6ba0c03dc2531c2eaab5a54b781c7493928
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ enum MapBitmapScaling {
none,
}

MapBitmapScaling mapBitmapScalingFromString(String mode) => switch (mode) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be private so we're not increasing the API surface of the package.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My preference would be visible for testing and keep the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be my thought as well, @stuartmorgan do you agree with this decision?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's fine; from a semver standpoint we consider those equivalent.

'auto' => MapBitmapScaling.auto,
'none' => MapBitmapScaling.none,
_ => throw ArgumentError('Unrecognized MapBitmapScaling $mode', 'mode'),
};

// The default pixel ratio for custom bitmaps.
const double _naturalPixelRatio = 1.0;

Expand Down Expand Up @@ -104,6 +110,9 @@ class BitmapDescriptor {
assert(jsonMap['imagePixelRatio'] is double);
assert(!jsonMap.containsKey('width') || jsonMap['width'] is double);
assert(!jsonMap.containsKey('height') || jsonMap['height'] is double);
final double? width = jsonMap.containsKey('width') ? jsonMap['width'] as double : null;
final double? height = jsonMap.containsKey('height') ? jsonMap['height'] as double : null;
return AssetMapBitmap(jsonMap['assetName'] as String, bitmapScaling: mapBitmapScalingFromString(jsonMap['bitmapScaling'] as String), imagePixelRatio: jsonMap['imagePixelRatio'] as double, width: width, height: height);
case BytesMapBitmap.type:
assert(jsonList.length == 2);
assert(jsonList[1] != null && jsonList[1] is Map<String, dynamic>);
Expand Down