Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update js dependency and migrate to web #680

Merged
merged 4 commits into from
May 8, 2024

Conversation

ThexXTURBOXx
Copy link
Contributor

@ThexXTURBOXx ThexXTURBOXx commented Feb 17, 2024

This allows newer versions of js being used in conjunction with flutter_secure_storage. Also, as html is about to get phased out, this PR already migrates to web as it is recommended practice to do so.

Fixes #670
Fixes #679
Fixes #683

If you want to use this now, you can do so via a dependency_override:

dependency_overrides:
  flutter_secure_storage:
    git:
      url: https://github.com/ThexXTURBOXx/flutter_secure_storage.git
      ref: develop
      path: flutter_secure_storage

You probably need to also override the other subpackages similarly (I won't explain how to do that. Just do it as I have shown with the main package above).

@ThexXTURBOXx ThexXTURBOXx changed the title Update js dependency Update js dependency and migrate to web Feb 17, 2024
@ThexXTURBOXx
Copy link
Contributor Author

This PR now also migrates from html to web since package maintainers are advised to do so sooner than later

@JgomesAT
Copy link

Is there any date to merge this and create a new version??

@ThexXTURBOXx
Copy link
Contributor Author

@JgomesAT I don't even know if this will ever get merged as the repo owner is not very active currently.
For the time being, you can use my fork through a dependency_override

@JgomesAT
Copy link

dependency_overrides:
  flutter_secure_storage:
    git:
      url: https://github.com/ThexXTURBOXx/flutter_secure_storage.git
      ref: develop
      path: flutter_secure_storage

With the version of your repo I have an error in compilation:

../../../../.pub-cache/git/flutter_secure_storage-6ac827e457393b5c654c1abda40d31e2cb93f62c/flutter_secure_storage/lib/flutter_secure_storage.dart:268:17: Error: The getter 'onCupertinoProtectedDataAvailabilityChanged' isn't defined for the class 'FlutterSecureStoragePlatform'.

  • 'FlutterSecureStoragePlatform' is from 'package:flutter_secure_storage_platform_interface/flutter_secure_storage_platform_interface.dart' ('../../../../.pub-cache/hosted/pub.dev/flutter_secure_storage_platform_interface-1.0.2/lib/flutter_secure_storage_platform_interface.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'onCupertinoProtectedDataAvailabilityChanged'.
    _platform.onCupertinoProtectedDataAvailabilityChanged;
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ../../../../.pub-cache/git/flutter_secure_storage-6ac827e457393b5c654c1abda40d31e2cb93f62c/flutter_secure_storage/lib/flutter_secure_storage.dart:278:17: Error: The method 'isCupertinoProtectedDataAvailable' isn't defined for the class 'FlutterSecureStoragePlatform'.
  • 'FlutterSecureStoragePlatform' is from 'package:flutter_secure_storage_platform_interface/flutter_secure_storage_platform_interface.dart' ('../../../../.pub-cache/hosted/pub.dev/flutter_secure_storage_platform_interface-1.0.2/lib/flutter_secure_storage_platform_interface.dart').
    Try correcting the name to the name of an existing method, or defining a method named 'isCupertinoProtectedDataAvailable'.
    _platform.isCupertinoProtectedDataAvailable();
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@ThexXTURBOXx
Copy link
Contributor Author

You probably need to override the other packages as well

@JgomesAT
Copy link

You probably need to override the other packages as well

What other package??

@ThexXTURBOXx
Copy link
Contributor Author

As described above, the platform interface and web submodules (and probably also linux etc.

@JgomesAT
Copy link

As described above, the platform interface and web submodules (and probably also linux etc.

but this library is part of the flutter_storage I don't have this library in the pubspec

@JgomesAT
Copy link

IF I put your repo in the pubspec dependencies: and the old one in the dependencies_override

dependencies:
flutter_secure_storage:
git:
url: https://github.com/ThexXTURBOXx/flutter_secure_storage.git
ref: develop
path: flutter_secure_storage

dependency_overrides:
flutter_secure_storage: ^9.0.0

I have a successful build

@ThexXTURBOXx
Copy link
Contributor Author

IF I put your repo in the pubspec dependencies: and the old one in the dependencies_override

@JgomesAT Then, you are using the official version

but this library is part of the flutter_storage I don't have this library in the pubspec

You have all these packages in your pubspec.lock and hence you will need to override all of them.
Please refrain from commenting under this PR unless there is an issue with my code. For further information, please consult StackOverflow instead.

@JgomesAT
Copy link

I think that is an issue of your code I only use your repo, and I removed all references of package flutter_secure_storage: ^9.0.0
the error is in the run in a flutter in a web in debug mode in an Apple(iMAC) device

@ThexXTURBOXx
Copy link
Contributor Author

This is an issue with your current setup.
Take a look inside your pubspec.lock (NOT pubspec.yaml). You will need to override ALL the packages that start with flutter_secure_storage.
Then it works without any problems.
I won't answer any questions not related to my code here anymore.

@JgomesAT
Copy link

I'm sorry, but I didn't understand, this behavior is strange I need to add all submodules, in a possible final merge of the library this won't be necessary, will it?

example I need to add this in the override:

flutter_secure_storage_platform_interface:
git:
url: https://github.com/ThexXTURBOXx/flutter_secure_storage.git
ref: develop
path: flutter_secure_storage_platform_interface

@ThexXTURBOXx
Copy link
Contributor Author

Exactly, after merging and releasing these changes properly to pub.dev, this won't be necessary anymore.

@@ -13,7 +13,8 @@ dependencies:
flutter_secure_storage_platform_interface: ^1.0.1
flutter_web_plugins:
sdk: flutter
js: ^0.6.3
js: '>=0.6.3 <1.0.0'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
js: '>=0.6.3 <1.0.0'

The migration to the new js-interop approach also means getting rid of the package:js.

https://dart.dev/interop/js-interop/package-web

See also these comments firebase/flutterfire#12027 (comment) from Kevin Moore (Flutter Web PM)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes, thanks for reminding me about this... Currently, I don't have enough free time to also address this, but hopefully I will do so soon!

Copy link

@IchordeDionysos IchordeDionysos Apr 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries 😌 I hear your struggle to find time to maintain/contribute to open-source projects!

@ombhd
Copy link

ombhd commented Apr 3, 2024

Will this be merged soon?

@StefanTasevski
Copy link

StefanTasevski commented Apr 11, 2024

Can this get merged? @ThexXTURBOXx

@ThexXTURBOXx
Copy link
Contributor Author

I think yes. Someone might want to migrate some stuff to js_interop, though

@jtavio
Copy link

jtavio commented Apr 24, 2024

When will you make the merge of this?

@ThexXTURBOXx
Copy link
Contributor Author

@juliansteenbakker Since I have seen that you are about to incorporate this, I want to mention that the js_interop migration from #698 should also be considered. A mixture of this PR right here and #698 is probably the best way to go.
Do you want me to rebase my PR right here onto your upstream master?

@juliansteenbakker
Copy link
Owner

Hi @ThexXTURBOXx , that would be awesome ! I am planning on releasing a smaller version with bug fixes first today, and a new major version with some breaking changes and possibly this PR somewhere in the end of this week.

@ThexXTURBOXx
Copy link
Contributor Author

@juliansteenbakker Done! :)

@@ -1,7 +1,7 @@
name: flutter_secure_storage_web
description: Web implementation of flutter_secure_storage. Use flutter_secure_storage for the full flutter package.
repository: https://github.com/mogol/flutter_secure_storage
version: 1.1.2
version: 1.2.0

environment:
sdk: ">=2.12.0 <4.0.0"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good, however the only thing that's a bit annoying is that the web package is available from dart 3.3, which is basically the latest flutter version, meaning that if we publish this, everyone is required to run the latest Flutter version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is true. I have pushed the constraints for web down as far as possible. Older versions lack features that are (IMHO) critical for the functionality of flutter_secure_storage. Maybe, the constraints could be pushed even lower than that using some hacky workarounds, but I am unsure.
This is also one of the reasons why it makes sense to apply this PR (and #698 for that matter) only after a major version bump

@juliansteenbakker
Copy link
Owner

I have released v9.1.0 which has all fixes that are possible for the current lower sdk version. So i will now merge this, and the next release (v10) will use the higher sdk version.

@juliansteenbakker juliansteenbakker merged commit 7e2321a into juliansteenbakker:develop May 8, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update flutter_secure_storage_web depends on js ^0.6.3 Migrate to package:web Upgrade dependency js
7 participants