Skip to content

Instantly share code, notes, and snippets.

@Veenap
Created March 5, 2021 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Veenap/6e1effa564ebc1f7a68d7bca1ffd1a9a to your computer and use it in GitHub Desktop.
Save Veenap/6e1effa564ebc1f7a68d7bca1ffd1a9a to your computer and use it in GitHub Desktop.
// 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