requestIgnoreBatteryOptimizations method

  1. @override
Future<bool> requestIgnoreBatteryOptimizations()
override

Prompts the user with the system dialog to exempt the app from battery optimizations. Returns true if the app was already exempt (no dialog shown); returns false when the dialog was launched — the user's choice isn't observable, so re-check with isIgnoringBatteryOptimizations.

Implementation

@override
Future<bool> requestIgnoreBatteryOptimizations() async {
  return await _channel.invokeMethod<bool>('requestIgnoreBatteryOptimizations') ?? false;
}