From 5eb20632e84ef6aa0bf7753a5275921b394ea3ce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 21:06:22 +0000 Subject: [PATCH 1/4] chore(deps): bump web in /packages/battery_plus/battery_plus Bumps [web](https://github.com/dart-lang/web) from 0.5.1 to 1.0.0. - [Release notes](https://github.com/dart-lang/web/releases) - [Changelog](https://github.com/dart-lang/web/blob/main/CHANGELOG.md) - [Commits](https://github.com/dart-lang/web/compare/v0.5.1...v1.0.0) --- updated-dependencies: - dependency-name: web dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- packages/battery_plus/battery_plus/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/battery_plus/battery_plus/pubspec.yaml b/packages/battery_plus/battery_plus/pubspec.yaml index 38ac71870d..4d467705c9 100644 --- a/packages/battery_plus/battery_plus/pubspec.yaml +++ b/packages/battery_plus/battery_plus/pubspec.yaml @@ -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: ">=0.5.0 <2.0.0" dev_dependencies: flutter_test: From 6fd7c7ba79222cb02c68ce4f8fc33e197447e192 Mon Sep 17 00:00:00 2001 From: Miguel Beltran Date: Wed, 7 Aug 2024 16:46:22 +0200 Subject: [PATCH 2/4] set web to ^1.0.0 --- packages/battery_plus/battery_plus/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/battery_plus/battery_plus/pubspec.yaml b/packages/battery_plus/battery_plus/pubspec.yaml index 4d467705c9..0a18fb04ef 100644 --- a/packages/battery_plus/battery_plus/pubspec.yaml +++ b/packages/battery_plus/battery_plus/pubspec.yaml @@ -34,7 +34,7 @@ dependencies: battery_plus_platform_interface: ^2.0.1 meta: ^1.8.0 upower: ^0.7.0 - web: ">=0.5.0 <2.0.0" + web: "^1.0.0" dev_dependencies: flutter_test: From f23da19b5c8e8a3447ca42b07c41564c88d0776e Mon Sep 17 00:00:00 2001 From: Miguel Beltran Date: Wed, 7 Aug 2024 16:47:53 +0200 Subject: [PATCH 3/4] cleanup web implementation --- .../lib/src/battery_plus_web.dart | 24 +++---------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/packages/battery_plus/battery_plus/lib/src/battery_plus_web.dart b/packages/battery_plus/battery_plus/lib/src/battery_plus_web.dart index 353227954d..0307f498c8 100644 --- a/packages/battery_plus/battery_plus/lib/src/battery_plus_web.dart +++ b/packages/battery_plus/battery_plus/lib/src/battery_plus_web.dart @@ -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. /// @@ -18,7 +18,7 @@ class BatteryPlusWebPlugin extends BatteryPlatform { /// Return [BatteryManager] if the BatteryManager API is supported by the User Agent. Future _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; @@ -80,7 +80,7 @@ class BatteryPlusWebPlugin extends BatteryPlatform { _checkBatteryChargingState(batteryManager.charging), ); - batteryManager.onchargingchange = (web.Event _) { + batteryManager.onchargingchange = (Event _) { _batteryChangeStreamController?.add( _checkBatteryChargingState(batteryManager.charging), ); @@ -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? 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); -} From c621215018ef5d03bb70ab69cb549dd66d67aef6 Mon Sep 17 00:00:00 2001 From: Miguel Beltran Date: Wed, 7 Aug 2024 16:53:37 +0200 Subject: [PATCH 4/4] remove quotes --- packages/battery_plus/battery_plus/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/battery_plus/battery_plus/pubspec.yaml b/packages/battery_plus/battery_plus/pubspec.yaml index 0a18fb04ef..2c90f51e9d 100644 --- a/packages/battery_plus/battery_plus/pubspec.yaml +++ b/packages/battery_plus/battery_plus/pubspec.yaml @@ -34,7 +34,7 @@ dependencies: battery_plus_platform_interface: ^2.0.1 meta: ^1.8.0 upower: ^0.7.0 - web: "^1.0.0" + web: ^1.0.0 dev_dependencies: flutter_test: