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

fix(device_info_plus)!: fixed webasm compliance #3254

Merged
merged 5 commits into from
Oct 8, 2024

Conversation

arnaudruffin
Copy link
Contributor

@arnaudruffin arnaudruffin commented Sep 12, 2024

Description

This PR allows device_info_plus to be used in a web project compiled to webasm.

For that a type had to be changed (devicememory became a double?) and one converted from JStype to dart type.
I also took the liberty to update the example "index.html" file, as it was based on a deprecated template and not compatible with webasm compilation.

Most of this commit is a copy of what was done in #3161 by @GiacomoPignoni . Credits go to him.

Related Issues

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I titled the PR using Conventional Commits.
  • I did not modify the CHANGELOG.md nor the plugin version in pubspec.yaml files.
  • All existing and new tests are passing.
  • The analyzer (flutter analyze) does not report any problems on my PR. => not directly on my modifications

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate that with a ! in the title as explained in Conventional Commits).
  • No, this is not a breaking change.

@arnaudruffin arnaudruffin changed the title fix(device_info_plus): fixed webaasm fix(device_info_plus): fixed webasm Sep 12, 2024
@arnaudruffin arnaudruffin changed the title fix(device_info_plus): fixed webasm fix(device_info_plus): fixed webasm compliance Sep 12, 2024
@miquelbeltran miquelbeltran changed the title fix(device_info_plus): fixed webasm compliance fix(device_info_plus)!: fixed webasm compliance Sep 18, 2024
@miquelbeltran
Copy link
Member

Thanks @arnaudruffin this looks good to me now.

I marked the PR as breaking, because it changes a user facing class member type, even if it is just changing from int to double.

@vbuberen
Copy link
Collaborator

I would like to check a few things first. If all is good I will merge and release on Monday.

@GelistirmeKF

This comment was marked as off-topic.

@miquelbeltran
Copy link
Member

miquelbeltran commented Sep 25, 2024

@GelistirmeKF This project is run by volunteers and the PR will be merged and released when we have the time to work on it.

If you are in a hurry, create a fork and import the dependency directly as explained here: https://dart.dev/tools/pub/dependencies#git-packages

@GelistirmeKF
Copy link

Thanks @miquelbeltran for solution alternative. By this package, appreciate the community for valuable efforts

@GelistirmeKF This project is run by volunteers and the PR will be merged and released when we have the time to work on it.

If you are in a hurry, create a fork and import the dependency directly as explained here: https://dart.dev/tools/pub/dependencies#git-packages

Copy link
Member

@miquelbeltran miquelbeltran left a comment

Choose a reason for hiding this comment

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

The web version on device_info_plus needs to be set to ^1.0.0, otherwise if Flutter resolves web 0.5 it won't compile.

I tried to push the commit, but GitHub rejected the push (did you enable allowing maintainers to push changes?)

The required change:

diff --git a/packages/device_info_plus/device_info_plus/pubspec.yaml b/packages/device_info_plus/device_info_plus/pubspec.yaml
index 3457c632..0a025afb 100644
--- a/packages/device_info_plus/device_info_plus/pubspec.yaml
+++ b/packages/device_info_plus/device_info_plus/pubspec.yaml
@@ -37,7 +37,7 @@ dependencies:
   flutter_web_plugins:
     sdk: flutter
   meta: ^1.8.0
-  web: ">=0.5.0 <2.0.0"
+  web: ^1.0.0
 
   # win32 is compatible across v4 and v5 for Win32 only (not COM)
   win32: ">=4.0.0 <6.0.0"

@miquelbeltran
Copy link
Member

Hi @arnaudruffin can you do the requested changes? otherwise I will have to close the PR and create a new one.

@miquelbeltran miquelbeltran self-requested a review October 8, 2024 05:21
@miquelbeltran miquelbeltran changed the title fix(device_info_plus)!: fixed webasm compliance fix(device_info_plus): fixed webasm compliance Oct 8, 2024
@miquelbeltran miquelbeltran changed the title fix(device_info_plus): fixed webasm compliance fix(device_info_plus)!: fixed webasm compliance Oct 8, 2024
@miquelbeltran
Copy link
Member

I managed to push the change to your main branch, git didn't let me at first. Once CI finishes, I will merge this.

I'll do a release for all packages later today.

@miquelbeltran miquelbeltran merged commit e35e212 into fluttercommunity:main Oct 8, 2024
25 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: illegal cast in device_info_plus when compiled to Wasm
4 participants