Skip to content

Commit

Permalink
Biometric unavailable popup only shows if setting enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
jameskokoska committed Feb 7, 2024
1 parent 442b6e6 commit 3a17c61
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions budget/lib/struct/initializeBiometrics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:local_auth/local_auth.dart';

// Returns null if there was an error or if biometrics are unavailable
Future<bool?> checkBiometrics({
bool checkAlways = false,
}) async {
final bool requireAuth =
checkAlways || appStateSettings["requireAuth"] == true;
try {
if (kIsWeb) return true;
final LocalAuthentication auth = LocalAuthentication();
final bool requireAuth = checkAlways || appStateSettings["requireAuth"];
biometricsAvailable = kIsWeb == false && await auth.canCheckBiometrics ||
await auth.isDeviceSupported();
if (biometricsAvailable == false) {
return null;
if (requireAuth)
return null;
else
return false;
} else if (requireAuth == true && biometricsAvailable == true) {
await auth.stopAuthentication();
return await auth.authenticate(
Expand All @@ -33,7 +36,10 @@ Future<bool?> checkBiometrics({
}
} catch (e) {
print("Error with biometrics: " + e.toString());
return null;
if (requireAuth)
return null;
else
return false;
}
}

Expand Down
2 changes: 1 addition & 1 deletion budget/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 5.2.0+320
version: 5.2.0+321

environment:
sdk: ">= 3.0.0"
Expand Down

0 comments on commit 3a17c61

Please sign in to comment.