Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7ccd968
[local_auth] Windows support.
azchohfi Jan 27, 2022
3906da5
Merge branch 'main' into local_auth_windows
azchohfi Feb 17, 2022
70c341d
Merge branch 'main' into local_auth_windows
azchohfi Feb 23, 2022
c492f89
Merge branch 'main' into local_auth_windows
azchohfi Feb 24, 2022
c997ad8
Handling biometricOnly parameter.
azchohfi Feb 25, 2022
9cf0a1a
Merge branch 'main' into local_auth_windows
azchohfi Apr 7, 2022
975ca8d
Fixed readme
azchohfi Apr 7, 2022
3fcbca7
[local_auth] Fix version and readme.
azchohfi Apr 8, 2022
34afbf5
Merge branch 'main' into local_auth_windows
azchohfi Apr 15, 2022
835f5cc
[local_auth] Small fixes.
azchohfi Apr 15, 2022
9eaba3c
Small fix.
azchohfi Apr 15, 2022
22ec14c
Fixed tests.
azchohfi Apr 15, 2022
9349aab
Added local_auth_windows tests.
azchohfi Apr 15, 2022
1032693
PR Feedback.
azchohfi Apr 18, 2022
1659e49
Merge branch 'local_auth_windows' of https://github.com/azchohfi/plug…
azchohfi Apr 18, 2022
8c7a87b
Fixed tests.
azchohfi Apr 18, 2022
bf47529
Added more tests.
azchohfi Apr 18, 2022
8143983
Revert changes in local_auth.
azchohfi Apr 19, 2022
bcf105b
Merge branch 'main' into local_auth_windows
azchohfi Apr 25, 2022
a4f02f4
Merge branch 'main' into local_auth_windows
azchohfi Apr 26, 2022
7449a5c
Merge branch 'main' into local_auth_windows
azchohfi May 9, 2022
fb26c93
Merge branch 'main' into local_auth_windows
azchohfi May 10, 2022
e9ab4ef
[local_auth_windows] Fixed authors list.
azchohfi May 10, 2022
30f0958
[local_auth_windows] Fixed changelog.
azchohfi May 10, 2022
97e1ee9
[local_auth_windows] PR feedback.
azchohfi May 12, 2022
40aa9a2
Merge branch 'main' into local_auth_windows
azchohfi May 12, 2022
6813b7b
Fixed build
azchohfi May 13, 2022
47823c6
Fixed format.
azchohfi May 13, 2022
45ceb6e
Merge branch 'main' into local_auth_windows
azchohfi May 13, 2022
271a49e
Applied more PR feedback.
azchohfi May 13, 2022
e1e24a6
Added C++ comments.
azchohfi May 13, 2022
cabc43e
Small doc fixes.
azchohfi May 13, 2022
34a58de
Merge branch 'main' into local_auth_windows
azchohfi May 16, 2022
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
Fixed format.
  • Loading branch information
azchohfi committed May 13, 2022
commit 47823c6dfa683c7d7b56e9979a0ff61a4fdd7a3b
51 changes: 26 additions & 25 deletions packages/local_auth/local_auth_windows/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,48 @@ import 'package:local_auth_platform_interface/local_auth_platform_interface.dart
import 'package:local_auth_windows/local_auth_windows.dart';

void main() {
runApp(MyApp());
runApp(const MyApp());
}

class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);

@override
_MyAppState createState() => _MyAppState();
State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
_SupportState _supportState = _SupportState.unknown;
bool? _canCheckBiometrics;
List<BiometricType>? _availableBiometrics;
bool? _deviceSupportsBiometrics;
List<BiometricType>? _enrolledBiometrics;
String _authorized = 'Not Authorized';
bool _isAuthenticating = false;

@override
void initState() {
super.initState();
LocalAuthPlatform.instance.isDeviceSupported().then((bool isSupported) {
setState(() {
_supportState =
isSupported ? _SupportState.supported : _SupportState.unsupported;
});
});
LocalAuthPlatform.instance.isDeviceSupported().then(
(bool isSupported) => setState(() => _supportState = isSupported
? _SupportState.supported
: _SupportState.unsupported),
);
}

Future<void> _checkBiometrics() async {
late bool canCheckBiometrics;
late bool deviceSupportsBiometrics;
try {
canCheckBiometrics =
(await LocalAuthPlatform.instance.getEnrolledBiometrics()).isNotEmpty;
deviceSupportsBiometrics =
await LocalAuthPlatform.instance.deviceSupportsBiometrics();
} on PlatformException catch (e) {
canCheckBiometrics = false;
deviceSupportsBiometrics = false;
print(e);
}
if (!mounted) {
return;
}

setState(() {
_canCheckBiometrics = canCheckBiometrics;
_deviceSupportsBiometrics = deviceSupportsBiometrics;
});
}

Expand All @@ -70,7 +71,7 @@ class _MyAppState extends State<MyApp> {
}

setState(() {
_availableBiometrics = availableBiometrics;
_enrolledBiometrics = availableBiometrics;
});
}

Expand Down Expand Up @@ -104,9 +105,8 @@ class _MyAppState extends State<MyApp> {
return;
}

setState(() {
_authorized = authenticated ? 'Authorized' : 'Not Authorized';
});
setState(
() => _authorized = authenticated ? 'Authorized' : 'Not Authorized');
}

Future<void> _authenticateWithBiometrics() async {
Expand Down Expand Up @@ -173,16 +173,17 @@ class _MyAppState extends State<MyApp> {
else
const Text('This device is not supported'),
const Divider(height: 100),
Text('Can check biometrics: $_canCheckBiometrics\n'),
Text(
'Device supports biometrics: $_deviceSupportsBiometrics\n'),
ElevatedButton(
child: const Text('Check biometrics'),
onPressed: _checkBiometrics,
child: const Text('Check biometrics'),
),
const Divider(height: 100),
Text('Available biometrics: $_availableBiometrics\n'),
Text('Enrolled biometrics: $_enrolledBiometrics\n'),
ElevatedButton(
child: const Text('Get available biometrics'),
onPressed: _getEnrolledBiometrics,
child: const Text('Get enrolled biometrics'),
),
const Divider(height: 100),
Text('Current State: $_authorized\n'),
Expand All @@ -201,16 +202,17 @@ class _MyAppState extends State<MyApp> {
Column(
children: <Widget>[
ElevatedButton(
onPressed: _authenticate,
child: Row(
mainAxisSize: MainAxisSize.min,
children: const <Widget>[
Text('Authenticate'),
Icon(Icons.perm_device_information),
],
),
onPressed: _authenticate,
),
ElevatedButton(
onPressed: _authenticateWithBiometrics,
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Expand All @@ -220,7 +222,6 @@ class _MyAppState extends State<MyApp> {
const Icon(Icons.fingerprint),
],
),
onPressed: _authenticateWithBiometrics,
),
],
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class WindowsAuthMessages extends AuthMessages {

@override
int get hashCode => Object.hash(
super.hashCode,
biometricHint,
biometricNotRecognized,
biometricRequiredTitle,
Expand Down Expand Up @@ -186,6 +187,6 @@ String get windowsDeviceCredentialsSetupDescription =>
/// biometric on their device.
String get windowsGoToSettingsDescription => Intl.message(
'Biometric authentication is not set up on your device. Go to '
'\'Settings > Security\' to add biometric authentication.',
"'Settings > Security' to add biometric authentication.",
desc: 'Message advising the user to go to the settings and configure '
'biometric on their device.');