import

android.os.Bundle

Then add the following as a new method in the activity class,
below the configureFlutterEngine() method:

private

int

getBatteryLevel

()

int

batteryLevel

if

VERSION

SDK_INT

>=

VERSION_CODES

LOLLIPOP

BatteryManager

batteryManager

BatteryManager

getSystemService

BATTERY_SERVICE

);

batteryLevel

batteryManager

getIntProperty

BatteryManager

BATTERY_PROPERTY_CAPACITY

);

else

Intent