[battery] Fix pedantic linter errors (#2311)
diff --git a/packages/battery/CHANGELOG.md b/packages/battery/CHANGELOG.md
index 12a8300..5bd557a 100644
--- a/packages/battery/CHANGELOG.md
+++ b/packages/battery/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.3.1+5
+
+* Fix pedantic linter errors.
+
## 0.3.1+4
* Update and migrate iOS example project.
diff --git a/packages/battery/analysis_options.yaml b/packages/battery/analysis_options.yaml
deleted file mode 100644
index d4ccef6..0000000
--- a/packages/battery/analysis_options.yaml
+++ /dev/null
@@ -1,11 +0,0 @@
-# This is a temporary file to allow us to land a new set of linter rules in a
-# series of manageable patches instead of one gigantic PR. It disables some of
-# the new lints that are already failing on this plugin, for this plugin. It
-# should be deleted and the failing lints addressed as soon as possible.
-
-include: ../../analysis_options.yaml
-
-analyzer:
- errors:
- public_member_api_docs: ignore
- unawaited_futures: ignore
diff --git a/packages/battery/example/lib/main.dart b/packages/battery/example/lib/main.dart
index 0feaa05..1c1dfcf 100644
--- a/packages/battery/example/lib/main.dart
+++ b/packages/battery/example/lib/main.dart
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// ignore_for_file: public_member_api_docs
+
import 'dart:async';
import 'package:flutter/material.dart';
@@ -63,6 +65,7 @@
child: const Icon(Icons.battery_unknown),
onPressed: () async {
final int batteryLevel = await _battery.batteryLevel;
+ // ignore: unawaited_futures
showDialog<void>(
context: context,
builder: (_) => AlertDialog(
diff --git a/packages/battery/lib/battery.dart b/packages/battery/lib/battery.dart
index 96f470e..091b001 100644
--- a/packages/battery/lib/battery.dart
+++ b/packages/battery/lib/battery.dart
@@ -8,9 +8,21 @@
import 'package:meta/meta.dart' show visibleForTesting;
/// Indicates the current battery state.
-enum BatteryState { full, charging, discharging }
+enum BatteryState {
+ /// The battery is completely full of energy.
+ full,
+ /// The battery is currently storing energy.
+ charging,
+
+ /// The battery is currently losing energy.
+ discharging
+}
+
+/// API for accessing information about the battery of the device the Flutter
+/// app is currently running on.
class Battery {
+ /// Initializes the plugin and starts listening for potential platform events.
factory Battery() {
if (_instance == null) {
final MethodChannel methodChannel =
@@ -22,6 +34,8 @@
return _instance;
}
+ /// This constructor is only used for testing and shouldn't be accessed by
+ /// users of the plugin. It may break or change at any time.
@visibleForTesting
Battery.private(this._methodChannel, this._eventChannel);
diff --git a/packages/battery/pubspec.yaml b/packages/battery/pubspec.yaml
index 13f84ba..ae611bd 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.1+4
+version: 0.3.1+5
flutter:
plugin: