Skip to content

Commit

Permalink
chore(deps): bump web from 0.5.1 to 1.0.0 in /packages/battery_plus/b…
Browse files Browse the repository at this point in the history
…attery_plus (#3103)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Miguel Beltran <[email protected]>
  • Loading branch information
dependabot[bot] and miquelbeltran authored Aug 9, 2024
1 parent 1f23910 commit cf534ee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
24 changes: 3 additions & 21 deletions packages/battery_plus/battery_plus/lib/src/battery_plus_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'dart:js_interop';

import 'package:battery_plus_platform_interface/battery_plus_platform_interface.dart';
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
import 'package:web/web.dart' as web;
import 'package:web/web.dart';

/// The web implementation of the BatteryPlatform of the Battery plugin.
///
Expand All @@ -18,7 +18,7 @@ class BatteryPlusWebPlugin extends BatteryPlatform {
/// Return [BatteryManager] if the BatteryManager API is supported by the User Agent.
Future<BatteryManager?> _getBatteryManager() async {
try {
return await web.window.navigator.getBattery()?.toDart;
return await window.navigator.getBattery().toDart;
} on NoSuchMethodError catch (_) {
// BatteryManager API is not supported this User Agent.
return null;
Expand Down Expand Up @@ -80,7 +80,7 @@ class BatteryPlusWebPlugin extends BatteryPlatform {
_checkBatteryChargingState(batteryManager.charging),
);

batteryManager.onchargingchange = (web.Event _) {
batteryManager.onchargingchange = (Event _) {
_batteryChangeStreamController?.add(
_checkBatteryChargingState(batteryManager.charging),
);
Expand All @@ -105,21 +105,3 @@ class BatteryPlusWebPlugin extends BatteryPlatform {
}
}
}

extension on web.Navigator {
/// https://developer.mozilla.org/en-US/docs/Web/API/Navigator/getBattery
external JSPromise<BatteryManager>? getBattery();
}

/// BatteryManager API
/// https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager
extension type BatteryManager(JSObject _) implements JSObject {
/// https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager/level
external double get level;

/// https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager/charging
external bool get charging;

/// https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager/chargingchange_event
external set onchargingchange(JSFunction fn);
}
2 changes: 1 addition & 1 deletion packages/battery_plus/battery_plus/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencies:
battery_plus_platform_interface: ^2.0.1
meta: ^1.8.0
upower: ^0.7.0
web: ^0.5.0
web: ^1.0.0

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit cf534ee

Please sign in to comment.