title: Flutter: How can I check if ping / touch / face / whatever is set up on the phone using local_auth package?
body: <p>I am making an app and trying to use the local_auth package: <a href="https://pub.dev/packages/local_auth" rel="nofollow noreferrer">https://pub.dev/packages/local_auth</a></p>
  <p>Works great if I have PIN or fingerprint set up but if I don't have anything... Then I have no idea what to do.</p>
  <p>I have this code:</p>
  <pre><code>@override
    Widget build(BuildContext context) {
      print(&quot;Is device supported ----&gt; $_isDeviceSupported&quot;);
      print(&quot;Have biometrics -&gt; $_haveBiometrics&quot;);
      print(&quot;Biometric authenticated -&gt; $_biometricAuthenticated&quot;);
      print(&quot;Not available -&gt; $_notAvailable&quot;);
  
  
      return _notAvailable ? _widgetToShowIfAuthenticated : _isDeviceSupported
          ? _haveBiometrics
              ? _biometricAuthenticated
                  ? _widgetToShowIfAuthenticated
                  : authenticationPage()
              : _widgetToShowIfAuthenticated
          : authenticationPage();
    }
  </code></pre>
  <p>I can check if the device have any of these option. For example can it have a PIN code or fingerprint? -&gt; <code>_isDeviceSupported</code>
  I can check if it has any biometric authentication -&gt; <code>_haveBiometrics</code></p>
  <p>These work great if the phone have PIN or fingerprint. But if the device is able to use these kind of authentication methods, the <code>_isDeviceSupported</code> is true, but if I try to authenticate I get an error:</p>
  <p><code>PlatformException(NotAvailable, Required security features not enabled, null, null)</code></p>
  <p>And I want to find out that it is <code>NotAvailable</code> before I get the exception. At the moment I have this:</p>
  <pre><code>  void authenticate() async {
      if (!biometricAuthenticated) {
        try {
          biometricAuthenticated = await _auth.authenticate(
            localizedReason: &quot;Please authenticate&quot;,
            stickyAuth: true,
            useErrorDialogs: true,
            biometricOnly: false,
          );
        } on PlatformException catch (e) {
          print(e);
          print(&quot;Message: ${e.message}&quot;);
          print(&quot;Message: ${e.code}&quot;);
          if (e.code == &quot;NotAvailable&quot;) notAvailable = true;
        }
      }
    }
  </code></pre>
  <p>As you can see I have to first catch the exception then set the <code>notAvailable</code> variable true... This does not seem right. I should check somehow even if the phone is able to use these security methods, are they set up...</p>