getUsagePermission static method

Future<String> getUsagePermission()

Requests Usage Stats permission from the user. This will open the system settings screen for the user to grant access. Returns "granted" if permission is already enabled, or "need_permission" if the settings screen was opened.

Implementation

static Future<String> getUsagePermission() async {
  try {
    final result = await _channel.invokeMethod<String>('getUsagePermission');
    return result ?? "unknown";
  } on PlatformException catch (e) {
    throw Exception('Failed to get usage permission: ${e.message}');
  }
}