isLockScreen function

Future<bool?> isLockScreen()

Returns whether the device is likely on the lock screen.

Returns null when the platform plugin is not registered, the platform returns null, or the platform call fails. Use isLockScreenOrThrow when callers need to distinguish these failure modes.

Implementation

Future<bool?> isLockScreen() async {
  try {
    return await isLockScreenOrThrow();
  } catch (_) {
    return null;
  }
}