From 3a17c61c2f93cf6ddb07162eecbf2239dcbe922c Mon Sep 17 00:00:00 2001 From: jameskokoska <50821962+jameskokoska@users.noreply.github.com> Date: Tue, 6 Feb 2024 23:33:11 -0500 Subject: [PATCH] Biometric unavailable popup only shows if setting enabled --- budget/lib/struct/initializeBiometrics.dart | 14 ++++++++++---- budget/pubspec.yaml | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/budget/lib/struct/initializeBiometrics.dart b/budget/lib/struct/initializeBiometrics.dart index a1d685ef..231a2782 100644 --- a/budget/lib/struct/initializeBiometrics.dart +++ b/budget/lib/struct/initializeBiometrics.dart @@ -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 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( @@ -33,7 +36,10 @@ Future checkBiometrics({ } } catch (e) { print("Error with biometrics: " + e.toString()); - return null; + if (requireAuth) + return null; + else + return false; } } diff --git a/budget/pubspec.yaml b/budget/pubspec.yaml index 59ab1ac2..33e368a4 100644 --- a/budget/pubspec.yaml +++ b/budget/pubspec.yaml @@ -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"