import 'package:flutter/material.dart';
import 'package:local_auth/local_auth.dart';

class LocalAuth {
  static final _auth = LocalAuthentication();

  static Future<bool> _canAthenticate() async =>
      await _auth.canCheckBiometrics || await _auth.isDeviceSupported();

  static Future<bool> authenticate() async {
    try {
      if (!await _canAthenticate()) return false;
      return await _auth.authenticate(
        localizedReason: 'Use Fingerprint or Face Id to authenticate',
        options: const AuthenticationOptions(
          biometricOnly: true,
          useErrorDialogs: true,
          stickyAuth: true,
        ),
        // authMessages: <AuthMessages>[
        //   AndroidAuthMessages(
        //     signInTitle: 'Oops! Biometric authentication required!',
        //     cancelButton: 'No thanks',
        //   ),
        //   IOSAuthMessages(
        //     cancelButton: 'No thanks',
        //   ),
        // ],
        
      );
      // final bool didAuthenticate = await _auth.authenticate(
      //   localizedReason: 'Please authenticate to show account balance',
      //   authMessages: const <AuthMessages>[
      //     AndroidAuthMessages(
      //       signInTitle: 'Oops! Biometric authentication required!',
      //       cancelButton: 'No thanks',
      //     ),
      //     IOSAuthMessages(
      //       cancelButton: 'No thanks',
      //     ),
      //   ]);
    } catch (e) {
      debugPrint('error $e');
      return false;
    }
  }
}
