[Battery]add type params for invokeMethod calls. (#1412)
Bump min flutter version to 1.2.0.
Add template type parameter for invokeMethod calls.
Updated invokeMethod and invokeMethod to using invokeListMethod and invokeMapMethod if any.
diff --git a/packages/battery/CHANGELOG.md b/packages/battery/CHANGELOG.md
index abb56c5..d70b0d6 100644
--- a/packages/battery/CHANGELOG.md
+++ b/packages/battery/CHANGELOG.md
@@ -1,3 +1,8 @@
+## 0.3.0+2
+
+* Bump the minimum Flutter version to 1.2.0.
+* Add template type parameter to `invokeMethod` calls.
+
## 0.3.0+1
* Log a more detailed warning at build time about the previous AndroidX
diff --git a/packages/battery/lib/battery.dart b/packages/battery/lib/battery.dart
index 2a0cf2f..96f470e 100644
--- a/packages/battery/lib/battery.dart
+++ b/packages/battery/lib/battery.dart
@@ -33,10 +33,7 @@
/// Returns the current battery level in percent.
Future<int> get batteryLevel => _methodChannel
- // TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
- // https://github.com/flutter/flutter/issues/26431
- // ignore: strong_mode_implicit_dynamic_method
- .invokeMethod('getBatteryLevel')
+ .invokeMethod<int>('getBatteryLevel')
.then<int>((dynamic result) => result);
/// Fires whenever the battery state changes.
diff --git a/packages/battery/pubspec.yaml b/packages/battery/pubspec.yaml
index 51b4d5a..6d9af34 100644
--- a/packages/battery/pubspec.yaml
+++ b/packages/battery/pubspec.yaml
@@ -3,7 +3,7 @@
(full, charging, discharging) on Android and iOS.
author: Flutter Team <flutter-dev@googlegroups.com>
homepage: https://github.com/flutter/plugins/tree/master/packages/battery
-version: 0.3.0+1
+version: 0.3.0+2
flutter:
plugin:
@@ -25,4 +25,4 @@
environment:
sdk: ">=2.0.0-dev.28.0 <3.0.0"
- flutter: ">=0.1.4 <2.0.0"
+ flutter: ">=1.2.0 <2.0.0"
diff --git a/packages/battery/test/battery_test.dart b/packages/battery/test/battery_test.dart
index c16bf7f..93d6960 100644
--- a/packages/battery/test/battery_test.dart
+++ b/packages/battery/test/battery_test.dart
@@ -22,10 +22,7 @@
});
test('batteryLevel', () async {
- // TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
- // https://github.com/flutter/flutter/issues/26431
- // ignore: strong_mode_implicit_dynamic_method
- when(methodChannel.invokeMethod('getBatteryLevel'))
+ when(methodChannel.invokeMethod<int>('getBatteryLevel'))
.thenAnswer((Invocation invoke) => Future<int>.value(42));
expect(await battery.batteryLevel, 42);
});