flutter_eco_mode
A Flutter plugin to help implementing custom eco-friendly mode in your mobile app.
According to our recommendations, the plugin determine if a device is:
- a low-end device
- in a battery eco mode
It will also give you your own rules for your app.
This plugin is still in reflexion and development. And will only be available for Android and iOS at the moment.
Next this plugin will have the objective to propose solutions to deactivate functionalities of the device to save energy. For example, disable animations or other nonessential resourceful operations...
Why this plugin?
We are developing this plugin, to perhaps implementing it on the SNCF Connect application, and offering an eco-friendly app to our users who have low-end devices to allow them to save the resources of their phone. And also to offer a less energy-consuming app.
Features
Feature | Android | iOS | Runtime | Event |
---|---|---|---|---|
Platform Info | Yes | Yes | X | |
Processor Count | Yes | Yes | X | |
Total Memory | Yes | Yes | X | |
Free Memory | Yes | Yes | X | |
Total Storage | Yes | Yes | X | |
Free Storage | Yes | Yes | X | |
Device Range | Yes | Yes | X | X |
Battery Thermal State | Yes | Yes | X | |
Battery State | Yes | Yes | X | X |
Battery Level | Yes | Yes | X | X |
Battery In Low Power Mode | Yes | Yes | X | X |
Battery Eco Mode | Yes | Yes | X | X |
Eco Mode
Device Range
This feature gives the possibility to calculate a score for the device. The score does NOT represent an ecological performance. It's just a score to determine the device's capacities. It is calculated by combining static information about the device on different OS. It will return a double between 0 and 1.
Then we can determine the device Eco Range:
- High End
- Mid Range
- Low End
Low-end devices means devices with poor capacities or poor features, usually old devices or low-cost devices.
And finally, you can use the last boolean information isLowEndDevice to directly know if your device is a low-end device or not.
Not really convinced by the Eco Range?
That's why we give you the possibility to calculate your own score by using others features in the plugin. If you have more than three eco ranges in your custom eco-mode, feel free to give the best user eco experience to your final users :)
Battery Eco Mode
This feature combines different battery information to determine if the device is in eco-mode or not. It will return a boolean.
@override
Stream<bool?> get isBatteryEcoModeStream => CombineLatestStream.list([
_isNotEnoughBatteryStream(),
lowPowerModeEventStream.withInitialValue(isBatteryInLowPowerMode()),
]).map((event) => event.any((element) => element)).asBroadcastStream();
Stream<bool> _isNotEnoughBatteryStream() => CombineLatestStream.list([
batteryLevelEventStream.map((event) => event.isNotEnough),
batteryStateEventStream.map((event) => event.isDischarging),
]).map((event) => event.every((element) => element)).asBroadcastStream();
Example
See the example
directory for a complete sample app using flutter_eco_mode.
Contribution
We are open to any contributions or suggestions. If you have any questions, please contact us.
License
Copyright © 2024 SNCF Connect & Tech. This project is licensed under the MIT License - see the LICENSE file for details.
This file has been written on February 22, 2024.