Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/battery/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.1+5

* Fix pedantic linter errors.

## 0.3.1+4

* Update and migrate iOS example project.
Expand Down
11 changes: 0 additions & 11 deletions packages/battery/analysis_options.yaml

This file was deleted.

3 changes: 3 additions & 0 deletions packages/battery/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -63,6 +65,7 @@ class _MyHomePageState extends State<MyHomePage> {
child: const Icon(Icons.battery_unknown),
onPressed: () async {
final int batteryLevel = await _battery.batteryLevel;
// ignore: unawaited_futures
showDialog<void>(
context: context,
builder: (_) => AlertDialog(
Expand Down
16 changes: 15 additions & 1 deletion packages/battery/lib/battery.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,21 @@ import 'package:flutter/services.dart';
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 =
Expand All @@ -22,6 +34,8 @@ class Battery {
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);

Expand Down
2 changes: 1 addition & 1 deletion packages/battery/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for accessing information about the battery state
(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:
Expand Down