Created
March 5, 2021 14:33
-
-
Save Veenap/6e1effa564ebc1f7a68d7bca1ffd1a9a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get battery level. | |
static Future<String> getBatteryLevel() async { | |
String batteryLevel; | |
try { | |
final int result = await _channel.invokeMethod('getBatteryLevel'); | |
batteryLevel = 'Battery level: $result%.'; | |
} on PlatformException { | |
batteryLevel = 'Failed to get battery level.'; | |
} | |
return batteryLevel; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment