Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: battery_plus_platform_interface misses enum case #2450

Closed
8 tasks done
felixwoestmann opened this issue Dec 12, 2023 · 2 comments · Fixed by #2451
Closed
8 tasks done

[Bug]: battery_plus_platform_interface misses enum case #2450

felixwoestmann opened this issue Dec 12, 2023 · 2 comments · Fixed by #2451
Assignees
Labels
bug Something isn't working

Comments

@felixwoestmann
Copy link

Platform

Android 12

Plugin

battery_plus

Version

v5.0.1

Flutter SDK

v3.16.2

Steps to reproduce

Use the battery_plus plugin on an Android Emulator with a neutral charging state.

The battery_plus plugin after being updated to version v5.0.1 now contains the charging state "not_charging". see. #2275

The corresponding platform interface (battery_plus_platform_interface) in its currrent version 2.0.0 is lacking this enum, leading to an ArgumentError.

File: utils.dart

BatteryState parseBatteryState(String state) {
  switch (state) {
    case 'full':
      return BatteryState.full;
    case 'charging':
      return BatteryState.charging;
    case 'discharging':
      return BatteryState.discharging;
    case 'connected_not_charging':
      return BatteryState.connectedNotCharging;
    case 'unknown':
      return BatteryState.unknown;
    default:
      throw ArgumentError('$state is not a valid BatteryState.');
  }
}

The initial commit contained the fix, this was however reverted by this commit: 78f44bf

Please release a hotfix.

Code Sample

No response

Logs

Invalid argument(s): not_charging is not a valid BatteryState.
I/flutter ( 3973): #0      parseBatteryState (package:battery_plus_platform_interface/src/utils.dart:17:7)
I/flutter ( 3973): #1      MethodChannelBattery.batteryState.<anonymous closure> (package:battery_plus_platform_interface/method_channel_battery_plus.dart:43:47)
I/flutter ( 3973): #2      _rootRunUnary (dart:async/zone.dart:1407:47)
I/flutter ( 3973): <asynchronous suspension>
I/flutter ( 3973): #3      BatteryIndicatorProvider._update (package:common/src/feature/battery/provider/battery_indicator_provider.dart:22:21)
I/flutter ( 3973): <asynchronous suspension>

Flutter Doctor

[✓] Flutter (Channel stable, 3.16.3, on macOS 14.0 23A344 darwin-arm64,
    locale en-DE)
    • Flutter version 3.16.3 on channel stable at
      /Users/felix/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b0366e0a3f (7 days ago), 2023-12-05 19:46:39
      -0800
    • Engine revision 54a7145303
    • Dart version 3.2.3
    • DevTools version 2.28.4

[✓] Android toolchain - develop for Android devices (Android SDK version
    34.0.0)
    • Android SDK at /Users/felix/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 15.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15A507
    ! iOS 17.0 Simulator not installed; this may be necessary for iOS and
      macOS development.
      To download and install the platform, open Xcode, select Xcode >
      Settings > Platforms,
      and click the GET button for the required platform.

      For more information, please visit:
        https://developer.apple.com/documentation/xcode/installing-additi
        onal-simulator-runtimes
    • CocoaPods version 1.13.0

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google
      Chrome

[✓] Android Studio (version 2023.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      17.0.7+0-17.0.7b1000.6-10550314)

[✓] IntelliJ IDEA Ultimate Edition (version 2020.3.3)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.85.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.78.0

[✓] Connected device (3 available)
    • Android SDK built for arm64 (mobile) • emulator-5554 •
      android-arm64  • Android 10 (API 29) (emulator)
    • macOS (desktop)                      • macos         • darwin-arm64
      • macOS 14.0 23A344 darwin-arm64
    • Chrome (web)                         • chrome        •
      web-javascript • Google Chrome 120.0.6099.71

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

Checklist before submitting a bug

  • I searched issues in this repository and couldn't find such bug/problem
  • I Google'd a solution and I couldn't find it
  • I searched on StackOverflow for a solution and I couldn't find it
  • I read the README.md file of the plugin
  • I'm using the latest version of the plugin
  • All dependencies are up to date with flutter pub upgrade
  • I did a flutter clean
  • I tried running the example project
@felixwoestmann felixwoestmann added bug Something isn't working triage labels Dec 12, 2023
@vbuberen
Copy link
Collaborator

Thanks for reporting. Indeed, there is an issue as not_charging wasn't a proper name that had to be changed to better explain what is the status about. I will release a fix shortly.

@vbuberen
Copy link
Collaborator

Released the fix for this issue in 5.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants