flutterEngine

dartExecutor

binaryMessenger

CHANNEL

).

setMethodCallHandler

// This method is invoked on the main thread.

call

result

>

if

call

method

==

"getBatteryLevel"

val

batteryLevel

getBatteryLevel

()

if

batteryLevel

!=

result

success

batteryLevel

else

result

error

"UNAVAILABLE"

"Battery level not available."

null

else

result

notImplemented