flutter_biometric_auth_plus 0.0.2 copy "flutter_biometric_auth_plus: ^0.0.2" to clipboard
flutter_biometric_auth_plus: ^0.0.2 copied to clipboard

Enhanced biometric authentication with fallback options and better error handling for Flutter applications.

Flutter Biometric Auth Plus #

Pub Version License Platform Support WASM Compatible

Enhanced biometric authentication with fallback options and better error handling for Flutter applications. Now with full platform support and custom implementation!

๐Ÿš€ What's New in v0.0.2 #

  • โœ… Complete rewrite: Removed dependency on local_auth package
  • โœ… Custom implementation: Platform-specific native code for each platform
  • โœ… Full platform support: All 6 platforms (iOS, Android, Web, Windows, macOS, Linux)
  • โœ… WASM compatibility: Fully compatible with web/WASM runtime
  • โœ… Perfect score: 160/160 points in Pana analysis

๐ŸŒŸ Features #

  • ๐Ÿ” Multi-platform biometric authentication
  • ๐Ÿ“ฑ Platform-specific native implementations
  • ๐ŸŒ Web/WASM compatibility
  • ๐Ÿ”„ Automatic fallback mechanisms
  • โšก Enhanced error handling
  • ๐ŸŽฏ Type-safe API design
  • ๐Ÿ“š Comprehensive documentation

๐Ÿ“ฑ Platform Support #

Platform Status Implementation
Android โœ… Full Support BiometricManager + BiometricPrompt
iOS โœ… Full Support LocalAuthentication framework
Web โœ… Full Support WebAuthn API + WASM
Windows โœ… Full Support Windows Hello APIs
macOS โœ… Full Support LocalAuthentication framework
Linux โœ… Full Support PAM + biometric daemons

๐Ÿš€ Quick Start #

1. Add Dependency #

dependencies:
  flutter_biometric_auth_plus: ^0.0.2

2. Import Package #

import 'package:flutter_biometric_auth_plus/flutter_biometric_auth_plus.dart';

3. Check Biometric Availability #

// Check if biometrics are available
final bool isAvailable = await BiometricAuth.isBiometricsAvailable();

// Get available biometric types
final List<BiometricAuthType> biometrics = 
    await BiometricAuth.getAvailableBiometrics();

4. Authenticate #

// Basic authentication
final AuthResult result = await BiometricAuth.authenticate(
  reason: 'Please authenticate to access the app',
);

if (result.isSuccess) {
  print('Authentication successful!');
} else {
  print('Authentication failed: ${result.data?['reason']}');
}

5. Authentication with Fallback #

// Try biometrics first, fallback to passcode
final AuthResult result = await BiometricAuth.authenticateWithFallback(
  reason: 'Please authenticate to access the app',
);

if (result.isSuccess) {
  if (result.data?['fallbackUsed'] == true) {
    print('Authenticated using device passcode');
  } else {
    print('Authenticated using biometrics');
  }
}

๐Ÿ”ง Advanced Usage #

Check Device Support #

final bool isSupported = await BiometricAuth.isDeviceSupported();
final String strength = await BiometricAuth.getBiometricStrength();

Handle Different Biometric Types #

final List<BiometricAuthType> availableBiometrics = 
    await BiometricAuth.getAvailableBiometrics();

for (final type in availableBiometrics) {
  print('Available: ${type.displayName} (${type.identifier})');
}

Custom Error Handling #

try {
  final result = await BiometricAuth.authenticate(
    reason: 'Please authenticate',
  );
  // Handle success
} on BiometricException catch (e) {
  switch (e.code) {
    case 'BIOMETRICS_NOT_AVAILABLE':
      print('Biometrics not available: ${e.message}');
      break;
    case 'AUTHENTICATION_FAILED':
      print('Authentication failed: ${e.message}');
      break;
    case 'PERMISSION_DENIED':
      print('Permission denied: ${e.message}');
      break;
  }
}

๐Ÿ—๏ธ Architecture #

This package uses a platform-agnostic approach with automatic fallback:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    BiometricAuth Class                     โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚   Native Impl   โ”‚  โ”‚        Stub Impl               โ”‚  โ”‚
โ”‚  โ”‚                 โ”‚  โ”‚                                 โ”‚  โ”‚
โ”‚  โ”‚ โ€ข Android       โ”‚  โ”‚ โ€ข Web/WASM Compatible          โ”‚  โ”‚
โ”‚  โ”‚ โ€ข iOS           โ”‚  โ”‚ โ€ข WebAuthn API                 โ”‚  โ”‚
โ”‚  โ”‚ โ€ข Windows       โ”‚  โ”‚ โ€ข Fallback Implementation      โ”‚  โ”‚
โ”‚  โ”‚ โ€ข macOS         โ”‚  โ”‚                                 โ”‚  โ”‚
โ”‚  โ”‚ โ€ข Linux         โ”‚  โ”‚                                 โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ”„ Migration from local_auth #

If you're migrating from the local_auth package:

Before (local_auth) #

import 'package:local_auth/local_auth.dart';

final LocalAuthentication auth = LocalAuthentication();
final bool canAuthenticate = await auth.canCheckBiometrics;

After (flutter_biometric_auth_plus) #

import 'package:flutter_biometric_auth_plus/flutter_biometric_auth_plus.dart';

final bool canAuthenticate = await BiometricAuth.isBiometricsAvailable();

Benefits of migration:

  • โœ… Full platform support (was limited to 4/6 platforms)
  • โœ… WASM compatibility (was not compatible)
  • โœ… No external dependencies (was dependent on local_auth)
  • โœ… Better error handling (enhanced error messages)
  • โœ… Automatic fallback (seamless platform switching)

๐Ÿ“‹ Requirements #

  • Flutter: >=3.10.0
  • Dart: >=3.0.0
  • Platforms: iOS 9.0+, Android 6.0+, Web, Windows 10+, macOS 10.14+, Linux

๐Ÿ”’ Permissions #

Android #

Add to android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.USE_BIOMETRIC" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />

iOS #

Add to ios/Runner/Info.plist:

<key>NSFaceIDUsageDescription</key>
<string>This app uses Face ID for secure authentication.</string>

๐Ÿงช Testing #

Run the test suite:

flutter test

Run analysis:

flutter analyze
dart analyze

๐Ÿ“Š Quality Metrics #

  • Pana Score: 160/160 (100%) โœ…
  • Test Coverage: 15/15 tests passing โœ…
  • Analysis: No issues found โœ…
  • Documentation: 95.3% API coverage โœ…
  • Platform Support: 6/6 platforms โœ…
  • WASM Compatibility: Full support โœ…

๐Ÿค Contributing #

Contributions are welcome! Please feel free to submit a Pull Request.

๐Ÿ“„ License #

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments #

  • Flutter Team for the amazing framework
  • Dart Team for the powerful language
  • Community for feedback and contributions

Made with โค๏ธ for the Flutter community

This package is a complete rewrite that removes dependency on external biometric packages and provides full platform support with custom implementations.

3
likes
160
points
17
downloads

Publisher

verified publisherbechattaoui.dev

Weekly Downloads

Enhanced biometric authentication with fallback options and better error handling for Flutter applications.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_biometric_auth_plus