Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit af86b9d

Browse files
[package_info] [location_background] Fix remaining Android compiler warnings (#1884)
* Fix Android compiler warnings * Fix deprecation warnings for location plugin * Specify min Flutter SDK
1 parent a0acfa7 commit af86b9d

File tree

6 files changed

+17
-18
lines changed

6 files changed

+17
-18
lines changed

packages/location_background/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.1.0+2
2+
3+
* Fix Dart deprecation warnings.
4+
15
## 0.1.0+1
26

37
* Log a more detailed warning at build time about the previous AndroidX

packages/location_background/lib/location_background_plugin.dart

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,8 @@ class LocationBackgroundPlugin {
117117
final CallbackHandle handle =
118118
PluginUtilities.getCallbackHandle(_backgroundCallbackDispatcher);
119119
assert(handle != null, 'Unable to lookup callback.');
120-
_channel
121-
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
122-
// https://github.com/flutter/flutter/issues/26431
123-
// ignore: strong_mode_implicit_dynamic_method
124-
.invokeMethod(_kStartHeadlessService, <dynamic>[handle.toRawHandle()]);
120+
_channel.invokeMethod<void>(
121+
_kStartHeadlessService, <dynamic>[handle.toRawHandle()]);
125122
}
126123

127124
// The method channel we'll use to communicate with the native portion of our
@@ -147,10 +144,7 @@ class LocationBackgroundPlugin {
147144
throw ArgumentError.notNull('callback');
148145
}
149146
final CallbackHandle handle = PluginUtilities.getCallbackHandle(callback);
150-
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
151-
// https://github.com/flutter/flutter/issues/26431
152-
// ignore: strong_mode_implicit_dynamic_method
153-
return _channel.invokeMethod(_kMonitorLocationChanges, <dynamic>[
147+
return _channel.invokeMethod<bool>(_kMonitorLocationChanges, <dynamic>[
154148
handle.toRawHandle(),
155149
pauseLocationUpdatesAutomatically,
156150
showsBackgroundLocationIndicator,
@@ -160,8 +154,5 @@ class LocationBackgroundPlugin {
160154

161155
/// Stop all location updates.
162156
Future<void> cancelLocationUpdates() =>
163-
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
164-
// https://github.com/flutter/flutter/issues/26431
165-
// ignore: strong_mode_implicit_dynamic_method
166-
_channel.invokeMethod(_kCancelLocationUpdates);
157+
_channel.invokeMethod<void>(_kCancelLocationUpdates);
167158
}

packages/location_background/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: location_background_plugin
22
description: A new flutter plugin project.
33
author: Flutter Team <[email protected]>
44
homepage: https://github.com/flutter/plugins/tree/master/packages/location_background
5-
version: 0.1.0+1
5+
version: 0.1.0+2
66
publish_to: none
77

88
dependencies:
@@ -20,4 +20,4 @@ flutter:
2020

2121
environment:
2222
sdk: ">=2.0.0-dev.28.0 <3.0.0"
23-
flutter: ">=0.4.4 <2.0.0"
23+
flutter: ">=1.5.0 <2.0.0"

packages/package_info/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.4.0+6
2+
3+
* Fix Android compiler warnings.
4+
15
## 0.4.0+5
26

37
* Add iOS-specific warning to README.md.

packages/package_info/android/src/main/java/io/flutter/plugins/packageinfo/PackageInfoPlugin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void onMethodCall(MethodCall call, Result result) {
3939
PackageManager pm = context.getPackageManager();
4040
PackageInfo info = pm.getPackageInfo(context.getPackageName(), 0);
4141

42-
Map<String, String> map = new HashMap<String, String>();
42+
Map<String, String> map = new HashMap<>();
4343
map.put("appName", info.applicationInfo.loadLabel(pm).toString());
4444
map.put("packageName", context.getPackageName());
4545
map.put("version", info.versionName);
@@ -54,11 +54,11 @@ public void onMethodCall(MethodCall call, Result result) {
5454
}
5555
}
5656

57+
@SuppressWarnings("deprecation")
5758
private static long getLongVersionCode(PackageInfo info) {
5859
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
5960
return info.getLongVersionCode();
6061
}
61-
//noinspection deprecation
6262
return info.versionCode;
6363
}
6464
}

packages/package_info/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Flutter plugin for querying information about the application
33
package, such as CFBundleVersion on iOS or versionCode on Android.
44
author: Flutter Team <[email protected]>
55
homepage: https://github.com/flutter/plugins/tree/master/packages/package_info
6-
version: 0.4.0+5
6+
version: 0.4.0+6
77

88
flutter:
99
plugin:

0 commit comments

Comments
 (0)