Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b53743a
Bind to local platform interface package
stuartmorgan-g Aug 26, 2025
dff4dec
Add structured exception class
stuartmorgan-g Aug 26, 2025
0f54e0f
Update Windows
stuartmorgan-g Aug 26, 2025
9f9c148
Clarify platform interface docs
stuartmorgan-g Sep 3, 2025
a623537
Android implementation
stuartmorgan-g Aug 27, 2025
8ce45dc
Convert iOS
stuartmorgan-g Sep 3, 2025
6b44729
Documentation updates
stuartmorgan-g Sep 4, 2025
3894214
Remove useErrorDialogs and all related handling, update README
stuartmorgan-g Sep 8, 2025
b7cbe24
More changelog and version updates
stuartmorgan-g Sep 9, 2025
4897463
Rename Android biometricHint
stuartmorgan-g Sep 9, 2025
7362182
Throw structured exception from getEnrolledBiometrics
stuartmorgan-g Sep 9, 2025
a9d6b2f
Merge branch 'main' into local-auth-structured-errors
stuartmorgan-g Sep 9, 2025
359be0c
Apply Gemini error formatting suggestions in app-facing package
stuartmorgan-g Sep 11, 2025
5d23e5c
autoformat Gemini changes
stuartmorgan-g Sep 11, 2025
4f8fb80
Merge branch 'main' into local-auth-structured-errors
stuartmorgan-g Sep 11, 2025
3125501
Merge branch 'main' into local-auth-structured-errors
stuartmorgan-g Sep 16, 2025
d6dc783
Typo fixes
stuartmorgan-g Sep 16, 2025
11d257d
Merge branch 'main' into local-auth-structured-errors
stuartmorgan-g Sep 17, 2025
f11d2be
Update for adjustment to auth_options
stuartmorgan-g Sep 24, 2025
4e99fdd
Sync with landed version of platform interface
stuartmorgan-g Sep 30, 2025
fbd24bf
Merge branch 'main' into local-auth-structured-errors
stuartmorgan-g Sep 30, 2025
859b046
iOS README update
stuartmorgan-g Sep 30, 2025
3955e48
Revert app-facing package
stuartmorgan-g Sep 30, 2025
bb45330
Update interface dependency
stuartmorgan-g Sep 30, 2025
2796b1c
Merge branch 'main' into local-auth-structured-errors-impls
stuartmorgan-g Oct 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add structured exception class
  • Loading branch information
stuartmorgan-g committed Aug 26, 2025
commit dff4dec6abd31ad818fff2500fa244a47fe8d394
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## NEXT
## 1.1.0

* Adds `LocalAuthException` to allow for consistent, structured exceptions
across platform implementations.
* Updates minimum supported SDK version to Flutter 3.29/Dart 3.7.

## 1.0.10
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/foundation.dart';

/// An exception thrown by the plugin when there is authenication failure, or
/// some other error.
@immutable
class LocalAuthException implements Exception {
/// Crceates a new exception with the given information.
const LocalAuthException({
required this.code,
this.description,
this.details,
});

/// The type of failure.
final LocalAuthExceptionCode code;

/// A human-readable description of the failure.
final String? description;

/// Any additional details about the failure.
final Object? details;

@override
String toString() => 'LocalAuthException(code $code, $description, $details)';
}

/// Types of [LocalAuthException]s, as indicated by [LocalAuthException.code].
///
/// Adding new values to this enum in the future will *not* be considered a
/// breaking change, so clients should not assume they can exhaustively match
/// exception codes. Clients should always include a default or other fallback.
enum LocalAuthExceptionCode {
/// An authentication operation is already in progress, and has not completed.
///
/// A new authentication cannot be started while the Future for a previous
/// authentication is still outstanding.
authInProgress,

/// UI needs to be displayed, but could not be.
///
/// For example, this can be returned on Android if a call tries to show UI
/// when no Activity is available.
uiUnavailable,

/// The operation was canceled by the user.
userCanceled,

/// The operation was canceled due to a device-specific timeout.
timeout,

/// The operation was canceled by a system event.
///
/// For example, on mobile this may be returned if the application is
/// backgrounded during authentication.
systemCanceled,

/// The device has no credentials configured.
///
/// For example, on mobile this would be returned if the device has no
/// enrolled biometrics and no fallback authentication mechanism set such as
/// a passcode, pin, or pattern.
noCredentialsSet,

/// The device is capable of biometric authentication, but no biometrics are
/// enrolled.
noBiometricsEnrolled,

/// The device does not have biometric hardware.
noBiometricHardware,

/// The device has, or can have, biometric hardware, but none is currently
/// available.
///
/// Examples include:
/// - Hardware that is currently in use by another application.
/// - Devices that have previously paired with bluetooth biometric hardware,
/// but are not currently paired to it.
///
/// Devices that could have removable hardware attached may return either this
/// or [noBiometricHardware] depending on the platform implementation.
/// Platforms should generally only return this code if the system provides
/// information indicating that the device has previously had such hardware.
biometricHardwareTemporarilyUnavailable,

/// Authentication has temporarily been locked out, and should be re-attempted
/// later.
///
/// For example, devices may return this error after too many failed
/// authentication attempts.
temporaryLockout,

/// Biometric authentication has been locked until some other authentication
/// has succeeded.
///
/// Applications that do not require biometric authentication should generally
/// handle this error by re-attempting authentication with fallback to
/// non-biometrics allowed. Applications that require biometrics should
/// prompt users to resolve the lockout.
biometricLockout,

/// The user indicated via system-provided UI that they want to use a fallback
/// authentication option instead of biometrics.
///
/// Whether this can be returned depends on the platform implementation and
/// the authentication configuration options. Applications should generally
/// handle this error by offering the user an alternate authentication option.
userRequestedFallback,

/// The authentication attempt failed due to some device-level error.
///
/// The [LocalAuthException.description] should contain more details about the
/// error.
deviceError,

/// The authentication attempt failed due to some unknown or unexpected error.
///
/// The [LocalAuthException.description] should contain more details about the
/// error.
unknownError,
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

export 'auth_exception.dart';
export 'auth_messages.dart';
export 'auth_options.dart';
export 'biometric_type.dart';
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/local_auth/lo
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+local_auth%22
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 1.0.10
version: 1.1.0

environment:
sdk: ^3.7.0
Expand Down