register method

  1. @override
Future<void> register({
  1. required Color color,
  2. Duration? timeAfterResume,
})
override

activate a screenshot blocking with a color effect view (iOS 13+, Android 8+) color color of the background

timeAfterResume (Android only) Time delayed for the view to stop displaying when going back to the application (in milliseconds). Default = 1000ms

function will throw warning when timeAfterResume bigger than 3000ms, users have to wait for the application to turn off the filter before going back to the main view, which is a very bad user experiences.

Throws a PlatformException if there were technical problems on native side (e.g. lack of relevant hardware).

Implementation

@override
Future<void> register({
  required Color color,
  Duration? timeAfterResume,
}) async {
  final colorHex =
      '#${color.value.toRadixString(16).padLeft(8, '0').substring(2)}';
  await methodChannel.invokeMethod<void>('register', <String, dynamic>{
    'color': colorHex,
    'timeAfterResume': (timeAfterResume ?? const Duration(milliseconds: 1000))
        .inMilliseconds,
  });
}