Skip to content

Commit

Permalink
[google_maps_flutter] Annotate deprecated member usage (#8214)
Browse files Browse the repository at this point in the history
There are several intentional uses of deprecated members from other packages within the plugin group, so annotate them so that they don't show up in the regular team audits:
- App-facing package integration tests of the deprecated style method.
- Handling of deprecated marker bitmap formats.

These turned up in the [routine repo audit](https://github.com/flutter/flutter/blob/main/docs/infra/Packages-Gardener-Rotation.md#deprecations).
  • Loading branch information
stuartmorgan authored Dec 4, 2024
1 parent 7496306 commit 67291a3
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ void runTests() {

const String mapStyle =
'[{"elementType":"geometry","stylers":[{"color":"#242f3e"}]}]';
// Intentionally testing the deprecated code path.
// ignore: deprecated_member_use
await controller.setMapStyle(mapStyle);
});

Expand All @@ -184,6 +186,8 @@ void runTests() {
final GoogleMapController controller = await controllerCompleter.future;

try {
// Intentionally testing the deprecated code path.
// ignore: deprecated_member_use
await controller.setMapStyle('invalid_value');
fail('expected MapStyleException');
} on MapStyleException catch (e) {
Expand All @@ -208,6 +212,8 @@ void runTests() {
);
final GoogleMapController controller = await controllerCompleter.future;

// Intentionally testing the deprecated code path.
// ignore: deprecated_member_use
await controller.setMapStyle(null);
});

Expand Down Expand Up @@ -471,6 +477,8 @@ void runTests() {
final Set<Marker> markers = <Marker>{
Marker(
markerId: const MarkerId('1'),
// Intentionally testing the deprecated code path.
// ignore: deprecated_member_use
icon: await BitmapDescriptor.fromAssetImage(
imageConfiguration,
'assets/red_square.png',
Expand All @@ -493,6 +501,8 @@ void runTests() {
final Set<Marker> markers = <Marker>{
Marker(
markerId: const MarkerId('1'),
// Intentionally testing the deprecated code path.
// ignore: deprecated_member_use
icon: BitmapDescriptor.fromBytes(
bytes,
size: const Size(100, 100),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1405,6 +1405,8 @@ void googleMapsTests() {
final Set<Marker> markers = <Marker>{
Marker(
markerId: const MarkerId('1'),
// Intentionally testing the deprecated code path.
// ignore: deprecated_member_use
icon: await BitmapDescriptor.fromAssetImage(
imageConfiguration,
'assets/red_square.png',
Expand All @@ -1427,6 +1429,8 @@ void googleMapsTests() {
final Set<Marker> markers = <Marker>{
Marker(
markerId: const MarkerId('1'),
// Intentionally testing the deprecated code path.
// ignore: deprecated_member_use
icon: BitmapDescriptor.fromBytes(
bytes,
size: const Size(100, 100),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,8 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform {
case final DefaultMarker marker:
return PlatformBitmap(
bitmap: PlatformBitmapDefaultMarker(hue: marker.hue?.toDouble()));
// Clients may still use this deprecated format, so it must be supported.
// ignore: deprecated_member_use
case final BytesBitmap bytes:
return PlatformBitmap(
bitmap: PlatformBitmapBytes(
Expand All @@ -895,6 +897,8 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform {
case final AssetBitmap asset:
return PlatformBitmap(
bitmap: PlatformBitmapAsset(name: asset.name, pkg: asset.package));
// Clients may still use this deprecated format, so it must be supported.
// ignore: deprecated_member_use
case final AssetImageBitmap asset:
return PlatformBitmap(
bitmap: PlatformBitmapAssetImage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,8 @@ void main() {
final Set<Marker> markers = <Marker>{
Marker(
markerId: const MarkerId('1'),
// Intentionally testing the deprecated code path.
// ignore: deprecated_member_use
icon: await BitmapDescriptor.fromAssetImage(
imageConfiguration,
'assets/red_square.png',
Expand All @@ -1268,6 +1270,8 @@ void main() {
testWidgets('markerWithLegacyBytes', (WidgetTester tester) async {
tester.view.devicePixelRatio = 2.0;
final Uint8List bytes = const Base64Decoder().convert(iconImageBase64);
// Intentionally testing the deprecated code path.
// ignore: deprecated_member_use
final BitmapDescriptor icon = BitmapDescriptor.fromBytes(
bytes,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,8 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform {
case final DefaultMarker marker:
return PlatformBitmap(
bitmap: PlatformBitmapDefaultMarker(hue: marker.hue?.toDouble()));
// Clients may still use this deprecated format, so it must be supported.
// ignore: deprecated_member_use
case final BytesBitmap bytes:
final Size? size = bytes.size;
return PlatformBitmap(
Expand All @@ -782,6 +784,8 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform {
case final AssetBitmap asset:
return PlatformBitmap(
bitmap: PlatformBitmapAsset(name: asset.name, pkg: asset.package));
// Clients may still use this deprecated format, so it must be supported.
// ignore: deprecated_member_use
case final AssetImageBitmap asset:
final Size? size = asset.size;
return PlatformBitmap(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,10 @@ class GoogleMapController {
/// own configuration and are rendered on top of a GMap instance later. This
/// happens in the second half of this method.
///
/// This method is eagerly called from the [GoogleMapsPlugin.buildView] method
/// so the internal [GoogleMapsController] of a Web Map initializes as soon as
/// possible. Check [_attachMapEvents] to see how this controller notifies the
/// This method is eagerly called from the
/// [GoogleMapsPlugin.buildViewWithConfiguration] method so the internal
/// [GoogleMapsController] of a Web Map initializes as soon as possible.
/// Check [_attachMapEvents] to see how this controller notifies the
/// plugin of it being fully ready (through the `onTilesloaded.first` event).
///
/// Failure to call this method would result in the GMap not rendering at all,
Expand Down

0 comments on commit 67291a3

Please sign in to comment.