feat(battery_plus)!: Migrate to package:web#2720
Conversation
6328531 to
5b279c0
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
Please check the pinned issue: #2653 |
|
I am working on a strange problem. In the case of bool get isSupported {
try {
web.window.navigator.getBattery();
return true;
} on NoSuchMethodError catch (_) {
// flutter run mode, catch the exception
return false;
}
}However, if we have a @override
void initState() {
super.initState();
try {
_battery.batteryState.then(_updateBatteryState);
_batteryStateSubscription =
_battery.onBatteryStateChanged.listen(_updateBatteryState);
} catch (_) {
// flutter build mode, catch the exception
}
} |
5b279c0 to
11b4449
Compare
|
Tested on local server, no problems. Therefore, I believe the problem is caused by hosting on GitHub Pages. I'll update the code base and update the demo. And after adding comments (just in case), I will open the PR! |
11b4449 to
ce96ad3
Compare
ce96ad3 to
8811f9b
Compare
|
Another option is to add a method that determines the browser and returns true only for chrome or edge. |
|
Thank you Koji! This is already a big leap forward. We are going to be merging it for now, and our plan is to release all packages by Thursday, we are just waiting for another PR to land. |
Description
Migration to the
webpackage and add missing API.https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager#browser_compatibility
BatteryManager API is only supported Chrome or Edge.
Safari and Firefox are not supported, so status is expected to be unknown.
Related Issues
Checklist
CHANGELOG.mdnor the plugin version inpubspec.yamlfiles.flutter analyze) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?
!in the title as explained in Conventional Commits).