diff --git a/packages/local_auth/local_auth_ohos/example/lib/main.dart b/packages/local_auth/local_auth_ohos/example/lib/main.dart index f9bab12b92b3450db9bba8044bc863f447f3ed29..23abdda0ed5d73188b673fa31ef6720e8dfc13fb 100644 --- a/packages/local_auth/local_auth_ohos/example/lib/main.dart +++ b/packages/local_auth/local_auth_ohos/example/lib/main.dart @@ -147,8 +147,12 @@ class _MyAppState extends State { } Future _cancelAuthentication() async { - await LocalAuthPlatform.instance.stopAuthentication(); - setState(() => _isAuthenticating = false); + bool result = await LocalAuthPlatform.instance.stopAuthentication(); + setState(() { + _isAuthenticating = !result; + _authorized = result ? 'Not Authorized' : 'Authorized'; + }); + } @override @@ -185,7 +189,7 @@ class _MyAppState extends State { ), const Divider(height: 100), Text('Current State: $_authorized\n'), - if (_isAuthenticating) + if (_authorized == 'Authorized') ElevatedButton( onPressed: _cancelAuthentication, // TODO(goderbauer): Make this const when this package requires Flutter 3.8 or later.