-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[google_maps_flutter] Android Code Inspection and Clean up #3112
[google_maps_flutter] Android Code Inspection and Clean up #3112
Conversation
| import com.google.android.gms.maps.model.LatLngBounds; | ||
| import io.flutter.plugin.common.BinaryMessenger; | ||
| import io.flutter.plugin.common.PluginRegistry; | ||
| import io.flutter.plugin.common.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use specific imports, avoid *
| import io.flutter.plugin.common.MethodCall; | ||
| import io.flutter.plugin.common.MethodChannel; | ||
| import io.flutter.plugin.common.PluginRegistry; | ||
| import io.flutter.plugin.common.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i have this warning if i just import PluginRegistry :
warning: [deprecation] PluginRegistry in io.flutter.plugin.common has been deprecated
import io.flutter.plugin.common.PluginRegistry;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dnfield i fixed using io.flutter.plugin.common.PluginRegistry.Registrar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, you can't import deprecated classes. You have to use it by the fully qualified name and add the lint ignore statement on the same line.
| Application application, | ||
| Lifecycle lifecycle, | ||
| PluginRegistry.Registrar registrar, | ||
| @SuppressWarnings("deprecation") io.flutter.plugin.common.PluginRegistry.Registrar registrar, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dnfield it's fixed
xster
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API dedeprecation usage LGTM
| if (data.size() == 2) { | ||
| return BitmapDescriptorFactory.fromAsset( | ||
| FlutterMain.getLookupKeyForAsset(toString(data.get(1)))); | ||
| FlutterInjector.instance() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, just keep a local reference to the flutter loader to keep it shorter
| class Convert { | ||
|
|
||
| private static BitmapDescriptor toBitmapDescriptor(Object o) { | ||
| final FlutterLoader flutterLoader = FlutterInjector.instance().flutterLoader(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably isn't present on stable, or if it is, we have to increase the minimum version Flutter SDK constraint most likelyt o capture it. /cc @xster
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also consider whether we just ignore a depprecation warning for this or not - xster will have more context there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
phew, glad you caught me. Forgot about targeting stable. We should indeed leave an ignore like https://github.com/flutter/plugins/pull/3072/files#diff-e57a1a7ffb729ad174b597626202429c1c87e4168e19b2aa9decc1be84e8777bR56 with a TODO to remove when the next stable ships. For now we have to use the old APIs.
dnfield
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to figure out the Flutter SDK constraint or used deprecated API
| class Convert { | ||
|
|
||
| private static BitmapDescriptor toBitmapDescriptor(Object o) { | ||
| final FlutterLoader flutterLoader = FlutterInjector.instance().flutterLoader(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also consider whether we just ignore a depprecation warning for this or not - xster will have more context there.
dnfield
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM modulo filing an issue for the TODO
| class Convert { | ||
|
|
||
| // TODO(hamdikahloun): FlutterMain has been deprecated and should be replaced with FlutterLoader | ||
| // when it's available in Stable channel. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please file an issue if there isn't one already and link it here.
) * Android Code Inspection and Clean up * Android Code Inspection and Clean up * Android Code Inspection and Clean up * Android Code Inspection and Clean up * Android Code Inspection and Clean up * Android Code Inspection and Clean up * Import PluginRegistry * Import PluginRegistry * Update GoogleMapController.java * google_maps_flutter * Update build.gradle * Update Convert.java * Update Convert.java Add TODO comment * Update Convert.java
) * Android Code Inspection and Clean up * Android Code Inspection and Clean up * Android Code Inspection and Clean up * Android Code Inspection and Clean up * Android Code Inspection and Clean up * Android Code Inspection and Clean up * Import PluginRegistry * Import PluginRegistry * Update GoogleMapController.java * google_maps_flutter * Update build.gradle * Update Convert.java * Update Convert.java Add TODO comment * Update Convert.java
Description
Handle deprecation & unchecked warning as error
Avoiding uses or overrides a deprecated API
Related Issues
flutter/flutter#65970
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?