juliansteenbakker / 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.14k stars 391 forks source link

[Mobile] Getting Flutter_secure_storage_windows Error #601

Closed wibowoCodeId closed 3 months ago

wibowoCodeId commented 1 year ago

I got an error when i just using mobile for flutter_secure_storage_windows.

Here the error

/C:/Users/fauzi/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_secure_storage_windows-3.0.0/lib/src/flutter_secure_storage_windows_ffi.dart:253:45:` Error: The argument type 'Pointer' can't be assigned to the parameter type 'int'.

  • 'Pointer' is from 'dart:ffi'.
  • 'Uint8' is from 'dart:ffi'. if (LocalFree(plainTextBlob.ref.pbData).address != NULL) { ^ /C:/Users/fauzi/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_secure_storage_windows-3.0.0/lib/src/flutter_secure_storage_windows_ffi.dart:253:53: Error: The getter 'address' isn't defined for the class 'int'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'address'. if (LocalFree(plainTextBlob.ref.pbData).address != NULL) { ^^^^^^^ /C:/Users/fauzi/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_secure_storage_windows-3.0.0/lib/src/flutter_secure_storage_windows_ffi.dart:371:47: Error: The argument type 'Pointer' can't be assigned to the parameter type 'int'.
  • 'Pointer' is from 'dart:ffi'.
  • 'Uint8' is from 'dart:ffi'. if (LocalFree(encryptedTextBlob.ref.pbData).address != NULL) { ^ /C:/Users/fauzi/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_secure_storage_windows-3.0.0/lib/src/flutter_secure_storage_windows_ffi.dart:371:55: Error: The getter 'address' isn't defined for the class 'int'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'address'. if (LocalFree(encryptedTextBlob.ref.pbData).address != NULL) { ^^^^^^^ Target kernel_snapshot failed: Exception

FAILURE: Build failed with an exception.

  • Where: Script 'C:\Flutter\main\packages\flutter_tools\gradle\src\main\groovy\flutter.groovy' line: 1297

  • What went wrong: Execution failed for task ':app:compileFlutterBuildDevDebug'.

Process 'command 'C:\Flutter\main\bin\flutter.bat'' finished with non-zero exit value 1 `

I just using this for Mobile Version. And this i got when running the mobile version

mshahjahan-mufin commented 1 year ago

@wibowoCodeId Please provide minimal reproducable code.

wibowoCodeId commented 1 year ago

@wibowoCodeId Please provide minimal reproducable code.

Here the code i using this secure storage to secure the hive key.

Future<List<int>> hiveKeys() async {
  const FlutterSecureStorage ss = FlutterSecureStorage();

  const AndroidOptions aOptions = AndroidOptions(
    encryptedSharedPreferences: true,
  );

  const IOSOptions iOptions = IOSOptions(
    accessibility: KeychainAccessibility.first_unlock,
  );
  String? stringKey = await ss.read(
    key: 'boxKey',
    aOptions: aOptions,
    iOptions: iOptions,
  );
  late List<int> hiveKey;
  if (stringKey != null) {
    hiveKey = stringKey.codeUnits;
  } else {
    hiveKey = Hive.generateSecureKey();
    final Uint8List bytes = Uint8List.fromList(hiveKey);
    stringKey = String.fromCharCodes(bytes);
    await ss.write(
      key: 'boxKey',
      value: stringKey,
      aOptions: aOptions,
      iOptions: iOptions,
    );
  }
  return hiveKey;
}
mfurkanyuceal commented 1 year ago

Same issue

dorukatak commented 1 year ago

some issue

Mina-Nashaat10 commented 1 year ago

Is there a solution to the problem?

JamesBrel commented 1 year ago

just delete the folder "/C:/Users/fauzi/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_secure_storage_windows-3.0.0"

and it will work.

JamesBrel commented 1 year ago

Is there a solution to the problem?

just delete the folder "/C:/Users/fauzi/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_secure_storage_windows-3.0.0"

and it will work.

JamesBrel commented 1 year ago

if you put the dependencies_override : win32 , remove it , it is the solution

Nader2004 commented 1 year ago

if you put the dependencies_override : win32 , remove it , it is the solution

in my case i have win32 under the dependencies_override, but i have just upgraded it to : win32: ^5.0.0, and it worked for me.

juliansteenbakker commented 3 months ago

I am closing all older issues. If this issue still exists in the latest version, please let me know.

elmar001 commented 3 months ago

Same issue with the latest version:

../../../.pub-cache/hosted/pub.dev/flutter_secure_storage_windows-3.1.2/lib/src/flutter_secure_storage_windows_ffi.dart:260:45: Error: The argument type 'Pointer' can't be assigned to the parameter type 'int'.

FAILURE: Build failed with an exception.

Working solution it the one mentioned in comments above: Add this high level key directly inside dependency overrides (No need to put package name etc):

dependency_overrides:
  win32: ^5.0.0  # This overrides the version globally for all packages for windows