registerWithImage method

  1. @override
Future<void> registerWithImage({
  1. required String uri,
  2. required double width,
  3. required double height,
  4. Color? color = Colors.black,
  5. Alignment? alignment,
  6. double? top,
  7. double? left,
  8. double? bottom,
  9. double? right,
})
override

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

uri (required) uri of the image

width (required) width of the image

height (required) height of the image

alignment Alignment of the image, default Alignment.center

Throws a PlatformException if there were technical problems on native side

Implementation

@override
Future<void> registerWithImage({
  required String uri,
  required double width,
  required double height,
  Color? color = Colors.black,
  Alignment? alignment,
  double? top,
  double? left,
  double? bottom,
  double? right,
}) async {
  final colorHex =
      '#${color?.toARGB32().toRadixString(16).padLeft(8, '0').substring(2)}';
  final align = alignments.indexWhere(
    (element) => element == alignment,
  );
  await methodChannel
      .invokeMethod<void>('activateShieldWithImage', <String, dynamic>{
    'uri': uri,
    'width': width.toString(),
    'height': height.toString(),
    'alignment': align == -1 ? 4 : align,
    'top': top,
    'left': left,
    'bottom': bottom,
    'right': right,
    'color': colorHex,
  });
}