getBiometricType function

Future getBiometricType()

Determina el tipo de biometría disponible: 'Face ID' | 'Touch ID' | false

Implementation

Future<dynamic> getBiometricType() async {
  try {
    // En Android no existe Face ID/Touch ID como nombres formales; devolvemos 'Touch ID' por compatibilidad.
    if (Platform.isAndroid) return 'Touch ID';

    final bool hasHardware = await _localAuth.isDeviceSupported();
    if (!hasHardware) return false;

    final List<BiometricType> types = await _localAuth.getAvailableBiometrics();

    // Priorizar Face ID (face) si está presente.
    if (types.contains(BiometricType.face)) {
      return 'Face ID';
    }

    if (types.contains(BiometricType.fingerprint)) {
      return 'Touch ID';
    }

    // Otros tipos (iris, etc.) se tratan como no soportados en la API original.
    return false;
  } catch (e) {
    debugPrint('Error en getBiometricType: $e');
    return false;
  }
}