handleMethodCall method

Future handleMethodCall(
  1. MethodCall call
)

Implementation

Future<dynamic> handleMethodCall(MethodCall call) async {
  switch (call.method) {
    case 'isDebuggerDetected':
      return _isDebuggerDetected();
    case 'isRootDetected':
      return _isRootDetected();
    case 'isEmulatorDetected':
      return _isEmulatorDetected();
    case 'isFridaDetected':
      return _isFridaDetected();
    case 'isVpnDetected':
      return _isVpnDetected();
    case 'isScreenRecordingDetected':
      return false;
    case 'isDeveloperModeDetected':
      return _isDeveloperModeDetected();
    case 'isUsbDebuggingDetected':
      return _isUsbDebuggingDetected();
    case 'secureStorageWrite':
      final String key = call.arguments['key'] as String;
      final String value = call.arguments['value'] as String;
      final String algo = call.arguments['algorithm'] as String;
      final String size = call.arguments['keySize'] as String;
      html.window.localStorage['securely_${key}_${algo}_$size'] = value;
      return true;
    case 'secureStorageRead':
      final String key = call.arguments['key'] as String;
      final String algo = call.arguments['algorithm'] as String;
      final String size = call.arguments['keySize'] as String;
      return html.window.localStorage['securely_${key}_${algo}_$size'];
    case 'secureStorageDelete':
      final String key = call.arguments['key'] as String;
      final String algo = call.arguments['algorithm'] as String;
      final String size = call.arguments['keySize'] as String;
      html.window.localStorage.remove('securely_${key}_${algo}_$size');
      return true;
    case 'secureStorageContainsKey':
      final String key = call.arguments['key'] as String;
      final String algo = call.arguments['algorithm'] as String;
      final String size = call.arguments['keySize'] as String;
      return html.window.localStorage.containsKey('securely_${key}_${algo}_$size');
    case 'secureStorageClear':
      final keysToRemove = <String>[];
      html.window.localStorage.forEach((k, v) {
        if (k.startsWith('securely_')) {
          keysToRemove.add(k);
        }
      });
      for (final k in keysToRemove) {
        html.window.localStorage.remove(k);
      }
      return true;
    default:
      throw MissingPluginException();
  }
}