From 3f80a620c54bcd157bba1b2b098d7e5980c79d9d Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 3 Dec 2024 12:35:37 -0500 Subject: [PATCH] [google_maps_flutter] Annotate deprecated member usage 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. --- .../example/integration_test/src/maps_controller.dart | 10 ++++++++++ .../example/integration_test/google_maps_tests.dart | 4 ++++ .../lib/src/google_maps_flutter_android.dart | 4 ++++ .../ios14/integration_test/google_maps_test.dart | 4 ++++ .../lib/src/google_maps_flutter_ios.dart | 4 ++++ .../lib/src/google_maps_controller.dart | 7 ++++--- 6 files changed, 30 insertions(+), 3 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter/example/integration_test/src/maps_controller.dart b/packages/google_maps_flutter/google_maps_flutter/example/integration_test/src/maps_controller.dart index 2ab5ffccccb..536adc32f07 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/integration_test/src/maps_controller.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/integration_test/src/maps_controller.dart @@ -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); }); @@ -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) { @@ -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); }); @@ -471,6 +477,8 @@ void runTests() { final Set markers = { Marker( markerId: const MarkerId('1'), + // Intentionally testing the deprecated code path. + // ignore: deprecated_member_use icon: await BitmapDescriptor.fromAssetImage( imageConfiguration, 'assets/red_square.png', @@ -493,6 +501,8 @@ void runTests() { final Set markers = { Marker( markerId: const MarkerId('1'), + // Intentionally testing the deprecated code path. + // ignore: deprecated_member_use icon: BitmapDescriptor.fromBytes( bytes, size: const Size(100, 100), diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/integration_test/google_maps_tests.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/integration_test/google_maps_tests.dart index 277010adfeb..666b4855581 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/integration_test/google_maps_tests.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/integration_test/google_maps_tests.dart @@ -1405,6 +1405,8 @@ void googleMapsTests() { final Set markers = { Marker( markerId: const MarkerId('1'), + // Intentionally testing the deprecated code path. + // ignore: deprecated_member_use icon: await BitmapDescriptor.fromAssetImage( imageConfiguration, 'assets/red_square.png', @@ -1427,6 +1429,8 @@ void googleMapsTests() { final Set markers = { Marker( markerId: const MarkerId('1'), + // Intentionally testing the deprecated code path. + // ignore: deprecated_member_use icon: BitmapDescriptor.fromBytes( bytes, size: const Size(100, 100), diff --git a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart index 038d5fe16d4..dd19bed8646 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart @@ -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( @@ -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( diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/integration_test/google_maps_test.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/integration_test/google_maps_test.dart index d3ea025d99c..e2b5941d261 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/integration_test/google_maps_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/integration_test/google_maps_test.dart @@ -1245,6 +1245,8 @@ void main() { final Set markers = { Marker( markerId: const MarkerId('1'), + // Intentionally testing the deprecated code path. + // ignore: deprecated_member_use icon: await BitmapDescriptor.fromAssetImage( imageConfiguration, 'assets/red_square.png', @@ -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, ); diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/google_maps_flutter_ios.dart b/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/google_maps_flutter_ios.dart index ba56b6170fd..89c6b90ddc6 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/google_maps_flutter_ios.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/google_maps_flutter_ios.dart @@ -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( @@ -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( diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart index 89f5e33e238..cbc12bf562f 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart @@ -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,