setScreenProtection method

  1. @override
Future<bool> setScreenProtection(
  1. ScreenProtectionOptions? options
)
override

Applies options to the app's window, or removes the protections when it is null. Returns false when nothing could be applied yet (Android without a resumed activity; it is applied as soon as one is attached) or when the platform has no such protection.

Implementation

@override
Future<bool> setScreenProtection(ScreenProtectionOptions? options) async {
  final applied = await methodChannel.invokeMethod<bool>(
    'setScreenProtection',
    (options ??
            const ScreenProtectionOptions(
              secureWindow: false,
              filterObscuredTouches: false,
              hideOverlayWindows: false,
            ))
        .toMap(),
  );
  return applied ?? false;
}