mogol / flutter_secure_storage

A Flutter plugin to store data in secure storage
https://pub.dartlang.org/packages/flutter_secure_storage
BSD 3-Clause "New" or "Revised" License
1.09k stars 340 forks source link

onCupertinoProtectedDataAvailabilityChanged listener is not returning any value(true or false) even when isCupertinoProtectedDataAvailable is true #733

Open aswinranjith-iouring opened 3 weeks ago

aswinranjith-iouring commented 3 weeks ago

Hi, I am facing this where I have protected data stored in my keychain using flutter_secure_storage and I need to check if protected data is available or not then whenever the data becomes available I need to get the values from the keychain. here is my code. but the issue is even when isProtectedDataAvailable is true the listener is not returning anything. Is this an implementation issue or am I missing something? Please tell me how to implement this properly. The package version I am using is 9.2.2

final isProtectedDataAvailable =
    await _storage.isCupertinoProtectedDataAvailable();

if (isProtectedDataAvailable ?? false) {
  _storage.onCupertinoProtectedDataAvailabilityChanged?.listen(
    (availability) {
      if (availability) {
        LogManager().log('availability true');
      } else {
        // Handle normal flow
        LogManager().log('availability false');
      }
    },
    onError: (e) {
      LogManager().log('error occurred $e');
    },
    cancelOnError: true,
    onDone: () {
      LogManager().log('Done');
    },
  );
}
aswinranjith-iouring commented 3 weeks ago

Here is flutter doctor -v information [✓] Flutter (Channel stable, 3.19.6, on macOS 14.0 23A344 darwin-arm64, locale en-IN) • Flutter version 3.19.6 on channel stable at /Users/aswinranjith/Documents/flutter 3.19.6/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 54e66469a9 (7 weeks ago), 2024-04-17 13:08:03 -0700 • Engine revision c4cd48e186 • Dart version 3.3.4 • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/aswinranjith/Library/Android/sdk • Platform android-34, build-tools 34.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15F31d • CocoaPods version 1.14.3

[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.3) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)

[✓] VS Code (version 1.89.1) • VS Code at /Users/aswinranjith/Downloads/Visual Studio Code.app/Contents • Flutter extension version 3.82.0

[✓] Connected device (4 available) • Aswin’s iPhone (mobile) • hiding device id • ios • iOS 17.5.1 21F90 • iPhone 15 (mobile) • hiding device id • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-4 (simulator) • macOS (desktop) • macos • darwin-arm64 • macOS 14.0 23A344 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 125.0.6422.142 ! Error: Browsing on the local area network for Aswin’s iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac. The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources • All expected network resources are available.

• No issues found!

mcg95 commented 2 weeks ago

I am facing the same issue. There doesn't seem to be any values being returned by the listener.