setTouchIDAuthenticationAllowableReuseDuration method

Future<double> setTouchIDAuthenticationAllowableReuseDuration(
  1. double duration
)

Sets the allowable reuse duration for Touch ID authentication (iOS/macOS only).

On iOS and macOS, this method allows you to specify the allowable duration for reusing a previously authenticated Touch ID (fingerprint) to unlock an app or perform secure actions. This duration is specified in seconds.

This method is applicable only to iOS and macOS platforms. On other platforms, it throws an error indicating that the method is not supported.

Parameters:

  • duration: The allowable reuse duration in seconds.

Returns a Future with a double value representing the allowable reuse duration. If the operation is successful, it returns the specified duration value. If the method is not supported on the current platform, it throws an error.

Example usage (iOS/macOS):

double allowableReuseDuration = 30.0; // 30 seconds
double result = await setTouchIDAuthenticationAllowableReuseDuration(allowableReuseDuration);
// Allowable reuse duration set successfully

Throws an exception if there's an issue with setting the allowable reuse duration.

Note: This method may not be available on all versions of iOS or macOS, so it's important to check for platform compatibility before using it.

Implementation

Future<double> setTouchIDAuthenticationAllowableReuseDuration(
    double duration) async {
  if (Platform.isIOS || Platform.isMacOS) {
    return await FlutterLocalAuthenticationPlatform.instance
        .setTouchIDAuthenticationAllowableReuseDuration(duration);
  }
  return Future.value(duration);
}