Guest User

Untitled

a guest
Dec 12th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. //From Flutter
  2. Future<String> _getBatteryLevel() async {
  3. String batteryLevel;
  4. try {
  5. //invoke the platform specific code
  6. //wait for the result
  7. final int result = await platform.invokeMethod('getBatteryLevel');
  8. batteryLevel = 'Battery level at $result % .';
  9. } on PlatformException catch (e) {
  10. batteryLevel = "Failed to get battery level: '${e.message}'.";
  11. }
  12.  
  13. return batteryLevel;
  14. }
Add Comment
Please, Sign In to add comment