initialize static method

Future<void> initialize({
  1. bool maskAllTexts = false,
  2. List<String>? textsToMask,
})

Implementation

static Future<void> initialize({bool maskAllTexts = false, List<String>? textsToMask}) async {
  _maskAllTexts = maskAllTexts;
  _textsToMask = textsToMask?.expand((p) {
    if (p.trim().isEmpty) return <RegExp>[];
    try {
      return [RegExp(p)];
    } on FormatException {
      return <RegExp>[];
    }
  }).toList() ?? [];
  methodChannel.setMethodCallHandler((call) async {
    switch (call.method) {
      case 'getMaskRegions':
        final ids = (call.arguments as List).cast<String>();
        return _getMaskRegions(ids);
      default:
        throw PlatformException(
          code: 'unimplemented',
          message: 'Method ${call.method} not implemented',
        );
    }
  });

  if (Platform.isAndroid && (maskAllTexts || _textsToMask.isNotEmpty)) {
    await _registerSentinel();
  }
}