encrypt static method

Future<BiometricResult> encrypt({
  1. required String biometricKey,
  2. required String message,
  3. String messageKey = '',
  4. String title = 'Biometric Authentication',
  5. String subtitle = 'Enter biometric credentials to proceed',
  6. String description = '',
  7. String negativeButtonText = 'CANCEL',
  8. bool confirmationRequired = false,
  9. bool deviceCredentialAllowed = false,
})

Encrypt message using biometric.

Implementation

static Future<BiometricResult> encrypt({
  required String biometricKey,
  required String message,
  String messageKey = '',
  String title = 'Biometric Authentication',
  String subtitle = 'Enter biometric credentials to proceed',
  String description = '',
  String negativeButtonText = 'CANCEL',
  bool confirmationRequired = false,
  bool deviceCredentialAllowed = false,
}) async {
  try {
    final resultKey = await _channel.invokeMethod('encrypt', {
      'biometric_key': biometricKey,
      'message_key': messageKey,
      'message': message,
      'title': title,
      'subtitle': subtitle,
      'description': description,
      'negative_button_text': negativeButtonText,
      'confirmation_required': confirmationRequired,
      'device_credential_allowed': deviceCredentialAllowed,
    });

    if (resultKey is String) {
      return BiometricResult(
        status: BiometricStatus.SUCCESS,
        data: resultKey,
      );
    } else {
      final bmType = await type;

      return BiometricResult(
        status: BiometricStatus.FAILED,
        type: bmType,
      );
    }
  } on Exception {
    return BiometricResult(status: BiometricStatus.CANCELED);
  }
}